import"../../vc-util/warning.mjs";import{camelize as e}from"../../_util/util.mjs";import t from"../../_util/omit.mjs";import{filterEmpty as n}from"../../_util/props-util/index.mjs";import{getPosition as r,isTreeNode as i}from"../util.mjs";function a(e,t){return e??t}function o(e){let{title:t,_title:n,key:r,children:i}=e||{},a=t||`title`;return{title:a,_title:n||[a],key:r||`key`,children:i||`children`}}function s(t){function r(t=[]){return n(t).map(t=>{if(!i(t))return null;let n=t.children||{},a=t.key,o={};for(let[n,r]of Object.entries(t.props))o[e(n)]=r;let{isLeaf:s,checkable:c,selectable:l,disabled:u,disableCheckbox:d}=o,f={isLeaf:s||s===``||void 0,checkable:c||c===``||void 0,selectable:l||l===``||void 0,disabled:u||u===``||void 0,disableCheckbox:d||d===``||void 0},p={...o,...f},{title:m=n.title?.(p),icon:h=n.icon?.(p),switcherIcon:g=n.switcherIcon?.(p),..._}=o,v=n.default?.(),y={..._,title:m,icon:h,switcherIcon:g,key:a,isLeaf:s,...f},b=r(v);return b.length&&(y.children=b),y})}return r(t)}function c(e,n,i){let{_title:s,key:c,children:l}=o(i),u=new Set(n===!0?[]:n),d=[];function f(e,i=null){return e.map((o,p)=>{let m=r(i?i.pos:`0`,p),h=a(o[c],m),g;for(let e=0;e<s.length;e+=1){let t=s[e];if(o[t]!==void 0){g=o[t];break}}let _={...t(o,[...s,c,l]),title:g,key:h,parent:i,pos:m,children:null,data:o,isStart:[...i?i.isStart:[],p===0],isEnd:[...i?i.isEnd:[],p===e.length-1]};return d.push(_),n===!0||u.has(h)?_.children=f(o[l]||[],_):_.children=[],_})}return f(e),d}function l(e,t,n){let i={};i=typeof n==`object`?n:{externalGetKey:n},i=i||{};let{childrenPropName:s,externalGetKey:c,fieldNames:l}=i,{key:u,children:d}=o(l),f=s||d,p;c?typeof c==`string`?p=e=>e[c]:typeof c==`function`&&(p=e=>c(e)):p=(e,t)=>a(e[u],t);function m(n,i,a,o){let s=n?n[f]:e,c=n?r(a.pos,i):`0`,l=n?[...o,n]:[];n&&t({node:n,index:i,pos:c,key:p(n,c),parentPos:a.node?a.pos:null,level:a.level+1,nodes:l}),s&&s.forEach((e,t)=>{m(e,t,{node:n,pos:c,level:a?a.level+1:-1},l)})}m(null)}function u(e,{initWrapper:t,processEntity:n,onProcessFinished:r,externalGetKey:i,childrenPropName:o,fieldNames:s}={},c){let u=i||c,d={},f={},p={posEntities:d,keyEntities:f};return t&&(p=t(p)||p),l(e,e=>{let{node:t,index:r,pos:i,key:o,parentPos:s,level:c,nodes:l}=e,u={node:t,nodes:l,index:r,key:o,pos:i,level:c},m=a(o,i);d[i]=u,f[m]=u,u.parent=d[s],u.parent&&(u.parent.children=u.parent.children||[],u.parent.children.push(u)),n&&n(u,p)},{externalGetKey:u,childrenPropName:o,fieldNames:s}),r&&r(p),p}function d(e,{expandedKeysSet:t,selectedKeysSet:n,loadedKeysSet:r,loadingKeysSet:i,checkedKeysSet:a,halfCheckedKeysSet:o,dragOverNodeKey:s,dropPosition:c,keyEntities:l}){let u=l[e];return{eventKey:e,expanded:t.has(e),selected:n.has(e),loaded:r.has(e),loading:i.has(e),checked:a.has(e),halfChecked:o.has(e),pos:String(u?u.pos:``),parent:u.parent,dragOver:s===e&&c===0,dragOverGapTop:s===e&&c===-1,dragOverGapBottom:s===e&&c===1}}function f(e){let{data:t,expanded:n,selected:r,checked:i,loaded:a,loading:o,halfChecked:s,dragOver:c,dragOverGapTop:l,dragOverGapBottom:u,pos:d,active:f,eventKey:p}=e,m={dataRef:t,...t,expanded:n,selected:r,checked:i,loaded:a,loading:o,halfChecked:s,dragOver:c,dragOverGapTop:l,dragOverGapBottom:u,pos:d,active:f,eventKey:p,key:p};return`props`in m||Object.defineProperty(m,"props",{get(){return e}}),m}export{u as convertDataToEntities,f as convertNodePropsToEventData,s as convertTreeToData,o as fillFieldNames,c as flattenTreeData,a as getKey,d as getTreeNodeProps,l as traverseDataNodes};