#!/usr/bin/env node
import{h as l}from"./chunk-7YD227Y6.js";function E(t,n,o){let r=t instanceof Error?t.message:String(t);return r.includes("EISDIR")?l.isADirectory(n,o):r.includes("ENOTDIR")?l.notADirectory(n,o):l.fileNotFound(n,o)}async function C(t,n,o){let{cmdName:r,allowStdinMarker:b=!0,stopOnError:u=!1,batchSize:m=100}=o;if(n.length===0)return{files:[{filename:"",content:t.stdin}],stderr:"",exitCode:0};let i=[],a="",s=0,f=[];for(let c=0;c<n.length;c+=m){let h=n.slice(c,c+m),v=await Promise.all(h.map(async e=>{if(b&&e==="-")return{filename:"-",content:t.stdin,error:null,observation:null};try{let d=t.fs.resolvePath(t.cwd,e),p=await t.fs.readFile(d,"binary");return{filename:e,content:p,error:null,observation:null}}catch(d){return{filename:e,content:"",error:`${r}: ${e}: No such file or directory
`,observation:E(d,e,r)}}}));for(let e of v)if(e.error){if(a+=e.error,s=1,e.observation&&f.push(e.observation),u)return{files:i,stderr:a,exitCode:s,observations:f}}else i.push({filename:e.filename,content:e.content})}return s===0?{files:i,stderr:a,exitCode:s}:{files:i,stderr:a,exitCode:s,observations:f}}async function A(t,n,o){let r=await C(t,n,{...o,stopOnError:!0});return r.exitCode!==0?{ok:!1,error:{stdout:"",stderr:r.stderr,exitCode:r.exitCode,...r.observations?{observations:r.observations}:{}}}:{ok:!0,content:r.files.map(u=>u.content).join("")}}export{C as a,A as b};
