const addLastChild = treeData => {
  const childMap = new Map();
  const updatedTreeData = treeData.map(node => {
    const newNode = {
      ...node
    };
    if (node.parentId) {
      const children = childMap.get(node.parentId) ?? [];
      children.push(newNode);
      childMap.set(node.parentId, children);
    }
    return newNode;
  });
  childMap.forEach(children => {
    const lastChildNode = children.at(-1);
    if (lastChildNode) {
      lastChildNode.lastChild = true;
    }
    const prevLastChild = children.at(-2);
    if (prevLastChild) {
      prevLastChild.lastChild = false;
    }
  });
  return updatedTreeData;
};

export { addLastChild };
//# sourceMappingURL=addLastChild.js.map
