import y from "../../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import { fillFieldNames as d } from "../../../../rc-tree/es/utils/treeUtil.mjs";
var s;
(function(e) {
  e[e.None = 0] = "None", e[e.Start = 1] = "Start", e[e.End = 2] = "End";
})(s || (s = {}));
function a(e, f, u) {
  const {
    key: n,
    children: i
  } = u;
  function c(r) {
    const t = r[n], l = r[i];
    f(t, r) !== !1 && a(l || [], f, u);
  }
  e.forEach(c);
}
function K(e) {
  let {
    treeData: f,
    expandedKeys: u,
    startKey: n,
    endKey: i,
    fieldNames: c
  } = e;
  const r = [];
  let t = s.None;
  if (n && n === i)
    return [n];
  if (!n || !i)
    return [];
  function l(o) {
    return o === n || o === i;
  }
  return a(f, (o) => {
    if (t === s.End)
      return !1;
    if (l(o)) {
      if (r.push(o), t === s.None)
        t = s.Start;
      else if (t === s.Start)
        return t = s.End, !1;
    } else
      t === s.Start && r.push(o);
    return u.includes(o);
  }, d(c)), r;
}
function m(e, f, u) {
  const n = y(f), i = [];
  return a(e, (c, r) => {
    const t = n.indexOf(c);
    return t !== -1 && (i.push(r), n.splice(t, 1)), !!n.length;
  }, d(u)), i;
}
export {
  K as calcRangeKeys,
  m as convertDirectoryKeysToNodes
};
