import { jsxs as o, jsx as a, Fragment as u } from "react/jsx-runtime";
import N from "react";
import { isObject as h } from "es-toolkit/compat";
import f from "../../utils/classNames.js";
import b from "../checkbox/Checkbox.js";
import T from "../radiobutton/RadioButton.js";
import i from "./TreeIcon.js";
const I = (n) => {
  if (n.icon === null)
    return { primaryIcon: null, subIcon: null };
  const e = n.icon ?? n.type, c = n.pairIcon === null ? null : n.pairIcon ?? n.subType ?? null;
  return { primaryIcon: e, subIcon: c };
}, j = N.memo((n) => {
  const { item: e, hasMultiselect: c, showRadioButtons: m, isSelected: s, onSelectItem: t, onActiveItem: p } = n, d = f(
    "TreeLeaf",
    "form-group margin-bottom-0",
    s && "active",
    e.className && e.className
  ), { primaryIcon: r, subIcon: l } = I(e);
  return /* @__PURE__ */ o("div", { className: d, "data-key": e.id, children: [
    c && /* @__PURE__ */ a(b, { className: "TreeCheckbox", checked: s, onClick: t }),
    !c && m && /* @__PURE__ */ a(T, { className: "TreeRadioButton", checked: s, onChange: t }),
    /* @__PURE__ */ o("span", { className: "TreeLabel TreeLabelName", onClick: p, children: [
      r && !l && /* @__PURE__ */ a(i, { icon: r }),
      r && l && /* @__PURE__ */ o("span", { className: "rioglyph-icon-pair", children: [
        /* @__PURE__ */ a(i, { icon: r }),
        /* @__PURE__ */ a(i, { icon: l })
      ] }),
      /* @__PURE__ */ o("span", { className: "TreeLabelNameText", children: [
        /* @__PURE__ */ a("span", { className: "TreeLabelNameTextHeadline", children: h(e.name) ? /* @__PURE__ */ o(u, { children: [
          /* @__PURE__ */ a("span", { className: "text-light margin-right-3", children: e.name.firstName }),
          /* @__PURE__ */ a("span", { children: e.name.lastName })
        ] }) : e.name }),
        e.info && /* @__PURE__ */ a("span", { className: "TreeLabelNameTextSubline", children: e.info })
      ] })
    ] })
  ] });
});
export {
  j as default
};
//# sourceMappingURL=TreeLeaf.js.map
