import { a3 as x, a4 as t, aa as k, V as u, w as m, aH as E, en as T, a5 as y, cf as F, cg as P, eo as L, U as H, H as a, ad as s, I as h, ae as i, af as r, am as c, dv as I, ah as A, W as B, ep as M, eh as $, eq as q } from "./56c67d3b.js";
import { useContext as d, useState as D, useEffect as K } from "react";
import { treeCommonChildren as N, treeDataPropertyView as W, formSection as j, valuePropertyView as U, TreeNameConfigs as O, useTree as z } from "./1428e5db.js";
import "react-dom";
import "./b10db7f7.js";
const G = x.div`
  height: 100%;
  padding: 4px;
  background: ${(e) => e.background};
  border: 1px solid ${(e) => e.border};
  border-radius: ${(e) => e.radius};
  .ant-tree-show-line .ant-tree-switcher {
    background: ${(e) => e.background};
  }
  .simplebar-vertical {
    display: ${(e) => e.verticalScrollbar ? "block" : "none"};
  }
`, J = [{
  label: t("tree.noSelect"),
  value: "none"
}, {
  label: t("tree.singleSelect"),
  value: "single"
}, {
  label: t("tree.multiSelect"),
  value: "multi"
}, {
  label: t("tree.checkbox"),
  value: "check"
}], Q = {
  ...N,
  selectType: k(J, "single"),
  checkStrictly: u,
  autoExpandParent: u,
  label: m(B, {
    position: "column"
  }),
  autoHeight: E,
  verticalScrollbar: m(u, !1),
  // TODO: more event
  onEvent: T,
  style: y(F, "style"),
  labelStyle: y(P.filter((e) => ["accent", "validate"].includes(e.name) === !1), "labelStyle"),
  inputFieldStyle: y(L, "inputFieldStyle")
}, R = (e) => {
  const {
    treeData: v,
    selectType: o,
    value: l,
    expanded: b,
    checkStrictly: g,
    style: V,
    labelStyle: f
  } = e, [C, X] = D(), w = o === "single" || o === "multi", S = o === "check";
  return K(() => {
    o === "none" && l.value.length > 0 ? l.onChange([]) : o === "single" && l.value.length > 1 && l.onChange(l.value.slice(0, 1));
  }, [o]), z(e), e.label({
    required: e.required,
    ...M(e),
    style: V,
    labelStyle: f,
    inputFieldStyle: e.inputFieldStyle,
    children: /* @__PURE__ */ a(G, {
      ...e.inputFieldStyle,
      verticalScrollbar: e.verticalScrollbar,
      children: /* @__PURE__ */ a($, {
        style: {
          margin: 0,
          padding: 0
        },
        children: /* @__PURE__ */ a(q, {
          disabled: e.disabled,
          height: C,
          rootStyle: {
            background: "transparent",
            color: e.inputFieldStyle.text
          },
          fieldNames: {
            title: "label",
            key: "value"
          },
          treeData: v,
          selectable: w,
          multiple: o === "multi",
          selectedKeys: w ? l.value : [],
          checkable: S,
          checkedKeys: S ? g ? {
            checked: l.value,
            halfChecked: []
          } : l.value : void 0,
          checkStrictly: g,
          showLine: e.showLine ? {
            showLeafIcon: e.showLeafIcon
          } : !1,
          expandedKeys: b.value,
          autoExpandParent: e.autoExpandParent,
          onSelect: (n) => {
            l.onChange(n), e.onEvent("change");
          },
          onCheck: (n) => {
            l.onChange(Array.isArray(n) ? n : n.checked), e.onEvent("change");
          },
          onExpand: (n) => {
            b.onChange(n);
          },
          onFocus: () => e.onEvent("focus"),
          onBlur: () => e.onEvent("blur")
        }, o)
      })
    }),
    showValidationWhenEmpty: e.showValidationWhenEmpty
  });
};
let p = function() {
  return new H(Q, (e) => /* @__PURE__ */ a(R, {
    ...e
  })).setPropertyViewFn((e) => /* @__PURE__ */ s(h, {
    children: [/* @__PURE__ */ a(i, {
      name: r.basic,
      children: W(e)
    }), ["logic", "both"].includes(d(c).editorModeStatus) && /* @__PURE__ */ s(h, {
      children: [/* @__PURE__ */ a(I, {
        ...e
      }), j(e), /* @__PURE__ */ s(i, {
        name: r.interaction,
        children: [e.onEvent.getPropertyView(), e.hidden.propertyView({
          label: t("prop.hide")
        }), e.disabled.propertyView({
          label: t("prop.disabled")
        }), e.selectType.propertyView({
          label: t("tree.selectType")
        }), e.selectType.getView() !== "none" && U(e), e.selectType.getView() === "check" && e.checkStrictly.propertyView({
          label: t("tree.checkStrictly"),
          tooltip: t("tree.checkStrictlyTooltip")
        })]
      })]
    }), ["layout", "both"].includes(d(c).editorModeStatus) && /* @__PURE__ */ s(i, {
      name: r.layout,
      children: [e.autoHeight.getPropertyView(), !e.autoHeight.getView() && e.verticalScrollbar.propertyView({
        label: t("prop.showVerticalScrollbar")
      }), e.expanded.propertyView({
        label: t("tree.expanded")
      }), e.defaultExpandAll.propertyView({
        label: t("tree.defaultExpandAll")
      }), e.showLine.propertyView({
        label: t("tree.showLine")
      }), e.showLine.getView() && e.showLeafIcon.propertyView({
        label: t("tree.showLeafIcon")
      })]
    }), ["layout", "both"].includes(d(c).editorModeStatus) && e.label.getPropertyView(), ["layout", "both"].includes(d(c).editorModeStatus) && /* @__PURE__ */ s(h, {
      children: [/* @__PURE__ */ a(i, {
        name: r.style,
        children: e.style.getPropertyView()
      }), /* @__PURE__ */ a(i, {
        name: r.labelStyle,
        children: e.labelStyle.getPropertyView()
      }), /* @__PURE__ */ a(i, {
        name: r.inputFieldStyle,
        children: e.inputFieldStyle.getPropertyView()
      })]
    })]
  })).build();
}();
p = class extends p {
  autoHeight() {
    return this.children.autoHeight.getView();
  }
};
const le = A(p, O);
export {
  le as TreeComp
};
