import"./chunk-DXB73IDG.js";async function x(o,h){let s="octal",e=[],i=[];for(let t=0;t<o.length;t++){let r=o[t];if(r==="-c")e.push("char");else if(r==="-An"||r==="-A"&&o[t+1]==="n")s="none",r==="-A"&&t++;else if(r==="-t"&&o[t+1]){let n=o[++t];n==="x1"?e.push("hex"):n==="c"?e.push("char"):n.startsWith("o")&&e.push("octal")}else(!r.startsWith("-")||r==="-")&&i.push(r)}e.length===0&&e.push("octal");let c=h.stdin;if(i.length>0&&i[0]!=="-"){let t=i[0].startsWith("/")?i[0]:`${h.cwd}/${i[0]}`;try{c=await h.fs.readFile(t)}catch{return{stdout:"",stderr:`od: ${i[0]}: No such file or directory
`,exitCode:1}}}let m=e.includes("char");function g(t){return t===0?"  \\0":t===7?"  \\a":t===8?"  \\b":t===9?"  \\t":t===10?"  \\n":t===11?"  \\v":t===12?"  \\f":t===13?"  \\r":t>=32&&t<127?`   ${String.fromCharCode(t)}`:` ${t.toString(8).padStart(3,"0")}`}function S(t){return m?`  ${t.toString(16).padStart(2,"0")}`:` ${t.toString(16).padStart(2,"0")}`}function $(t){return` ${t.toString(8).padStart(3,"0")}`}let f=[];for(let t of c)f.push(t.charCodeAt(0));let p=16,a=[];for(let t=0;t<f.length;t+=p){let r=f.slice(t,t+p);for(let n=0;n<e.length;n++){let d=e[n],u;d==="char"?u=r.map(g):d==="hex"?u=r.map(S):u=r.map($);let l="";n===0&&s!=="none"?l=`${t.toString(8).padStart(7,"0")} `:(n>0||s==="none")&&(l=s==="none"?"":"        "),a.push(l+u.join(""))}}return s!=="none"&&f.length>0&&a.push(f.length.toString(8).padStart(7,"0")),{stdout:a.length>0?`${a.join(`
`)}
`:"",stderr:"",exitCode:0}}var y={name:"od",execute:x};export{y as od};
