import{c as g,u as p,L as m,aa as v,r as y}from"./index-D92x6h1h.js";function h(n,u,i){const e=new Map;return u.forEach((t,s)=>{typeof t.uuid=="string"&&t.uuid&&e.set(t.uuid,s)}),n.map(t=>t.uuid).filter(t=>typeof t=="string"&&!!t).sort((t,s)=>{const c=e.get(t)??0,r=e.get(s)??0;return i==="up"?c-r:r-c})}function U(n,u,i){if(n.length===0)return!1;if(u.length===0)return!0;const e=i==="up"?u[0]?.uuid:u[u.length-1]?.uuid;return typeof e!="string"||!e?!0:!n.some(t=>t.uuid===e)}function M(n){return n[0]??null}function I(n){const u=g(),{t:i}=p(),e=y(!1);function t(){return n.value}async function s(r,f){if(f.length===0)return;const a=t(),d=a?.store?.entries??[],l=h(f,d,r);if(l.length!==0){e.value=!0;try{await m(`idnode/move${r}`,{uuid:JSON.stringify(l)}),await a?.store?.fetch(),await v();const o=M(l);o&&a?.scrollToUuid?.(o)}catch(o){u.error(o instanceof Error?o.message:String(o),{summary:i("Failed to move {0}",r)})}finally{e.value=!1}}}function c(r,f){const a=t();return U(r,a?.store?.entries??[],f)}return{moveInflight:e,moveSelected:s,canMove:c}}export{I as u};
