import { P as me, n as Ae, bg as de, d as k, a0 as pt, _ as ee, c as he, aa as Vt, bE as zt, o as Gt, i as Wt, K as Ce, N as Xt, bB as Ut, bF as Yt, bG as qt, bH as Jt, p as Qt, g as Zt, C as en, aj as tn, m as nn, r as on, b9 as nt, ah as an } from "./index2.js";
import { defineComponent as Ne, provide as bt, computed as b, inject as mt, shallowRef as O, createVNode as K, getCurrentInstance as ln, reactive as Kt, onMounted as xt, onUpdated as rn, watch as Ke, nextTick as kt, onBeforeUnmount as sn, Transition as dn, withDirectives as cn, vShow as un, ref as Je, Fragment as vn, toRaw as ot, watchEffect as $e, onUnmounted as fn, cloneVNode as yn } from "vue";
import { h as Fe, i as _e, j as St, e as gn, f as hn, c as pn, g as at, k as bn, l as lt, u as mn, p as Qe, a as Ze, b as ve, m as Kn, n as it, d as ge, o as xn } from "./useMaxLevel.js";
const Ct = Symbol("TreeContextKey"), kn = Ne({
  compatConfig: {
    MODE: 3
  },
  name: "TreeContext",
  props: {
    value: {
      type: Object
    }
  },
  setup(e, a) {
    let {
      slots: l
    } = a;
    return bt(Ct, b(() => e.value)), () => {
      var s;
      return (s = l.default) === null || s === void 0 ? void 0 : s.call(l);
    };
  }
}), tt = () => mt(Ct, b(() => ({}))), wt = Symbol("KeysStateKey"), Sn = (e) => {
  bt(wt, e);
}, Et = () => mt(wt, {
  expandedKeys: O([]),
  selectedKeys: O([]),
  loadedKeys: O([]),
  loadingKeys: O([]),
  checkedKeys: O([]),
  halfCheckedKeys: O([]),
  expandedKeysSet: b(() => /* @__PURE__ */ new Set()),
  selectedKeysSet: b(() => /* @__PURE__ */ new Set()),
  loadedKeysSet: b(() => /* @__PURE__ */ new Set()),
  loadingKeysSet: b(() => /* @__PURE__ */ new Set()),
  checkedKeysSet: b(() => /* @__PURE__ */ new Set()),
  halfCheckedKeysSet: b(() => /* @__PURE__ */ new Set()),
  flattenNodes: O([])
}), Cn = (e) => {
  let {
    prefixCls: a,
    level: l,
    isStart: s,
    isEnd: c
  } = e;
  const g = `${a}-indent-unit`, d = [];
  for (let E = 0; E < l; E += 1)
    d.push(K("span", {
      key: E,
      class: {
        [g]: !0,
        [`${g}-start`]: s[E],
        [`${g}-end`]: c[E]
      }
    }, null));
  return K("span", {
    "aria-hidden": "true",
    class: `${a}-indent`
  }, [d]);
}, Dt = {
  eventKey: [String, Number],
  prefixCls: String,
  // By parent
  // expanded: { type: Boolean, default: undefined },
  // selected: { type: Boolean, default: undefined },
  // checked: { type: Boolean, default: undefined },
  // loaded: { type: Boolean, default: undefined },
  // loading: { type: Boolean, default: undefined },
  // halfChecked: { type: Boolean, default: undefined },
  // dragOver: { type: Boolean, default: undefined },
  // dragOverGapTop: { type: Boolean, default: undefined },
  // dragOverGapBottom: { type: Boolean, default: undefined },
  // pos: String,
  title: me.any,
  /** New added in Tree for easy data access */
  data: {
    type: Object,
    default: void 0
  },
  parent: {
    type: Object,
    default: void 0
  },
  isStart: {
    type: Array
  },
  isEnd: {
    type: Array
  },
  active: {
    type: Boolean,
    default: void 0
  },
  onMousemove: {
    type: Function
  },
  // By user
  isLeaf: {
    type: Boolean,
    default: void 0
  },
  checkable: {
    type: Boolean,
    default: void 0
  },
  selectable: {
    type: Boolean,
    default: void 0
  },
  disabled: {
    type: Boolean,
    default: void 0
  },
  disableCheckbox: {
    type: Boolean,
    default: void 0
  },
  icon: me.any,
  switcherIcon: me.any,
  domRef: {
    type: Function
  }
}, wn = {
  prefixCls: {
    type: String
  },
  // data: { type: Array as PropType<FlattenNode[]> },
  motion: {
    type: Object
  },
  focusable: {
    type: Boolean
  },
  activeItem: {
    type: Object
  },
  focused: {
    type: Boolean
  },
  tabindex: {
    type: Number
  },
  checkable: {
    type: Boolean
  },
  selectable: {
    type: Boolean
  },
  disabled: {
    type: Boolean
  },
  // expandedKeys: { type: Array as PropType<Key[]> },
  // selectedKeys: { type: Array as PropType<Key[]> },
  // checkedKeys: { type: Array as PropType<Key[]> },
  // loadedKeys: { type: Array as PropType<Key[]> },
  // loadingKeys: { type: Array as PropType<Key[]> },
  // halfCheckedKeys: { type: Array as PropType<Key[]> },
  // keyEntities: { type: Object as PropType<Record<Key, DataEntity<DataNode>>> },
  // dragging: { type: Boolean as PropType<boolean> },
  // dragOverNodeKey: { type: [String, Number] as PropType<Key> },
  // dropPosition: { type: Number as PropType<number> },
  // Virtual list
  height: {
    type: Number
  },
  itemHeight: {
    type: Number
  },
  virtual: {
    type: Boolean
  },
  onScroll: {
    type: Function
  },
  onKeydown: {
    type: Function
  },
  onFocus: {
    type: Function
  },
  onBlur: {
    type: Function
  },
  onActiveChange: {
    type: Function
  },
  onContextmenu: {
    type: Function
  },
  onListChangeStart: {
    type: Function
  },
  onListChangeEnd: {
    type: Function
  }
}, En = () => ({
  prefixCls: String,
  focusable: {
    type: Boolean,
    default: void 0
  },
  activeKey: [Number, String],
  tabindex: Number,
  children: me.any,
  treeData: {
    type: Array
  },
  fieldNames: {
    type: Object
  },
  showLine: {
    type: [Boolean, Object],
    default: void 0
  },
  showIcon: {
    type: Boolean,
    default: void 0
  },
  icon: me.any,
  selectable: {
    type: Boolean,
    default: void 0
  },
  expandAction: [String, Boolean],
  disabled: {
    type: Boolean,
    default: void 0
  },
  multiple: {
    type: Boolean,
    default: void 0
  },
  checkable: {
    type: Boolean,
    default: void 0
  },
  checkStrictly: {
    type: Boolean,
    default: void 0
  },
  draggable: {
    type: [Function, Boolean]
  },
  defaultExpandParent: {
    type: Boolean,
    default: void 0
  },
  autoExpandParent: {
    type: Boolean,
    default: void 0
  },
  defaultExpandAll: {
    type: Boolean,
    default: void 0
  },
  defaultExpandedKeys: {
    type: Array
  },
  expandedKeys: {
    type: Array
  },
  defaultCheckedKeys: {
    type: Array
  },
  checkedKeys: {
    type: [Object, Array]
  },
  defaultSelectedKeys: {
    type: Array
  },
  selectedKeys: {
    type: Array
  },
  allowDrop: {
    type: Function
  },
  dropIndicatorRender: {
    type: Function
  },
  onFocus: {
    type: Function
  },
  onBlur: {
    type: Function
  },
  onKeydown: {
    type: Function
  },
  onContextmenu: {
    type: Function
  },
  onClick: {
    type: Function
  },
  onDblclick: {
    type: Function
  },
  onScroll: {
    type: Function
  },
  onExpand: {
    type: Function
  },
  onCheck: {
    type: Function
  },
  onSelect: {
    type: Function
  },
  onLoad: {
    type: Function
  },
  loadData: {
    type: Function
  },
  loadedKeys: {
    type: Array
  },
  onMouseenter: {
    type: Function
  },
  onMouseleave: {
    type: Function
  },
  onRightClick: {
    type: Function
  },
  onDragstart: {
    type: Function
  },
  onDragenter: {
    type: Function
  },
  onDragover: {
    type: Function
  },
  onDragleave: {
    type: Function
  },
  onDragend: {
    type: Function
  },
  onDrop: {
    type: Function
  },
  /**
   * Used for `rc-tree-select` only.
   * Do not use in your production code directly since this will be refactor.
   */
  onActiveChange: {
    type: Function
  },
  filterTreeNode: {
    type: Function
  },
  motion: me.any,
  switcherIcon: me.any,
  // Virtual List
  height: Number,
  itemHeight: Number,
  virtual: {
    type: Boolean,
    default: void 0
  },
  // direction for drag logic
  direction: {
    type: String
  },
  rootClassName: String,
  rootStyle: Object
});
var Dn = function(e, a) {
  var l = {};
  for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && a.indexOf(s) < 0 && (l[s] = e[s]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var c = 0, s = Object.getOwnPropertySymbols(e); c < s.length; c++)
    a.indexOf(s[c]) < 0 && Object.prototype.propertyIsEnumerable.call(e, s[c]) && (l[s[c]] = e[s[c]]);
  return l;
};
const rt = "open", st = "close", $n = "---", dt = Ne({
  compatConfig: {
    MODE: 3
  },
  name: "ATreeNode",
  inheritAttrs: !1,
  props: Dt,
  isTreeNode: 1,
  setup(e, a) {
    let {
      attrs: l,
      slots: s,
      expose: c
    } = a;
    Ae(!("slots" in e.data), `treeData slots is deprecated, please use ${Object.keys(e.data.slots || {}).map((t) => "`v-slot:" + t + "` ")}instead`);
    const g = O(!1), d = tt(), {
      expandedKeysSet: E,
      selectedKeysSet: $,
      loadedKeysSet: D,
      loadingKeysSet: N,
      checkedKeysSet: L,
      halfCheckedKeysSet: j
    } = Et(), {
      dragOverNodeKey: I,
      dropPosition: Q,
      keyEntities: f
    } = d.value, P = b(() => Fe(e.eventKey, {
      expandedKeysSet: E.value,
      selectedKeysSet: $.value,
      loadedKeysSet: D.value,
      loadingKeysSet: N.value,
      checkedKeysSet: L.value,
      halfCheckedKeysSet: j.value,
      dragOverNodeKey: I,
      dropPosition: Q,
      keyEntities: f
    })), T = de(() => P.value.expanded), H = de(() => P.value.selected), M = de(() => P.value.checked), W = de(() => P.value.loaded), A = de(() => P.value.loading), te = de(() => P.value.halfChecked), ne = de(() => P.value.dragOver), _ = de(() => P.value.dragOverGapTop), X = de(() => P.value.dragOverGapBottom), oe = de(() => P.value.pos), V = O(), ae = b(() => {
      const {
        eventKey: t
      } = e, {
        keyEntities: i
      } = d.value, {
        children: S
      } = i[t] || {};
      return !!(S || []).length;
    }), J = b(() => {
      const {
        isLeaf: t
      } = e, {
        loadData: i
      } = d.value, S = ae.value;
      return t === !1 ? !1 : t || !i && !S || i && W.value && !S;
    }), fe = b(() => J.value ? null : T.value ? rt : st), le = b(() => {
      const {
        disabled: t
      } = e, {
        disabled: i
      } = d.value;
      return !!(i || t);
    }), ke = b(() => {
      const {
        checkable: t
      } = e, {
        checkable: i
      } = d.value;
      return !i || t === !1 ? !1 : i;
    }), ie = b(() => {
      const {
        selectable: t
      } = e, {
        selectable: i
      } = d.value;
      return typeof t == "boolean" ? t : i;
    }), F = b(() => {
      const {
        data: t,
        active: i,
        checkable: S,
        disableCheckbox: R,
        disabled: z,
        selectable: G
      } = e;
      return k(k({
        active: i,
        checkable: S,
        disableCheckbox: R,
        disabled: z,
        selectable: G
      }, t), {
        dataRef: t,
        data: t,
        isLeaf: J.value,
        checked: M.value,
        expanded: T.value,
        loading: A.value,
        selected: H.value,
        halfChecked: te.value
      });
    }), ce = ln(), B = b(() => {
      const {
        eventKey: t
      } = e, {
        keyEntities: i
      } = d.value, {
        parent: S
      } = i[t] || {};
      return k(k({}, _e(k({}, e, P.value))), {
        parent: S
      });
    }), U = Kt({
      eventData: B,
      eventKey: b(() => e.eventKey),
      selectHandle: V,
      pos: oe,
      key: ce.vnode.key
    });
    c(U);
    const Z = (t) => {
      const {
        onNodeDoubleClick: i
      } = d.value;
      i(t, B.value);
    }, ue = (t) => {
      if (le.value) return;
      const {
        onNodeSelect: i
      } = d.value;
      t.preventDefault(), i(t, B.value);
    }, pe = (t) => {
      if (le.value) return;
      const {
        disableCheckbox: i
      } = e, {
        onNodeCheck: S
      } = d.value;
      if (!ke.value || i) return;
      t.preventDefault();
      const R = !M.value;
      S(t, B.value, R);
    }, Se = (t) => {
      const {
        onNodeClick: i
      } = d.value;
      i(t, B.value), ie.value ? ue(t) : pe(t);
    }, we = (t) => {
      const {
        onNodeMouseEnter: i
      } = d.value;
      i(t, B.value);
    }, Be = (t) => {
      const {
        onNodeMouseLeave: i
      } = d.value;
      i(t, B.value);
    }, Re = (t) => {
      const {
        onNodeContextMenu: i
      } = d.value;
      i(t, B.value);
    }, je = (t) => {
      const {
        onNodeDragStart: i
      } = d.value;
      t.stopPropagation(), g.value = !0, i(t, U);
      try {
        t.dataTransfer.setData("text/plain", "");
      } catch (S) {
      }
    }, He = (t) => {
      const {
        onNodeDragEnter: i
      } = d.value;
      t.preventDefault(), t.stopPropagation(), i(t, U);
    }, Ve = (t) => {
      const {
        onNodeDragOver: i
      } = d.value;
      t.preventDefault(), t.stopPropagation(), i(t, U);
    }, Oe = (t) => {
      const {
        onNodeDragLeave: i
      } = d.value;
      t.stopPropagation(), i(t, U);
    }, ze = (t) => {
      const {
        onNodeDragEnd: i
      } = d.value;
      t.stopPropagation(), g.value = !1, i(t, U);
    }, Ge = (t) => {
      const {
        onNodeDrop: i
      } = d.value;
      t.preventDefault(), t.stopPropagation(), g.value = !1, i(t, U);
    }, Pe = (t) => {
      const {
        onNodeExpand: i
      } = d.value;
      A.value || i(t, B.value);
    }, Te = () => {
      const {
        data: t
      } = e, {
        draggable: i
      } = d.value;
      return !!(i && (!i.nodeDraggable || i.nodeDraggable(t)));
    }, Ie = () => {
      const {
        draggable: t,
        prefixCls: i
      } = d.value;
      return t && (t != null && t.icon) ? K("span", {
        class: `${i}-draggable-icon`
      }, [t.icon]) : null;
    }, We = () => {
      var t, i, S;
      const {
        switcherIcon: R = s.switcherIcon || ((t = d.value.slots) === null || t === void 0 ? void 0 : t[(S = (i = e.data) === null || i === void 0 ? void 0 : i.slots) === null || S === void 0 ? void 0 : S.switcherIcon])
      } = e, {
        switcherIcon: z
      } = d.value, G = R || z;
      return typeof G == "function" ? G(F.value) : G;
    }, Le = () => {
      const {
        loadData: t,
        onNodeLoad: i
      } = d.value;
      A.value || t && T.value && !J.value && !ae.value && !W.value && i(B.value);
    };
    xt(() => {
      Le();
    }), rn(() => {
      Le();
    });
    const Xe = () => {
      const {
        prefixCls: t
      } = d.value, i = We();
      if (J.value)
        return i !== !1 ? K("span", {
          class: he(`${t}-switcher`, `${t}-switcher-noop`)
        }, [i]) : null;
      const S = he(`${t}-switcher`, `${t}-switcher_${T.value ? rt : st}`);
      return i !== !1 ? K("span", {
        onClick: Pe,
        class: S
      }, [i]) : null;
    }, Ue = () => {
      var t, i;
      const {
        disableCheckbox: S
      } = e, {
        prefixCls: R
      } = d.value, z = le.value;
      return ke.value ? K("span", {
        class: he(`${R}-checkbox`, M.value && `${R}-checkbox-checked`, !M.value && te.value && `${R}-checkbox-indeterminate`, (z || S) && `${R}-checkbox-disabled`),
        onClick: pe
      }, [(i = (t = d.value).customCheckable) === null || i === void 0 ? void 0 : i.call(t)]) : null;
    }, Me = () => {
      const {
        prefixCls: t
      } = d.value;
      return K("span", {
        class: he(`${t}-iconEle`, `${t}-icon__${fe.value || "docu"}`, A.value && `${t}-icon_loading`)
      }, null);
    }, be = () => {
      const {
        disabled: t,
        eventKey: i
      } = e, {
        draggable: S,
        dropLevelOffset: R,
        dropPosition: z,
        prefixCls: G,
        indent: n,
        dropIndicatorRender: o,
        dragOverNodeKey: r,
        direction: v
      } = d.value;
      return !t && S !== !1 && r === i ? o({
        dropPosition: z,
        dropLevelOffset: R,
        indent: n,
        prefixCls: G,
        direction: v
      }) : null;
    }, Ye = () => {
      var t, i, S, R, z, G;
      const {
        // title = slots.title ||
        //   context.value.slots?.[props.data?.slots?.title] ||
        //   context.value.slots?.title,
        // selected,
        icon: n = s.icon,
        // loading,
        data: o
      } = e, r = s.title || ((t = d.value.slots) === null || t === void 0 ? void 0 : t[(S = (i = e.data) === null || i === void 0 ? void 0 : i.slots) === null || S === void 0 ? void 0 : S.title]) || ((R = d.value.slots) === null || R === void 0 ? void 0 : R.title) || e.title, {
        prefixCls: v,
        showIcon: h,
        icon: y,
        loadData: u
        // slots: contextSlots,
      } = d.value, x = le.value, w = `${v}-node-content-wrapper`;
      let p;
      if (h) {
        const Y = n || ((z = d.value.slots) === null || z === void 0 ? void 0 : z[(G = o == null ? void 0 : o.slots) === null || G === void 0 ? void 0 : G.icon]) || y;
        p = Y ? K("span", {
          class: he(`${v}-iconEle`, `${v}-icon__customize`)
        }, [typeof Y == "function" ? Y(F.value) : Y]) : Me();
      } else u && A.value && (p = Me());
      let m;
      typeof r == "function" ? m = r(F.value) : m = r, m = m === void 0 ? $n : m;
      const C = K("span", {
        class: `${v}-title`
      }, [m]);
      return K("span", {
        ref: V,
        title: typeof r == "string" ? r : "",
        class: he(`${w}`, `${w}-${fe.value || "normal"}`, !x && (H.value || g.value) && `${v}-node-selected`),
        onMouseenter: we,
        onMouseleave: Be,
        onContextmenu: Re,
        onClick: Se,
        onDblclick: Z
      }, [p, C, be()]);
    };
    return () => {
      const t = k(k({}, e), l), {
        eventKey: i,
        isLeaf: S,
        isStart: R,
        isEnd: z,
        domRef: G,
        active: n,
        data: o,
        onMousemove: r,
        selectable: v
      } = t, h = Dn(t, ["eventKey", "isLeaf", "isStart", "isEnd", "domRef", "active", "data", "onMousemove", "selectable"]), {
        prefixCls: y,
        filterTreeNode: u,
        keyEntities: x,
        dropContainerKey: w,
        dropTargetKey: p,
        draggingNodeKey: m
      } = d.value, C = le.value, Y = pt(h, {
        aria: !0,
        data: !0
      }), {
        level: re
      } = x[i] || {}, se = z[z.length - 1], q = Te(), ye = !C && q, Ee = m === i, qe = v !== void 0 ? {
        "aria-selected": !!v
      } : void 0;
      return K("div", ee(ee({
        ref: G,
        class: he(l.class, `${y}-treenode`, {
          [`${y}-treenode-disabled`]: C,
          [`${y}-treenode-switcher-${T.value ? "open" : "close"}`]: !S,
          [`${y}-treenode-checkbox-checked`]: M.value,
          [`${y}-treenode-checkbox-indeterminate`]: te.value,
          [`${y}-treenode-selected`]: H.value,
          [`${y}-treenode-loading`]: A.value,
          [`${y}-treenode-active`]: n,
          [`${y}-treenode-leaf-last`]: se,
          [`${y}-treenode-draggable`]: ye,
          dragging: Ee,
          "drop-target": p === i,
          "drop-container": w === i,
          "drag-over": !C && ne.value,
          "drag-over-gap-top": !C && _.value,
          "drag-over-gap-bottom": !C && X.value,
          "filter-node": u && u(B.value)
        }),
        style: l.style,
        draggable: ye,
        "aria-grabbed": Ee,
        onDragstart: ye ? je : void 0,
        onDragenter: q ? He : void 0,
        onDragover: q ? Ve : void 0,
        onDragleave: q ? Oe : void 0,
        onDrop: q ? Ge : void 0,
        onDragend: q ? ze : void 0,
        onMousemove: r
      }, qe), Y), [K(Cn, {
        prefixCls: y,
        level: re,
        isStart: R,
        isEnd: z
      }, null), Ie(), Xe(), Ue(), Ye()]);
    };
  }
});
var ct = function(e, a) {
  var l = {};
  for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && a.indexOf(s) < 0 && (l[s] = e[s]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var c = 0, s = Object.getOwnPropertySymbols(e); c < s.length; c++)
    a.indexOf(s[c]) < 0 && Object.prototype.propertyIsEnumerable.call(e, s[c]) && (l[s[c]] = e[s[c]]);
  return l;
};
const Nn = Ne({
  compatConfig: {
    MODE: 3
  },
  name: "MotionTreeNode",
  inheritAttrs: !1,
  props: k(k({}, Dt), {
    active: Boolean,
    motion: Object,
    motionNodes: {
      type: Array
    },
    onMotionStart: Function,
    onMotionEnd: Function,
    motionType: String
  }),
  setup(e, a) {
    let {
      attrs: l,
      slots: s
    } = a;
    const c = O(!0), g = tt(), d = O(!1), E = b(() => e.motion ? e.motion : Vt()), $ = (D, N) => {
      var L, j, I, Q;
      N === "appear" ? (j = (L = E.value) === null || L === void 0 ? void 0 : L.onAfterEnter) === null || j === void 0 || j.call(L, D) : N === "leave" && ((Q = (I = E.value) === null || I === void 0 ? void 0 : I.onAfterLeave) === null || Q === void 0 || Q.call(I, D)), d.value || e.onMotionEnd(), d.value = !0;
    };
    return Ke(() => e.motionNodes, () => {
      e.motionNodes && e.motionType === "hide" && c.value && kt(() => {
        c.value = !1;
      });
    }, {
      immediate: !0,
      flush: "post"
    }), xt(() => {
      e.motionNodes && e.onMotionStart();
    }), sn(() => {
      e.motionNodes && $();
    }), () => {
      const {
        motion: D,
        motionNodes: N,
        motionType: L,
        active: j,
        eventKey: I
      } = e, Q = ct(e, ["motion", "motionNodes", "motionType", "active", "eventKey"]);
      return N ? K(dn, ee(ee({}, E.value), {}, {
        appear: L === "show",
        onAfterAppear: (f) => $(f, "appear"),
        onAfterLeave: (f) => $(f, "leave")
      }), {
        default: () => [cn(K("div", {
          class: `${g.value.prefixCls}-treenode-motion`
        }, [N.map((f) => {
          const P = ct(f.data, []), {
            title: T,
            key: H,
            isStart: M,
            isEnd: W
          } = f;
          return delete P.children, K(dt, ee(ee({}, P), {}, {
            title: T,
            active: j,
            data: f.data,
            key: H,
            eventKey: H,
            isStart: M,
            isEnd: W
          }), s);
        })]), [[un, c.value]])]
      }) : K(dt, ee(ee({
        class: l.class,
        style: l.style
      }, Q), {}, {
        active: j,
        eventKey: I
      }), s);
    };
  }
});
function On() {
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
  const l = e.length, s = a.length;
  if (Math.abs(l - s) !== 1)
    return {
      add: !1,
      key: null
    };
  function c(g, d) {
    const E = /* @__PURE__ */ new Map();
    g.forEach((D) => {
      E.set(D, !0);
    });
    const $ = d.filter((D) => !E.has(D));
    return $.length === 1 ? $[0] : null;
  }
  return l < s ? {
    add: !0,
    key: c(e, a)
  } : {
    add: !1,
    key: c(a, e)
  };
}
function ut(e, a, l) {
  const s = e.findIndex((d) => d.key === l), c = e[s + 1], g = a.findIndex((d) => d.key === l);
  if (c) {
    const d = a.findIndex((E) => E.key === c.key);
    return a.slice(g + 1, d);
  }
  return a.slice(g + 1);
}
var vt = function(e, a) {
  var l = {};
  for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && a.indexOf(s) < 0 && (l[s] = e[s]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var c = 0, s = Object.getOwnPropertySymbols(e); c < s.length; c++)
    a.indexOf(s[c]) < 0 && Object.prototype.propertyIsEnumerable.call(e, s[c]) && (l[s[c]] = e[s[c]]);
  return l;
};
const ft = {
  width: 0,
  height: 0,
  display: "flex",
  overflow: "hidden",
  opacity: 0,
  border: 0,
  padding: 0,
  margin: 0
}, Pn = () => {
}, xe = `RC_TREE_MOTION_${Math.random()}`, et = {
  key: xe
}, $t = {
  key: xe,
  level: 0,
  index: 0,
  pos: "0",
  node: et,
  nodes: [et]
}, yt = {
  parent: null,
  children: [],
  pos: $t.pos,
  data: et,
  title: null,
  key: xe,
  /** Hold empty list here since we do not use it */
  isStart: [],
  isEnd: []
};
function gt(e, a, l, s) {
  return a === !1 || !l ? e : e.slice(0, Math.ceil(l / s) + 1);
}
function ht(e) {
  const {
    key: a,
    pos: l
  } = e;
  return St(a, l);
}
function Tn(e) {
  let a = String(e.key), l = e;
  for (; l.parent; )
    l = l.parent, a = `${l.key} > ${a}`;
  return a;
}
const In = Ne({
  compatConfig: {
    MODE: 3
  },
  name: "NodeList",
  inheritAttrs: !1,
  props: wn,
  setup(e, a) {
    let {
      expose: l,
      attrs: s
    } = a;
    const c = Je(), g = Je(), {
      expandedKeys: d,
      flattenNodes: E
    } = Et();
    l({
      scrollTo: (f) => {
        c.value.scrollTo(f);
      },
      getIndentWidth: () => g.value.offsetWidth
    });
    const $ = O(E.value), D = O([]), N = Je(null);
    function L() {
      $.value = E.value, D.value = [], N.value = null, e.onListChangeEnd();
    }
    const j = tt();
    Ke([() => d.value.slice(), E], (f, P) => {
      let [T, H] = f, [M, W] = P;
      const A = On(M, T);
      if (A.key !== null) {
        const {
          virtual: te,
          height: ne,
          itemHeight: _
        } = e;
        if (A.add) {
          const X = W.findIndex((ae) => {
            let {
              key: J
            } = ae;
            return J === A.key;
          }), oe = gt(ut(W, H, A.key), te, ne, _), V = W.slice();
          V.splice(X + 1, 0, yt), $.value = V, D.value = oe, N.value = "show";
        } else {
          const X = H.findIndex((ae) => {
            let {
              key: J
            } = ae;
            return J === A.key;
          }), oe = gt(ut(H, W, A.key), te, ne, _), V = H.slice();
          V.splice(X + 1, 0, yt), $.value = V, D.value = oe, N.value = "hide";
        }
      } else W !== H && ($.value = H);
    }), Ke(() => j.value.dragging, (f) => {
      f || L();
    });
    const I = b(() => e.motion === void 0 ? $.value : E.value), Q = () => {
      e.onActiveChange(null);
    };
    return () => {
      const f = k(k({}, e), s), {
        prefixCls: P,
        selectable: T,
        checkable: H,
        disabled: M,
        motion: W,
        height: A,
        itemHeight: te,
        virtual: ne,
        focusable: _,
        activeItem: X,
        focused: oe,
        tabindex: V,
        onKeydown: ae,
        onFocus: J,
        onBlur: fe,
        onListChangeStart: le,
        onListChangeEnd: ke
      } = f, ie = vt(f, ["prefixCls", "selectable", "checkable", "disabled", "motion", "height", "itemHeight", "virtual", "focusable", "activeItem", "focused", "tabindex", "onKeydown", "onFocus", "onBlur", "onListChangeStart", "onListChangeEnd"]);
      return K(vn, null, [oe && X && K("span", {
        style: ft,
        "aria-live": "assertive"
      }, [Tn(X)]), K("div", null, [K("input", {
        style: ft,
        disabled: _ === !1 || M,
        tabindex: _ !== !1 ? V : null,
        onKeydown: ae,
        onFocus: J,
        onBlur: fe,
        value: "",
        onChange: Pn,
        "aria-label": "for screen reader"
      }, null)]), K("div", {
        class: `${P}-treenode`,
        "aria-hidden": !0,
        style: {
          position: "absolute",
          pointerEvents: "none",
          visibility: "hidden",
          height: 0,
          overflow: "hidden"
        }
      }, [K("div", {
        class: `${P}-indent`
      }, [K("div", {
        ref: g,
        class: `${P}-indent-unit`
      }, null)])]), K(zt, ee(ee({}, Gt(ie, ["onActiveChange"])), {}, {
        data: I.value,
        itemKey: ht,
        height: A,
        fullHeight: !1,
        virtual: ne,
        itemHeight: te,
        prefixCls: `${P}-list`,
        ref: c,
        onVisibleChange: (F, ce) => {
          const B = new Set(F);
          ce.filter((Z) => !B.has(Z)).some((Z) => ht(Z) === xe) && L();
        }
      }), {
        default: (F) => {
          const {
            pos: ce
          } = F, B = vt(F.data, []), {
            title: U,
            key: Z,
            isStart: ue,
            isEnd: pe
          } = F, Se = St(Z, ce);
          return delete B.key, delete B.children, K(Nn, ee(ee({}, B), {}, {
            eventKey: Se,
            title: U,
            active: !!X && Z === X.key,
            data: F.data,
            isStart: ue,
            isEnd: pe,
            motion: W,
            motionNodes: Z === xe ? D.value : null,
            motionType: N.value,
            onMotionStart: le,
            onMotionEnd: L,
            onMousemove: Q
          }), null);
        }
      })]);
    };
  }
});
function Ln(e) {
  let {
    dropPosition: a,
    dropLevelOffset: l,
    indent: s
  } = e;
  const c = {
    pointerEvents: "none",
    position: "absolute",
    right: 0,
    backgroundColor: "red",
    height: "2px"
  };
  switch (a) {
    case -1:
      c.top = 0, c.left = `${-l * s}px`;
      break;
    case 1:
      c.bottom = 0, c.left = `${-l * s}px`;
      break;
    case 0:
      c.bottom = 0, c.left = `${s}`;
      break;
  }
  return K("div", {
    style: c
  }, null);
}
const Mn = 10, Gn = Ne({
  compatConfig: {
    MODE: 3
  },
  name: "Tree",
  inheritAttrs: !1,
  props: Wt(En(), {
    prefixCls: "vc-tree",
    showLine: !1,
    showIcon: !0,
    selectable: !0,
    multiple: !1,
    checkable: !1,
    disabled: !1,
    checkStrictly: !1,
    draggable: !1,
    expandAction: !1,
    defaultExpandParent: !0,
    autoExpandParent: !1,
    defaultExpandAll: !1,
    defaultExpandedKeys: [],
    defaultCheckedKeys: [],
    defaultSelectedKeys: [],
    dropIndicatorRender: Ln,
    allowDrop: () => !0
  }),
  setup(e, a) {
    let {
      attrs: l,
      slots: s,
      expose: c
    } = a;
    const g = O(!1);
    let d = {};
    const E = O(), $ = O([]), D = O([]), N = O([]), L = O([]), j = O([]), I = O([]), Q = {}, f = Kt({
      draggingNodeKey: null,
      dragChildrenKeys: [],
      // dropTargetKey is the key of abstract-drop-node
      // the abstract-drop-node is the real drop node when drag and drop
      // not the DOM drag over node
      dropTargetKey: null,
      dropPosition: null,
      dropContainerKey: null,
      dropLevelOffset: null,
      dropTargetPos: null,
      dropAllowed: !0,
      // the abstract-drag-over-node
      // if mouse is on the bottom of top dom node or no the top of the bottom dom node
      // abstract-drag-over-node is the top node
      dragOverNodeKey: null
    }), P = O([]);
    Ke([() => e.treeData, () => e.children], () => {
      P.value = e.treeData !== void 0 ? e.treeData.slice() : gn(ot(e.children));
    }, {
      immediate: !0,
      deep: !0
    });
    const T = O({}), H = O(!1), M = O(null), W = O(!1), A = b(() => hn(e.fieldNames)), te = O();
    let ne = null, _ = null, X = null;
    const oe = b(() => ({
      expandedKeysSet: V.value,
      selectedKeysSet: ae.value,
      loadedKeysSet: J.value,
      loadingKeysSet: fe.value,
      checkedKeysSet: le.value,
      halfCheckedKeysSet: ke.value,
      dragOverNodeKey: f.dragOverNodeKey,
      dropPosition: f.dropPosition,
      keyEntities: T.value
    })), V = b(() => new Set(I.value)), ae = b(() => new Set($.value)), J = b(() => new Set(L.value)), fe = b(() => new Set(j.value)), le = b(() => new Set(D.value)), ke = b(() => new Set(N.value));
    $e(() => {
      if (P.value) {
        const n = pn(P.value, {
          fieldNames: A.value
        });
        T.value = k({
          [xe]: $t
        }, n.keyEntities);
      }
    });
    let ie = !1;
    Ke(
      [() => e.expandedKeys, () => e.autoExpandParent, T],
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
      (n, o) => {
        let [r, v] = n, [h, y] = o, u = I.value;
        if (e.expandedKeys !== void 0 || ie && v !== y)
          u = e.autoExpandParent || !ie && e.defaultExpandParent ? at(e.expandedKeys, T.value) : e.expandedKeys;
        else if (!ie && e.defaultExpandAll) {
          const x = k({}, T.value);
          delete x[xe], u = Object.keys(x).map((w) => x[w].key);
        } else !ie && e.defaultExpandedKeys && (u = e.autoExpandParent || e.defaultExpandParent ? at(e.defaultExpandedKeys, T.value) : e.defaultExpandedKeys);
        u && (I.value = u), ie = !0;
      },
      {
        immediate: !0
      }
    );
    const F = O([]);
    $e(() => {
      F.value = bn(P.value, I.value, A.value);
    }), $e(() => {
      e.selectable && (e.selectedKeys !== void 0 ? $.value = lt(e.selectedKeys, e) : !ie && e.defaultSelectedKeys && ($.value = lt(e.defaultSelectedKeys, e)));
    });
    const {
      maxLevel: ce,
      levelEntities: B
    } = mn(T);
    $e(() => {
      if (e.checkable) {
        let n;
        if (e.checkedKeys !== void 0 ? n = Qe(e.checkedKeys) || {} : !ie && e.defaultCheckedKeys ? n = Qe(e.defaultCheckedKeys) || {} : P.value && (n = Qe(e.checkedKeys) || {
          checkedKeys: D.value,
          halfCheckedKeys: N.value
        }), n) {
          let {
            checkedKeys: o = [],
            halfCheckedKeys: r = []
          } = n;
          e.checkStrictly || ({
            checkedKeys: o,
            halfCheckedKeys: r
          } = Ze(o, !0, T.value, ce.value, B.value)), D.value = o, N.value = r;
        }
      }
    }), $e(() => {
      e.loadedKeys && (L.value = e.loadedKeys);
    });
    const U = () => {
      k(f, {
        dragOverNodeKey: null,
        dropPosition: null,
        dropLevelOffset: null,
        dropTargetKey: null,
        dropContainerKey: null,
        dropTargetPos: null,
        dropAllowed: !1
      });
    }, Z = (n) => {
      te.value.scrollTo(n);
    };
    Ke(() => e.activeKey, () => {
      e.activeKey !== void 0 && (M.value = e.activeKey);
    }, {
      immediate: !0
    }), Ke(M, (n) => {
      kt(() => {
        n !== null && Z({
          key: n
        });
      });
    }, {
      immediate: !0,
      flush: "post"
    });
    const ue = (n) => {
      e.expandedKeys === void 0 && (I.value = n);
    }, pe = () => {
      f.draggingNodeKey !== null && k(f, {
        draggingNodeKey: null,
        dropPosition: null,
        dropContainerKey: null,
        dropTargetKey: null,
        dropLevelOffset: null,
        dropAllowed: !0,
        dragOverNodeKey: null
      }), ne = null, X = null;
    }, Se = (n, o) => {
      const {
        onDragend: r
      } = e;
      f.dragOverNodeKey = null, pe(), r == null || r({
        event: n,
        node: o.eventData
      }), _ = null;
    }, we = (n) => {
      Se(n, null), window.removeEventListener("dragend", we);
    }, Be = (n, o) => {
      const {
        onDragstart: r
      } = e, {
        eventKey: v,
        eventData: h
      } = o;
      _ = o, ne = {
        x: n.clientX,
        y: n.clientY
      };
      const y = ve(I.value, v);
      f.draggingNodeKey = v, f.dragChildrenKeys = Kn(v, T.value), E.value = te.value.getIndentWidth(), ue(y), window.addEventListener("dragend", we), r && r({
        event: n,
        node: h
      });
    }, Re = (n, o) => {
      const {
        onDragenter: r,
        onExpand: v,
        allowDrop: h,
        direction: y
      } = e, {
        pos: u,
        eventKey: x
      } = o;
      if (X !== x && (X = x), !_) {
        U();
        return;
      }
      const {
        dropPosition: w,
        dropLevelOffset: p,
        dropTargetKey: m,
        dropContainerKey: C,
        dropTargetPos: Y,
        dropAllowed: re,
        dragOverNodeKey: se
      } = it(n, _, o, E.value, ne, h, F.value, T.value, V.value, y);
      if (
        // don't allow drop inside its children
        f.dragChildrenKeys.indexOf(m) !== -1 || // don't allow drop when drop is not allowed caculated by calcDropPosition
        !re
      ) {
        U();
        return;
      }
      if (d || (d = {}), Object.keys(d).forEach((q) => {
        clearTimeout(d[q]);
      }), _.eventKey !== o.eventKey && (d[u] = window.setTimeout(() => {
        if (f.draggingNodeKey === null) return;
        let q = I.value.slice();
        const ye = T.value[o.eventKey];
        ye && (ye.children || []).length && (q = ge(I.value, o.eventKey)), ue(q), v && v(q, {
          node: o.eventData,
          expanded: !0,
          nativeEvent: n
        });
      }, 800)), _.eventKey === m && p === 0) {
        U();
        return;
      }
      k(f, {
        dragOverNodeKey: se,
        dropPosition: w,
        dropLevelOffset: p,
        dropTargetKey: m,
        dropContainerKey: C,
        dropTargetPos: Y,
        dropAllowed: re
      }), r && r({
        event: n,
        node: o.eventData,
        expandedKeys: I.value
      });
    }, je = (n, o) => {
      const {
        onDragover: r,
        allowDrop: v,
        direction: h
      } = e;
      if (!_)
        return;
      const {
        dropPosition: y,
        dropLevelOffset: u,
        dropTargetKey: x,
        dropContainerKey: w,
        dropAllowed: p,
        dropTargetPos: m,
        dragOverNodeKey: C
      } = it(n, _, o, E.value, ne, v, F.value, T.value, V.value, h);
      f.dragChildrenKeys.indexOf(x) !== -1 || !p || (_.eventKey === x && u === 0 ? f.dropPosition === null && f.dropLevelOffset === null && f.dropTargetKey === null && f.dropContainerKey === null && f.dropTargetPos === null && f.dropAllowed === !1 && f.dragOverNodeKey === null || U() : y === f.dropPosition && u === f.dropLevelOffset && x === f.dropTargetKey && w === f.dropContainerKey && m === f.dropTargetPos && p === f.dropAllowed && C === f.dragOverNodeKey || k(f, {
        dropPosition: y,
        dropLevelOffset: u,
        dropTargetKey: x,
        dropContainerKey: w,
        dropTargetPos: m,
        dropAllowed: p,
        dragOverNodeKey: C
      }), r && r({
        event: n,
        node: o.eventData
      }));
    }, He = (n, o) => {
      X === o.eventKey && !n.currentTarget.contains(n.relatedTarget) && (U(), X = null);
      const {
        onDragleave: r
      } = e;
      r && r({
        event: n,
        node: o.eventData
      });
    }, Ve = function(n, o) {
      let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
      var v;
      const {
        dragChildrenKeys: h,
        dropPosition: y,
        dropTargetKey: u,
        dropTargetPos: x,
        dropAllowed: w
      } = f;
      if (!w) return;
      const {
        onDrop: p
      } = e;
      if (f.dragOverNodeKey = null, pe(), u === null) return;
      const m = k(k({}, Fe(u, ot(oe.value))), {
        active: ((v = S.value) === null || v === void 0 ? void 0 : v.key) === u,
        data: T.value[u].node
      }), C = h.indexOf(u) !== -1;
      Ae(!C, "Can not drop to dragNode's children node. Maybe this is a bug of ant-design-vue. Please report an issue.");
      const Y = xn(x), re = {
        event: n,
        node: _e(m),
        dragNode: _ ? _.eventData : null,
        dragNodesKeys: [_.eventKey].concat(h),
        dropToGap: y !== 0,
        dropPosition: y + Number(Y[Y.length - 1])
      };
      r || p == null || p(re), _ = null;
    }, Oe = (n, o) => {
      const {
        expanded: r,
        key: v
      } = o, h = F.value.filter((u) => u.key === v)[0], y = _e(k(k({}, Fe(v, oe.value)), {
        data: h.data
      }));
      ue(r ? ve(I.value, v) : ge(I.value, v)), be(n, y);
    }, ze = (n, o) => {
      const {
        onClick: r,
        expandAction: v
      } = e;
      v === "click" && Oe(n, o), r && r(n, o);
    }, Ge = (n, o) => {
      const {
        onDblclick: r,
        expandAction: v
      } = e;
      (v === "doubleclick" || v === "dblclick") && Oe(n, o), r && r(n, o);
    }, Pe = (n, o) => {
      let r = $.value;
      const {
        onSelect: v,
        multiple: h
      } = e, {
        selected: y
      } = o, u = o[A.value.key], x = !y;
      x ? h ? r = ge(r, u) : r = [u] : r = ve(r, u);
      const w = T.value, p = r.map((m) => {
        const C = w[m];
        return C ? C.node : null;
      }).filter((m) => m);
      e.selectedKeys === void 0 && ($.value = r), v && v(r, {
        event: "select",
        selected: x,
        node: o,
        selectedNodes: p,
        nativeEvent: n
      });
    }, Te = (n, o, r) => {
      const {
        checkStrictly: v,
        onCheck: h
      } = e, y = o[A.value.key];
      let u;
      const x = {
        event: "check",
        node: o,
        checked: r,
        nativeEvent: n
      }, w = T.value;
      if (v) {
        const p = r ? ge(D.value, y) : ve(D.value, y), m = ve(N.value, y);
        u = {
          checked: p,
          halfChecked: m
        }, x.checkedNodes = p.map((C) => w[C]).filter((C) => C).map((C) => C.node), e.checkedKeys === void 0 && (D.value = p);
      } else {
        let {
          checkedKeys: p,
          halfCheckedKeys: m
        } = Ze([...D.value, y], !0, w, ce.value, B.value);
        if (!r) {
          const C = new Set(p);
          C.delete(y), {
            checkedKeys: p,
            halfCheckedKeys: m
          } = Ze(Array.from(C), {
            checked: !1,
            halfCheckedKeys: m
          }, w, ce.value, B.value);
        }
        u = p, x.checkedNodes = [], x.checkedNodesPositions = [], x.halfCheckedKeys = m, p.forEach((C) => {
          const Y = w[C];
          if (!Y) return;
          const {
            node: re,
            pos: se
          } = Y;
          x.checkedNodes.push(re), x.checkedNodesPositions.push({
            node: re,
            pos: se
          });
        }), e.checkedKeys === void 0 && (D.value = p, N.value = m);
      }
      h && h(u, x);
    }, Ie = (n) => {
      const o = n[A.value.key], r = new Promise((v, h) => {
        const {
          loadData: y,
          onLoad: u
        } = e;
        if (!y || J.value.has(o) || fe.value.has(o))
          return null;
        y(n).then(() => {
          const w = ge(L.value, o), p = ve(j.value, o);
          u && u(w, {
            event: "load",
            node: n
          }), e.loadedKeys === void 0 && (L.value = w), j.value = p, v();
        }).catch((w) => {
          const p = ve(j.value, o);
          if (j.value = p, Q[o] = (Q[o] || 0) + 1, Q[o] >= Mn) {
            Ae(!1, "Retry for `loadData` many times but still failed. No more retry.");
            const m = ge(L.value, o);
            e.loadedKeys === void 0 && (L.value = m), v();
          }
          h(w);
        }), j.value = ge(j.value, o);
      });
      return r.catch(() => {
      }), r;
    }, We = (n, o) => {
      const {
        onMouseenter: r
      } = e;
      r && r({
        event: n,
        node: o
      });
    }, Le = (n, o) => {
      const {
        onMouseleave: r
      } = e;
      r && r({
        event: n,
        node: o
      });
    }, Xe = (n, o) => {
      const {
        onRightClick: r
      } = e;
      r && (n.preventDefault(), r({
        event: n,
        node: o
      }));
    }, Ue = (n) => {
      const {
        onFocus: o
      } = e;
      H.value = !0, o && o(n);
    }, Me = (n) => {
      const {
        onBlur: o
      } = e;
      H.value = !1, i(null), o && o(n);
    }, be = (n, o) => {
      let r = I.value;
      const {
        onExpand: v,
        loadData: h
      } = e, {
        expanded: y
      } = o, u = o[A.value.key];
      if (W.value)
        return;
      const x = r.indexOf(u), w = !y;
      if (Ae(y && x !== -1 || !y && x === -1, "Expand state not sync with index check"), w ? r = ge(r, u) : r = ve(r, u), ue(r), v && v(r, {
        node: o,
        expanded: w,
        nativeEvent: n
      }), w && h) {
        const p = Ie(o);
        p && p.then(() => {
        }).catch((m) => {
          const C = ve(I.value, u);
          ue(C), Promise.reject(m);
        });
      }
    }, Ye = () => {
      W.value = !0;
    }, t = () => {
      setTimeout(() => {
        W.value = !1;
      });
    }, i = (n) => {
      const {
        onActiveChange: o
      } = e;
      M.value !== n && (e.activeKey !== void 0 && (M.value = n), n !== null && Z({
        key: n
      }), o && o(n));
    }, S = b(() => M.value === null ? null : F.value.find((n) => {
      let {
        key: o
      } = n;
      return o === M.value;
    }) || null), R = (n) => {
      let o = F.value.findIndex((v) => {
        let {
          key: h
        } = v;
        return h === M.value;
      });
      o === -1 && n < 0 && (o = F.value.length), o = (o + n + F.value.length) % F.value.length;
      const r = F.value[o];
      if (r) {
        const {
          key: v
        } = r;
        i(v);
      } else
        i(null);
    }, z = b(() => _e(k(k({}, Fe(M.value, oe.value)), {
      data: S.value.data,
      active: !0
    }))), G = (n) => {
      const {
        onKeydown: o,
        checkable: r,
        selectable: v
      } = e;
      switch (n.which) {
        case Ce.UP: {
          R(-1), n.preventDefault();
          break;
        }
        case Ce.DOWN: {
          R(1), n.preventDefault();
          break;
        }
      }
      const h = S.value;
      if (h && h.data) {
        const y = h.data.isLeaf === !1 || !!(h.data.children || []).length, u = z.value;
        switch (n.which) {
          case Ce.LEFT: {
            y && V.value.has(M.value) ? be({}, u) : h.parent && i(h.parent.key), n.preventDefault();
            break;
          }
          case Ce.RIGHT: {
            y && !V.value.has(M.value) ? be({}, u) : h.children && h.children.length && i(h.children[0].key), n.preventDefault();
            break;
          }
          case Ce.ENTER:
          case Ce.SPACE: {
            r && !u.disabled && u.checkable !== !1 && !u.disableCheckbox ? Te({}, u, !le.value.has(M.value)) : !r && v && !u.disabled && u.selectable !== !1 && Pe({}, u);
            break;
          }
        }
      }
      o && o(n);
    };
    return c({
      onNodeExpand: be,
      scrollTo: Z,
      onKeydown: G,
      selectedKeys: b(() => $.value),
      checkedKeys: b(() => D.value),
      halfCheckedKeys: b(() => N.value),
      loadedKeys: b(() => L.value),
      loadingKeys: b(() => j.value),
      expandedKeys: b(() => I.value)
    }), fn(() => {
      window.removeEventListener("dragend", we), g.value = !0;
    }), Sn({
      expandedKeys: I,
      selectedKeys: $,
      loadedKeys: L,
      loadingKeys: j,
      checkedKeys: D,
      halfCheckedKeys: N,
      expandedKeysSet: V,
      selectedKeysSet: ae,
      loadedKeysSet: J,
      loadingKeysSet: fe,
      checkedKeysSet: le,
      halfCheckedKeysSet: ke,
      flattenNodes: F
    }), () => {
      const {
        // focused,
        // flattenNodes,
        // keyEntities,
        draggingNodeKey: n,
        // activeKey,
        dropLevelOffset: o,
        dropContainerKey: r,
        dropTargetKey: v,
        dropPosition: h,
        dragOverNodeKey: y
        // indent,
      } = f, {
        prefixCls: u,
        showLine: x,
        focusable: w,
        tabindex: p = 0,
        selectable: m,
        showIcon: C,
        icon: Y = s.icon,
        switcherIcon: re,
        draggable: se,
        checkable: q,
        checkStrictly: ye,
        disabled: Ee,
        motion: qe,
        loadData: Nt,
        filterTreeNode: Ot,
        height: Pt,
        itemHeight: Tt,
        virtual: It,
        dropIndicatorRender: Lt,
        onContextmenu: Mt,
        onScroll: At,
        direction: Ft,
        rootClassName: _t,
        rootStyle: Bt
      } = e, {
        class: Rt,
        style: jt
      } = l, Ht = pt(k(k({}, e), l), {
        aria: !0,
        data: !0
      });
      let De;
      return se ? typeof se == "object" ? De = se : typeof se == "function" ? De = {
        nodeDraggable: se
      } : De = {} : De = !1, K(kn, {
        value: {
          prefixCls: u,
          selectable: m,
          showIcon: C,
          icon: Y,
          switcherIcon: re,
          draggable: De,
          draggingNodeKey: n,
          checkable: q,
          customCheckable: s.checkable,
          checkStrictly: ye,
          disabled: Ee,
          keyEntities: T.value,
          dropLevelOffset: o,
          dropContainerKey: r,
          dropTargetKey: v,
          dropPosition: h,
          dragOverNodeKey: y,
          dragging: n !== null,
          indent: E.value,
          direction: Ft,
          dropIndicatorRender: Lt,
          loadData: Nt,
          filterTreeNode: Ot,
          onNodeClick: ze,
          onNodeDoubleClick: Ge,
          onNodeExpand: be,
          onNodeSelect: Pe,
          onNodeCheck: Te,
          onNodeLoad: Ie,
          onNodeMouseEnter: We,
          onNodeMouseLeave: Le,
          onNodeContextMenu: Xe,
          onNodeDragStart: Be,
          onNodeDragEnter: Re,
          onNodeDragOver: je,
          onNodeDragLeave: He,
          onNodeDragEnd: Se,
          onNodeDrop: Ve,
          slots: s
        }
      }, {
        default: () => [K("div", {
          role: "tree",
          class: he(u, Rt, _t, {
            [`${u}-show-line`]: x,
            [`${u}-focused`]: H.value,
            [`${u}-active-focused`]: M.value !== null
          }),
          style: Bt
        }, [K(In, ee({
          ref: te,
          prefixCls: u,
          style: jt,
          disabled: Ee,
          selectable: m,
          checkable: !!q,
          motion: qe,
          height: Pt,
          itemHeight: Tt,
          virtual: It,
          focusable: w,
          focused: H.value,
          tabindex: p,
          activeItem: S.value,
          onFocus: Ue,
          onBlur: Me,
          onKeydown: G,
          onActiveChange: i,
          onListChangeStart: Ye,
          onListChangeEnd: t,
          onContextmenu: Mt,
          onScroll: At
        }, Ht), null)])]
      });
    };
  }
});
function Wn(e, a, l, s, c) {
  const {
    isLeaf: g,
    expanded: d,
    loading: E
  } = l;
  let $ = a;
  if (E)
    return K(Xt, {
      class: `${e}-switcher-loading-icon`
    }, null);
  let D;
  c && typeof c == "object" && (D = c.showLeafIcon);
  let N = null;
  const L = `${e}-switcher-icon`;
  return g ? c ? D && s ? s(l) : (typeof c == "object" && !D ? N = K("span", {
    class: `${e}-switcher-leaf-line`
  }, null) : N = K(Ut, {
    class: `${e}-switcher-line-icon`
  }, null), N) : null : (N = K(Yt, {
    class: L
  }, null), c && (N = d ? K(qt, {
    class: `${e}-switcher-line-icon`
  }, null) : K(Jt, {
    class: `${e}-switcher-line-icon`
  }, null)), typeof a == "function" ? $ = a(k(k({}, l), {
    defaultIcon: N,
    switcherCls: L
  })) : Qt($) && ($ = yn($, {
    class: L
  })), $ || N);
}
const An = new an("ant-tree-node-fx-do-not-use", {
  "0%": {
    opacity: 0
  },
  "100%": {
    opacity: 1
  }
}), Fn = (e, a) => ({
  [`.${e}-switcher-icon`]: {
    display: "inline-block",
    fontSize: 10,
    verticalAlign: "baseline",
    svg: {
      transition: `transform ${a.motionDurationSlow}`
    }
  }
}), _n = (e, a) => ({
  [`.${e}-drop-indicator`]: {
    position: "absolute",
    // it should displayed over the following node
    zIndex: 1,
    height: 2,
    backgroundColor: a.colorPrimary,
    borderRadius: 1,
    pointerEvents: "none",
    "&:after": {
      position: "absolute",
      top: -3,
      insetInlineStart: -6,
      width: 8,
      height: 8,
      backgroundColor: "transparent",
      border: `${a.lineWidthBold}px solid ${a.colorPrimary}`,
      borderRadius: "50%",
      content: '""'
    }
  }
}), Bn = (e, a) => {
  const {
    treeCls: l,
    treeNodeCls: s,
    treeNodePadding: c,
    treeTitleHeight: g
  } = a, d = (g - a.fontSizeLG) / 2, E = a.paddingXS;
  return {
    [l]: k(k({}, on(a)), {
      background: a.colorBgContainer,
      borderRadius: a.borderRadius,
      transition: `background-color ${a.motionDurationSlow}`,
      [`&${l}-rtl`]: {
        // >>> Switcher
        [`${l}-switcher`]: {
          "&_close": {
            [`${l}-switcher-icon`]: {
              svg: {
                transform: "rotate(90deg)"
              }
            }
          }
        }
      },
      [`&-focused:not(:hover):not(${l}-active-focused)`]: k({}, nt(a)),
      // =================== Virtual List ===================
      [`${l}-list-holder-inner`]: {
        alignItems: "flex-start"
      },
      [`&${l}-block-node`]: {
        [`${l}-list-holder-inner`]: {
          alignItems: "stretch",
          // >>> Title
          [`${l}-node-content-wrapper`]: {
            flex: "auto"
          },
          // >>> Drag
          [`${s}.dragging`]: {
            position: "relative",
            "&:after": {
              position: "absolute",
              top: 0,
              insetInlineEnd: 0,
              bottom: c,
              insetInlineStart: 0,
              border: `1px solid ${a.colorPrimary}`,
              opacity: 0,
              animationName: An,
              animationDuration: a.motionDurationSlow,
              animationPlayState: "running",
              animationFillMode: "forwards",
              content: '""',
              pointerEvents: "none"
            }
          }
        }
      },
      // ===================== TreeNode =====================
      [`${s}`]: {
        display: "flex",
        alignItems: "flex-start",
        padding: `0 0 ${c}px 0`,
        outline: "none",
        "&-rtl": {
          direction: "rtl"
        },
        // Disabled
        "&-disabled": {
          // >>> Title
          [`${l}-node-content-wrapper`]: {
            color: a.colorTextDisabled,
            cursor: "not-allowed",
            "&:hover": {
              background: "transparent"
            }
          }
        },
        [`&-active ${l}-node-content-wrapper`]: k({}, nt(a)),
        [`&:not(${s}-disabled).filter-node ${l}-title`]: {
          color: "inherit",
          fontWeight: 500
        },
        "&-draggable": {
          [`${l}-draggable-icon`]: {
            width: g,
            lineHeight: `${g}px`,
            textAlign: "center",
            visibility: "visible",
            opacity: 0.2,
            transition: `opacity ${a.motionDurationSlow}`,
            [`${s}:hover &`]: {
              opacity: 0.45
            }
          },
          [`&${s}-disabled`]: {
            [`${l}-draggable-icon`]: {
              visibility: "hidden"
            }
          }
        }
      },
      // >>> Indent
      [`${l}-indent`]: {
        alignSelf: "stretch",
        whiteSpace: "nowrap",
        userSelect: "none",
        "&-unit": {
          display: "inline-block",
          width: g
        }
      },
      // >>> Drag Handler
      [`${l}-draggable-icon`]: {
        visibility: "hidden"
      },
      // >>> Switcher
      [`${l}-switcher`]: k(k({}, Fn(e, a)), {
        position: "relative",
        flex: "none",
        alignSelf: "stretch",
        width: g,
        margin: 0,
        lineHeight: `${g}px`,
        textAlign: "center",
        cursor: "pointer",
        userSelect: "none",
        "&-noop": {
          cursor: "default"
        },
        "&_close": {
          [`${l}-switcher-icon`]: {
            svg: {
              transform: "rotate(-90deg)"
            }
          }
        },
        "&-loading-icon": {
          color: a.colorPrimary
        },
        "&-leaf-line": {
          position: "relative",
          zIndex: 1,
          display: "inline-block",
          width: "100%",
          height: "100%",
          // https://github.com/ant-design/ant-design/issues/31884
          "&:before": {
            position: "absolute",
            top: 0,
            insetInlineEnd: g / 2,
            bottom: -c,
            marginInlineStart: -1,
            borderInlineEnd: `1px solid ${a.colorBorder}`,
            content: '""'
          },
          "&:after": {
            position: "absolute",
            width: g / 2 * 0.8,
            height: g / 2,
            borderBottom: `1px solid ${a.colorBorder}`,
            content: '""'
          }
        }
      }),
      // >>> Checkbox
      [`${l}-checkbox`]: {
        top: "initial",
        marginInlineEnd: E,
        marginBlockStart: d
      },
      // >>> Title
      // add `${treeCls}-checkbox + span` to cover checkbox `${checkboxCls} + span`
      [`${l}-node-content-wrapper, ${l}-checkbox + span`]: {
        position: "relative",
        zIndex: "auto",
        minHeight: g,
        margin: 0,
        padding: `0 ${a.paddingXS / 2}px`,
        color: "inherit",
        lineHeight: `${g}px`,
        background: "transparent",
        borderRadius: a.borderRadius,
        cursor: "pointer",
        transition: `all ${a.motionDurationMid}, border 0s, line-height 0s, box-shadow 0s`,
        "&:hover": {
          backgroundColor: a.controlItemBgHover
        },
        [`&${l}-node-selected`]: {
          backgroundColor: a.controlItemBgActive
        },
        // Icon
        [`${l}-iconEle`]: {
          display: "inline-block",
          width: g,
          height: g,
          lineHeight: `${g}px`,
          textAlign: "center",
          verticalAlign: "top",
          "&:empty": {
            display: "none"
          }
        }
      },
      // https://github.com/ant-design/ant-design/issues/28217
      [`${l}-unselectable ${l}-node-content-wrapper:hover`]: {
        backgroundColor: "transparent"
      },
      // ==================== Draggable =====================
      [`${l}-node-content-wrapper`]: k({
        lineHeight: `${g}px`,
        userSelect: "none"
      }, _n(e, a)),
      [`${s}.drop-container`]: {
        "> [draggable]": {
          boxShadow: `0 0 0 2px ${a.colorPrimary}`
        }
      },
      // ==================== Show Line =====================
      "&-show-line": {
        // ================ Indent lines ================
        [`${l}-indent`]: {
          "&-unit": {
            position: "relative",
            height: "100%",
            "&:before": {
              position: "absolute",
              top: 0,
              insetInlineEnd: g / 2,
              bottom: -c,
              borderInlineEnd: `1px solid ${a.colorBorder}`,
              content: '""'
            },
            "&-end": {
              "&:before": {
                display: "none"
              }
            }
          }
        },
        // ============== Cover Background ==============
        [`${l}-switcher`]: {
          background: "transparent",
          "&-line-icon": {
            // https://github.com/ant-design/ant-design/issues/32813
            verticalAlign: "-0.15em"
          }
        }
      },
      [`${s}-leaf-last`]: {
        [`${l}-switcher`]: {
          "&-leaf-line": {
            "&:before": {
              top: "auto !important",
              bottom: "auto !important",
              height: `${g / 2}px !important`
            }
          }
        }
      }
    })
  };
}, Rn = (e) => {
  const {
    treeCls: a,
    treeNodeCls: l,
    treeNodePadding: s
  } = e;
  return {
    [`${a}${a}-directory`]: {
      // ================== TreeNode ==================
      [l]: {
        position: "relative",
        // Hover color
        "&:before": {
          position: "absolute",
          top: 0,
          insetInlineEnd: 0,
          bottom: s,
          insetInlineStart: 0,
          transition: `background-color ${e.motionDurationMid}`,
          content: '""',
          pointerEvents: "none"
        },
        "&:hover": {
          "&:before": {
            background: e.controlItemBgHover
          }
        },
        // Elements
        "> *": {
          zIndex: 1
        },
        // >>> Switcher
        [`${a}-switcher`]: {
          transition: `color ${e.motionDurationMid}`
        },
        // >>> Title
        [`${a}-node-content-wrapper`]: {
          borderRadius: 0,
          userSelect: "none",
          "&:hover": {
            background: "transparent"
          },
          [`&${a}-node-selected`]: {
            color: e.colorTextLightSolid,
            background: "transparent"
          }
        },
        // ============= Selected =============
        "&-selected": {
          "\n            &:hover::before,\n            &::before\n          ": {
            background: e.colorPrimary
          },
          // >>> Switcher
          [`${a}-switcher`]: {
            color: e.colorTextLightSolid
          },
          // >>> Title
          [`${a}-node-content-wrapper`]: {
            color: e.colorTextLightSolid,
            background: "transparent"
          }
        }
      }
    }
  };
}, jn = (e, a) => {
  const l = `.${e}`, s = `${l}-treenode`, c = a.paddingXS / 2, g = a.controlHeightSM, d = nn(a, {
    treeCls: l,
    treeNodeCls: s,
    treeNodePadding: c,
    treeTitleHeight: g
  });
  return [
    // Basic
    Bn(e, d),
    // Directory
    Rn(d)
  ];
}, Xn = Zt("Tree", (e, a) => {
  let {
    prefixCls: l
  } = a;
  return [{
    [e.componentCls]: en(`${l}-checkbox`, e)
  }, jn(l, e), tn(e)];
});
export {
  Gn as T,
  dt as V,
  jn as g,
  Wn as r,
  En as t,
  Xn as u
};
