import { defineComponent as C, ref as y, openBlock as a, createElementBlock as s, normalizeClass as i, unref as u, createVNode as m, withCtx as x, createBlock as g, createCommentVNode as d } from "vue";
import V from "vuedraggable";
import { useInjectApTable as b } from "../../../context.mjs";
import "../../../../config-provider/index.mjs";
import "./item.vue.mjs";
import { useNamespace as B } from "../../../../config-provider/hooks/use-namespace.mjs";
import c from "./item.vue2.mjs";
const E = /* @__PURE__ */ C({
  __name: "index",
  props: {
    value: {},
    "onUpdate:value": { type: Function }
  },
  setup(n) {
    const { b: p, is: f } = B("ap-column-setting-sortable-item"), { columnsBackup: v } = b(), r = (t) => t.flatMap((e) => [
      e,
      ...e.children ? r(e.children) : []
    ]);
    function k(t) {
      return r(v?.value ?? []).find((h) => h.key === t.key) ? t.show : !1;
    }
    const o = y(!1);
    return (t, e) => (a(), s("div", {
      class: i(u(p)())
    }, [
      m(c, {
        open: o.value,
        "onUpdate:open": e[0] || (e[0] = (l) => o.value = l),
        value: n.value
      }, null, 8, ["open", "value"]),
      n.value.children?.length ? (a(), s("div", {
        key: 0,
        class: i(u(f)("hidden", o.value))
      }, [
        m(u(V), {
          modelValue: n.value.children,
          "onUpdate:modelValue": e[1] || (e[1] = (l) => n.value.children = l),
          "item-key": "key"
        }, {
          item: x(({ element: l }) => [
            k(l) ? (a(), g(c, {
              key: 0,
              value: l,
              level: 2
            }, null, 8, ["value"])) : d("", !0)
          ]),
          _: 1
        }, 8, ["modelValue"])
      ], 2)) : d("", !0)
    ], 2));
  }
});
export {
  E as default
};
