import { eM as b, fK as d, fL as h, V as l, bX as m, du as x, ci as C, a4 as r, H as c, co as D, ad as v, ae as V, I as w, aj as i, dk as g, c1 as k, fM as n } from "./56c67d3b.js";
import { useEffect as y } from "react";
import { defaultTreeData as S, treeDataTooltip as j } from "./b10db7f7.js";
import "react-dom";
function u(e, t) {
  return n(e, ["string", "number"], t);
}
function f(e, t) {
  return n(e, ["array", "undefined"], t, (a, o) => (n(a, ["object"], o), n(a.label, ["string"], "label"), u(a.value, "value"), n(a.disabled, ["boolean", "undefined"], "disabled"), n(a.selectable, ["boolean", "undefined"], "selectable"), n(a.checkable, ["boolean", "undefined"], "checkable"), n(a.disableCheckbox, ["boolean", "undefined"], "disableCheckbox"), n(a.isLeaf, ["boolean", "undefined"], "isLeaf"), f(a.children, "children"), a));
}
function E(e) {
  return e === "" ? [] : f(e) ?? [];
}
function s(e) {
  return e === "" ? [] : n(e, ["array"], void 0, u);
}
function p(e, t) {
  if (e) {
    for (const a of e)
      if (t(a) === !1 || !p(a.children, t))
        return !1;
  }
  return !0;
}
function N(e) {
  const t = [];
  return p(e, (a) => {
    a.children && a.children.length > 0 && t.push(a.value);
  }), t;
}
const P = {
  // TODO: support loading mode
  treeData: b(E, S),
  defaultValue: d("value", s, []),
  value: d("value", s, []),
  expanded: h(s, []),
  defaultExpandAll: l,
  showLine: l,
  showLeafIcon: l,
  disabled: m,
  ...x,
  ...C
};
function B(e) {
  const {
    treeData: t,
    expanded: a,
    defaultExpandAll: o
  } = e;
  y(() => {
    o ? a.onChange(N(t)) : a.reset();
  }, [o, t]);
}
const F = (e) => e.treeData.propertyView({
  label: r("tree.treeData"),
  tooltip: j
}), M = (e) => e.defaultValue.propertyView({
  label: r("tree.value")
}), H = (e) => /* @__PURE__ */ c(D, {
  ...e
}), K = (e, t) => /* @__PURE__ */ v(V, {
  name: r("prop.expand"),
  children: [e.expanded.propertyView({
    label: r("tree.expanded")
  }), e.defaultExpandAll.propertyView({
    label: r("tree.defaultExpandAll")
  }), t]
}), X = (e, t) => /* @__PURE__ */ c(w, {}), q = [
  // TODO: more data
  new i("value", r("tree.valueDesc")),
  new i("treeData", r("tree.treeDataDesc")),
  new i("expanded", r("tree.expandedDesc")),
  g,
  ...k
];
export {
  q as TreeNameConfigs,
  X as advancedSection,
  K as expandSection,
  H as formSection,
  P as treeCommonChildren,
  F as treeDataPropertyView,
  B as useTree,
  M as valuePropertyView
};
