import { X as k, Y as t, a3 as x, O as u, w as m, aA as E, eh as T, Z as y, c2 as F, c3 as P, ei as L, U as H, F as a, a6 as c, G as p, a7 as i, a8 as r, af as s, aa as I, P as A, dk as B, ej as M } from "./603b75d9.js";
import { useContext as d, useState as $, useEffect as j } from "react";
import { treeCommonChildren as D, treeDataPropertyView as K, formSection as N, valuePropertyView as q, TreeNameConfigs as O, useTree as U } from "./425a28f6.js";
import { SelectInputValidationSection as W, selectInputValidate as G } from "./00d44232.js";
import "react-dom";
import "./f9847c56.js";
import "./7030eb81.js";
const X = k.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"};
  }
`, Y = [{
  label: t("tree.noSelect"),
  value: "none"
}, {
  label: t("tree.singleSelect"),
  value: "single"
}, {
  label: t("tree.multiSelect"),
  value: "multi"
}, {
  label: t("tree.checkbox"),
  value: "check"
}], Z = {
  ...D,
  selectType: x(Y, "single"),
  checkStrictly: u,
  autoExpandParent: u,
  label: m(A, {
    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")
}, z = (e) => {
  const {
    treeData: v,
    selectType: o,
    value: l,
    expanded: b,
    checkStrictly: g,
    style: V,
    labelStyle: f
  } = e, [C, J] = $(), w = o === "single" || o === "multi", S = o === "check";
  return j(() => {
    o === "none" && l.value.length > 0 ? l.onChange([]) : o === "single" && l.value.length > 1 && l.onChange(l.value.slice(0, 1));
  }, [o]), U(e), e.label({
    required: e.required,
    ...G(e),
    style: V,
    labelStyle: f,
    inputFieldStyle: e.inputFieldStyle,
    children: /* @__PURE__ */ a(X, {
      ...e.inputFieldStyle,
      verticalScrollbar: e.verticalScrollbar,
      children: /* @__PURE__ */ a(B, {
        style: {
          margin: 0,
          padding: 0
        },
        children: /* @__PURE__ */ a(M, {
          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 h = function() {
  return new H(Z, (e) => /* @__PURE__ */ a(z, {
    ...e
  })).setPropertyViewFn((e) => /* @__PURE__ */ c(p, {
    children: [/* @__PURE__ */ a(i, {
      name: r.basic,
      children: K(e)
    }), ["logic", "both"].includes(d(s).editorModeStatus) && /* @__PURE__ */ c(p, {
      children: [/* @__PURE__ */ a(W, {
        ...e
      }), N(e), /* @__PURE__ */ c(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" && q(e), e.selectType.getView() === "check" && e.checkStrictly.propertyView({
          label: t("tree.checkStrictly"),
          tooltip: t("tree.checkStrictlyTooltip")
        })]
      })]
    }), ["layout", "both"].includes(d(s).editorModeStatus) && /* @__PURE__ */ c(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(s).editorModeStatus) && e.label.getPropertyView(), ["layout", "both"].includes(d(s).editorModeStatus) && /* @__PURE__ */ c(p, {
      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();
}();
h = class extends h {
  autoHeight() {
    return this.children.autoHeight.getView();
  }
};
const oe = I(h, O);
export {
  oe as TreeComp
};
