import e from"../_util/collapseMotion.mjs";import{useInjectTreeContext as t}from"./contextTypes.mjs";import{treeNodeProps as n}from"./props.mjs";import r from"./TreeNode.mjs";import{Transition as i,computed as a,createVNode as o,defineComponent as s,nextTick as c,onBeforeUnmount as l,onMounted as u,shallowRef as d,vShow as f,watch as p,withDirectives as m}from"vue";var h=s({compatConfig:{MODE:3},name:`MotionTreeNode`,inheritAttrs:!1,props:{...n,active:Boolean,motion:Object,motionNodes:{type:Array},onMotionStart:Function,onMotionEnd:Function,motionType:String},setup(n,{attrs:s,slots:h}){let g=d(!0),_=t(),v=d(!1),y=a(()=>n.motion?n.motion:e()),b=(e,t)=>{t===`appear`?y.value?.onAfterEnter?.(e):t===`leave`&&y.value?.onAfterLeave?.(e),v.value||n.onMotionEnd(),v.value=!0};return p(()=>n.motionNodes,()=>{n.motionNodes&&n.motionType===`hide`&&g.value&&c(()=>{g.value=!1})},{immediate:!0,flush:`post`}),u(()=>{n.motionNodes&&n.onMotionStart()}),l(()=>{n.motionNodes&&b()}),()=>{let{motion:e,motionNodes:t,motionType:a,active:c,eventKey:l,...u}=n;return t?o(i,{...y.value,appear:a===`show`,onAfterAppear:e=>b(e,`appear`),onAfterLeave:e=>b(e,`leave`)},{default:()=>[m(o(`div`,{class:`${_.value.prefixCls}-treenode-motion`},[t.map(e=>{let{data:{...t},title:n,key:i,isStart:a,isEnd:s}=e;return delete t.children,o(r,{...t,title:n,active:c,data:e.data,key:i,eventKey:i,isStart:a,isEnd:s},h)})]),[[f,g.value]])]}):o(r,{class:s.class,style:s.style,...u,active:c,eventKey:l},h)}}});export{h as default};