import { negate as c, isEmpty as a, countBy as i, debounce as y, filter as m, mapValues as d, isObject as I } from "es-toolkit/compat";
import { isEqual as N } from "es-toolkit/predicate";
import { orderBy as u } from "es-toolkit/array";
import { searchNormalized as E } from "../../utils/searchNormalized.js";
const h = 100, F = c(N), B = c(a), S = (t) => (e) => !t.includes(e.id), j = (t) => (e) => t.includes(e.id), x = (t) => t.map((e) => e.id), A = (t) => i(t, (e) => e.type), v = (t) => i(t, (e) => e.subType), R = (t) => y(t, h), p = (t) => I(t.name), G = (t) => `${t.name.firstName} ${t.name.lastName}`, b = (t) => p(t) ? G(t) : t.name, l = (t) => u(
  t,
  [
    (e) => p(e) ? e.name.lastName.toLowerCase() : e.name?.toLowerCase() ?? ""
  ],
  ["asc"]
), g = (t) => {
  const e = Object.values(t), s = u(
    e,
    [
      (o) => (typeof o.name == "string" ? o.name.toLowerCase() : String(o.name)) ?? ""
    ],
    ["asc"]
  ), r = {};
  for (const o of s)
    r[o.id] = o;
  return r;
}, C = (t) => (e) => t ? E(b(e), t) : !0, $ = (t, e) => m(l(t), C(e)), q = (t) => {
  const e = {};
  return Object.values(t).forEach((s) => {
    B(s.items) && (e[s.id] = s);
  }), e;
}, z = (t, e = []) => m(t, (s) => e.includes(s.type)), D = (t, e) => t.filter((s) => s !== e), H = (t) => {
  const e = {}, s = {};
  d(t, (o) => {
    o.position === "last" ? e[o.id] = { ...o } : s[o.id] = { ...o };
  });
  const r = g(s);
  return a(e) ? r : { ...r, ...e };
}, M = (t) => d(t, (e) => ({
  ...e,
  items: l(e.items)
})), P = (t, e) => {
  const s = {};
  return t.forEach((r) => {
    s[r.id] = {
      ...r,
      items: []
    };
  }), e.forEach((r) => {
    (r.groupIds || []).forEach((f) => {
      const n = s[f];
      n && n.items.push(r);
    });
  }), s;
}, U = (t, e) => {
  const s = new Set(t);
  return s.has(e) ? s.delete(e) : s.add(e), [...s];
}, W = (t) => t ? t.startsWith("rioglyph-") ? t : `rioglyph-${t}` : null;
export {
  U as addOrRemoveFromList,
  j as containsItemById,
  R as debounceFn,
  D as excludeFromList,
  z as filterAssetByType,
  q as filterEmptyGroups,
  S as filterOutByItemId,
  $ as getFlatItems,
  G as getFullName,
  x as getListIds,
  P as getMappedItemsToGroups,
  v as getSubTypeCounts,
  A as getTypeCounts,
  B as notEmpty,
  F as notEqual,
  M as sortGroupItemsByName,
  H as sortGroupsByName,
  W as withRioglyphPrefix
};
//# sourceMappingURL=treeUtils.js.map
