import{convertChildrenToData as e}from"../utils/legacyUtil.mjs";import{shallowRef as t,toRaw as n,watch as r}from"vue";function i(e,{id:t,pId:n,rootPId:r}){let i={},a=[];return e.map(e=>{let n={...e},r=n[t];return i[r]=n,n.key=n.key||r,n}).forEach(e=>{let t=e[n],o=i[t];o&&(o.children=o.children||[],o.children.push(e)),(t===r||!o&&r===null)&&a.push(e)}),a}function a(a,o,s){let c=t();return r([s,a,o],()=>{let t=s.value;a.value?c.value=s.value?i(n(a.value),{id:`id`,pId:`pId`,rootPId:null,...t===!0?{}:t}):n(a.value).slice():c.value=e(n(o.value))},{immediate:!0,deep:!0}),c}export{a as default};