import { a3 as x, er as L, a4 as t, aa as g, W as P, w as F, X as A, en as I, V as C, a as k, a5 as w, cf as M, cg as H, es as W, S as D, U as N, H as r, ad as a, I as S, ae as o, af as n, et as R, am as c, dv as O, eu as j, ev as B, dj as U, ah as _, aj as $, dg as q, aA as K, ew as d } from "./56c67d3b.js";
import { useContext as u, useEffect as X } from "react";
import { treeCommonChildren as z, treeDataPropertyView as G, formSection as J, valuePropertyView as Q, TreeNameConfigs as Y, useTree as Z } from "./1428e5db.js";
import "react-dom";
import "./b10db7f7.js";
const ee = x(d)`
  width: 100%;
  ${(e) => e.$style && L(e.$style)}
`, te = [{
  label: t("tree.singleSelect"),
  value: "single"
}, {
  label: t("tree.multiSelect"),
  value: "multi"
}, {
  label: t("tree.checkbox"),
  value: "check"
}], le = [{
  label: t("tree.showAll"),
  value: "all"
}, {
  label: t("tree.showParent"),
  value: "parent"
}, {
  label: t("tree.showChild"),
  value: "child"
}], ae = {
  ...z,
  selectType: g(te, "single"),
  checkedStrategy: g(le, "parent"),
  label: P,
  placeholder: F(A, t("tree.placeholder")),
  // TODO: more event
  onEvent: I,
  allowClear: C,
  showSearch: C.DEFAULT_TRUE,
  inputValue: k(""),
  // search value
  style: w(M, "style"),
  labelStyle: w(H, "labelStyle"),
  inputFieldStyle: w(W, "inputFieldStyle"),
  viewRef: D
};
function oe(e) {
  switch (e) {
    case "all":
      return d.SHOW_ALL;
    case "parent":
      return d.SHOW_PARENT;
    case "child":
      return d.SHOW_CHILD;
  }
}
const ne = (e) => {
  const {
    treeData: y,
    selectType: s,
    value: i,
    expanded: b,
    style: V,
    labelStyle: f,
    inputValue: m
  } = e, h = s === "single", [v, E] = q(e);
  return X(() => {
    h && i.value.length > 1 && i.onChange(i.value.slice(0, 1));
  }, [s]), Z(e), e.label({
    required: e.required,
    ...v,
    style: V,
    labelStyle: f,
    inputFieldStyle: e.inputFieldStyle,
    children: /* @__PURE__ */ r(ee, {
      ref: e.viewRef,
      $style: e.inputFieldStyle,
      popupMatchSelectWidth: !1,
      disabled: e.disabled,
      placeholder: e.placeholder,
      allowClear: e.allowClear,
      fieldNames: {
        label: "label",
        value: "value"
      },
      treeData: y,
      multiple: !h,
      value: h ? i.value[0] : i.value,
      treeCheckable: s === "check",
      showCheckedStrategy: oe(e.checkedStrategy),
      treeLine: e.showLine ? {
        showLeafIcon: e.showLeafIcon
      } : !1,
      treeExpandedKeys: m ? void 0 : b.value,
      onTreeExpand: (l) => {
        b.onChange(l);
      },
      onChange: (l) => {
        const T = Array.isArray(l) ? l : l !== void 0 ? [l] : [];
        E(T);
      },
      showSearch: e.showSearch,
      treeNodeFilterProp: "label",
      autoClearSearchValue: !1,
      onSearch: (l) => {
        e.dispatch(K("inputValue", l, !1));
      },
      onFocus: () => e.onEvent("focus"),
      onBlur: () => e.onEvent("blur")
    }, s),
    showValidationWhenEmpty: e.showValidationWhenEmpty
  });
};
let p = function() {
  return new N(ae, (e, y) => /* @__PURE__ */ r(ne, {
    ...e,
    dispatch: y
  })).setPropertyViewFn((e) => /* @__PURE__ */ a(S, {
    children: [/* @__PURE__ */ a(o, {
      name: n.basic,
      children: [G(e), R(e)]
    }), ["logic", "both"].includes(u(c).editorModeStatus) && /* @__PURE__ */ a(S, {
      children: [/* @__PURE__ */ r(O, {
        ...e
      }), J(e), /* @__PURE__ */ a(o, {
        name: n.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")
        }), Q(e), e.selectType.getView() === "check" && e.checkedStrategy.propertyView({
          label: t("tree.checkedStrategy")
        }), j(e), B(e)]
      })]
    }), ["layout", "both"].includes(u(c).editorModeStatus) && /* @__PURE__ */ a(o, {
      name: n.layout,
      children: [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(u(c).editorModeStatus) && e.label.getPropertyView(), ["layout", "both"].includes(u(c).editorModeStatus) && /* @__PURE__ */ a(S, {
      children: [/* @__PURE__ */ r(o, {
        name: n.style,
        children: e.style.getPropertyView()
      }), /* @__PURE__ */ r(o, {
        name: n.labelStyle,
        children: e.labelStyle.getPropertyView()
      }), /* @__PURE__ */ r(o, {
        name: n.inputFieldStyle,
        children: e.inputFieldStyle.getPropertyView()
      })]
    })]
  })).setExposeMethodConfigs(U).build();
}();
p = class extends p {
  autoHeight() {
    return !0;
  }
};
const de = _(p, [...Y, new $("inputValue", t("select.inputValueDesc"))]);
export {
  de as TreeSelectComp
};
