{"ast":null,"code":"import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport * as React from 'react';\nimport { convertChildrenToData } from \"../utils/legacyUtil\";\nfunction buildTreeStructure(nodes, config) {\n  var id = config.id,\n    pId = config.pId,\n    rootPId = config.rootPId;\n  var nodeMap = new Map();\n  var rootNodes = [];\n  nodes.forEach(function (node) {\n    var nodeKey = node[id];\n    var clonedNode = _objectSpread(_objectSpread({}, node), {}, {\n      key: node.key || nodeKey\n    });\n    nodeMap.set(nodeKey, clonedNode);\n  });\n  nodeMap.forEach(function (node) {\n    var parentKey = node[pId];\n    var parent = nodeMap.get(parentKey);\n    if (parent) {\n      parent.children = parent.children || [];\n      parent.children.push(node);\n    } else if (parentKey === rootPId || rootPId === null) {\n      rootNodes.push(node);\n    }\n  });\n  return rootNodes;\n}\n\n/**\n * 将 `treeData` 或 `children` 转换为格式化的 `treeData`。\n * 如果 `treeData` 或 `children` 没有变化，则不会重新计算。\n */\nexport default function useTreeData(treeData, children, simpleMode) {\n  return React.useMemo(function () {\n    if (treeData) {\n      if (simpleMode) {\n        var config = _objectSpread({\n          id: 'id',\n          pId: 'pId',\n          rootPId: null\n        }, _typeof(simpleMode) === 'object' ? simpleMode : {});\n        return buildTreeStructure(treeData, config);\n      }\n      return treeData;\n    }\n    return convertChildrenToData(children);\n  }, [children, simpleMode, treeData]);\n}","map":{"version":3,"names":["_typeof","_objectSpread","React","convertChildrenToData","buildTreeStructure","nodes","config","id","pId","rootPId","nodeMap","Map","rootNodes","forEach","node","nodeKey","clonedNode","key","set","parentKey","parent","get","children","push","useTreeData","treeData","simpleMode","useMemo"],"sources":["/Users/nili/Documents/trae_projects/client/node_modules/rc-tree-select/es/hooks/useTreeData.js"],"sourcesContent":["import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport * as React from 'react';\nimport { convertChildrenToData } from \"../utils/legacyUtil\";\nfunction buildTreeStructure(nodes, config) {\n  var id = config.id,\n    pId = config.pId,\n    rootPId = config.rootPId;\n  var nodeMap = new Map();\n  var rootNodes = [];\n  nodes.forEach(function (node) {\n    var nodeKey = node[id];\n    var clonedNode = _objectSpread(_objectSpread({}, node), {}, {\n      key: node.key || nodeKey\n    });\n    nodeMap.set(nodeKey, clonedNode);\n  });\n  nodeMap.forEach(function (node) {\n    var parentKey = node[pId];\n    var parent = nodeMap.get(parentKey);\n    if (parent) {\n      parent.children = parent.children || [];\n      parent.children.push(node);\n    } else if (parentKey === rootPId || rootPId === null) {\n      rootNodes.push(node);\n    }\n  });\n  return rootNodes;\n}\n\n/**\n * 将 `treeData` 或 `children` 转换为格式化的 `treeData`。\n * 如果 `treeData` 或 `children` 没有变化，则不会重新计算。\n */\nexport default function useTreeData(treeData, children, simpleMode) {\n  return React.useMemo(function () {\n    if (treeData) {\n      if (simpleMode) {\n        var config = _objectSpread({\n          id: 'id',\n          pId: 'pId',\n          rootPId: null\n        }, _typeof(simpleMode) === 'object' ? simpleMode : {});\n        return buildTreeStructure(treeData, config);\n      }\n      return treeData;\n    }\n    return convertChildrenToData(children);\n  }, [children, simpleMode, treeData]);\n}"],"mappings":"AAAA,OAAOA,OAAO,MAAM,mCAAmC;AACvD,OAAOC,aAAa,MAAM,0CAA0C;AACpE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,qBAAqB,QAAQ,qBAAqB;AAC3D,SAASC,kBAAkBA,CAACC,KAAK,EAAEC,MAAM,EAAE;EACzC,IAAIC,EAAE,GAAGD,MAAM,CAACC,EAAE;IAChBC,GAAG,GAAGF,MAAM,CAACE,GAAG;IAChBC,OAAO,GAAGH,MAAM,CAACG,OAAO;EAC1B,IAAIC,OAAO,GAAG,IAAIC,GAAG,CAAC,CAAC;EACvB,IAAIC,SAAS,GAAG,EAAE;EAClBP,KAAK,CAACQ,OAAO,CAAC,UAAUC,IAAI,EAAE;IAC5B,IAAIC,OAAO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