import{c as e,f as t,l as n}from"./openclaw-root-D_0Q6--h.js";import r from"node:os";import i from"node:fs/promises";async function a(e){if(e.allowFinalHardlinkForUnlink)return;let n;try{n=await i.stat(e.filePath)}catch(e){if(t(e))return;throw e}if(n.isFile()&&n.nlink>1)throw Error(`Hardlinked path is not allowed under ${e.boundaryLabel} (${o(e.root)}): ${o(e.filePath)}`)}function o(e){return e.startsWith(r.homedir())?`~${e.slice(r.homedir().length)}`:e}const s=e;async function c(e){let t=await n({absolutePath:e.absolutePath,rootPath:e.rootPath,boundaryLabel:e.boundaryLabel,policy:e.policy});e.policy?.allowFinalSymlinkForUnlink===!0&&t.kind===`symlink`||await a({filePath:t.absolutePath,root:t.rootPath,boundaryLabel:e.boundaryLabel,allowFinalHardlinkForUnlink:e.policy?.allowFinalHardlinkForUnlink})}export{c as n,s as t};
