function flattenTree(treeData, option) {
  const childrenField = option?.children || "children";
  const result = [];
  function flatten(nodes) {
    for (const node of nodes) {
      const currentNode = node;
      const { [childrenField]: children, ...rest } = currentNode;
      result.push(rest);
      if (children && Array.isArray(children)) {
        flatten(children);
      }
    }
  }
  flatten(treeData);
  return result;
}

export { flattenTree };
//# sourceMappingURL=flattenTree.mjs.map
