import y from "../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import b from "../../../@babel/runtime/helpers/esm/typeof.mjs";
import { toPathOptions as g } from "../utils/treeUtil.mjs";
import * as v from "react";
import { toPathKey as h } from "../utils/commonUtil.mjs";
const _ = function(m, p, u, c, f) {
  return v.useMemo(function() {
    var d = f || // Default displayRender
    function(e) {
      var n = c ? e.slice(-1) : e, r = " / ";
      return n.every(function(a) {
        return ["string", "number"].includes(b(a));
      }) ? n.join(r) : n.reduce(function(a, i, t) {
        var o = /* @__PURE__ */ v.isValidElement(i) ? /* @__PURE__ */ v.cloneElement(i, {
          key: t
        }) : i;
        return t === 0 ? [o] : [].concat(y(a), [r, o]);
      }, []);
    };
    return m.map(function(e) {
      var n, r = g(e, p, u), a = d(r.map(function(t) {
        var o, l = t.option, s = t.value;
        return (o = l == null ? void 0 : l[u.label]) !== null && o !== void 0 ? o : s;
      }), r.map(function(t) {
        var o = t.option;
        return o;
      })), i = h(e);
      return {
        label: a,
        value: i,
        key: i,
        valueCells: e,
        disabled: (n = r[r.length - 1]) === null || n === void 0 || (n = n.option) === null || n === void 0 ? void 0 : n.disabled
      };
    });
  }, [m, p, u, f, c]);
};
export {
  _ as default
};
