"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("lodash-unified"),u=require("vue"),v=t=>{let f=0;const r=u.ref(t.options||[]),o=u.ref(!1);u.watch(()=>t.options,e=>{r.value=e},{deep:!0});function s(e,a){if(!e?.length)return;const i=t.fieldNames?.value||"value";for(const n of e){if(n[i]===a[i])return n;if(n.children?.length){const l=s(n.children,a);if(l)return l}}}async function c(e,a=!1){if(!h.isFunction(t.request))return;e?.length||(o.value=!0),f+=1;const i=f;try{a&&(r.value=[]);const n=await t.request(e,t.params);if(i!==f)return;if(e?.length){const l=e[e.length-1],d=s(r.value,l);d&&(d.children=n)}else r.value=n}finally{o.value=!1}}return u.onMounted(()=>{t.lazy||c()}),u.watch(()=>t.params,()=>{c()},{deep:!0}),{options:r,request:c,loading:o}};exports.useOptions=v;
