const getParentKey = (key, tree) => {
  for (const node of tree) {
    if (node.children) {
      if (node.children.some((child) => child.key === key)) return node.key;
      const parentKey = getParentKey(key, node.children);
      if (parentKey) return parentKey;
    }
  }
  return void 0;
};
const flattenTreeData = (tree) => {
  const list = [];
  const walk = (nodes) => {
    nodes.forEach((node) => {
      if (typeof node.title === "string") {
        list.push({ key: node.key, title: node.title });
      }
      if (node.children) walk(node.children);
    });
  };
  walk(tree);
  return list;
};
const getExpandedKeysFromSearch = (searchValue, treeData, dataList) => dataList.filter(
  (item) => item.title.toLowerCase().includes(searchValue.toLowerCase())
).map((item) => getParentKey(item.key, treeData)).filter((key, i, self) => !!key && self.indexOf(key) === i);

export { getParentKey as a, flattenTreeData as f, getExpandedKeysFromSearch as g };
//# sourceMappingURL=search-B5K8FsJs.js.map
