import{n as e,r as t,t as n}from"./chunk-74CEPOFO-V0JXh91S.mjs";var r={name:`expand`,summary:`convert tabs to spaces`,usage:`expand [OPTION]... [FILE]...`,description:`Convert TABs in each FILE to spaces, writing to standard output. If no FILE is specified, standard input is read.`,options:[`-t N        Use N spaces per tab (default: 8)`,`-t LIST     Use comma-separated list of tab stops`,`-i          Only convert leading tabs on each line`],examples:[`expand file.txt             # Convert all tabs to 8 spaces`,`expand -t 4 file.txt        # Use 4-space tabs`,`expand -t 4,8,12 file.txt   # Custom tab stops`]};function i(e){let t=e.split(`,`).map(e=>e.trim()),n=[];for(let e of t){let t=parseInt(e,10);if(Number.isNaN(t)||t<1)return null;n.push(t)}for(let e=1;e<n.length;e++)if(n[e]<=n[e-1])return null;return n}function a(e,t){if(t.length===1){let n=t[0];return n-e%n}for(let n of t)if(n>e)return n-e;if(t.length>=2){let n=t[t.length-1]-t[t.length-2],r=t[t.length-1];return r+(Math.floor((e-r)/n)+1)*n-e}return 1}function o(e,t){let{tabStops:n,leadingOnly:r}=t,i=``,o=0,s=!0;for(let t of e)if(t===`	`)if(r&&!s)i+=t,o++;else{let e=a(o,n);i+=` `.repeat(e),o+=e}else t!==` `&&t!==`	`&&(s=!1),i+=t,o++;return i}function s(e,t){if(e===``)return``;let n=e.split(`
`),r=e.endsWith(`
`)&&n[n.length-1]===``;return r&&n.pop(),n.map(e=>o(e,t)).join(`
`)+(r?`
`:``)}var c={name:`expand`,execute:async(a,o)=>{if(n(a))return t(r);let c={tabStops:[8],leadingOnly:!1},l=[],u=0;for(;u<a.length;){let t=a[u];if(t===`-t`&&u+1<a.length){let e=i(a[u+1]);if(!e)return{exitCode:1,stdout:``,stderr:`expand: invalid tab size: '${a[u+1]}'
`};c.tabStops=e,u+=2}else if(t.startsWith(`-t`)&&t.length>2){let e=i(t.slice(2));if(!e)return{exitCode:1,stdout:``,stderr:`expand: invalid tab size: '${t.slice(2)}'
`};c.tabStops=e,u++}else if(t===`--tabs`&&u+1<a.length){let e=i(a[u+1]);if(!e)return{exitCode:1,stdout:``,stderr:`expand: invalid tab size: '${a[u+1]}'
`};c.tabStops=e,u+=2}else if(t.startsWith(`--tabs=`)){let e=i(t.slice(7));if(!e)return{exitCode:1,stdout:``,stderr:`expand: invalid tab size: '${t.slice(7)}'
`};c.tabStops=e,u++}else if(t===`-i`||t===`--initial`)c.leadingOnly=!0,u++;else if(t===`--`){l.push(...a.slice(u+1));break}else{if(t.startsWith(`-`)&&t!==`-`)return e(`expand`,t);l.push(t),u++}}let d=``;if(l.length===0)d=s(o.stdin??``,c);else for(let e of l){let t=o.fs.resolvePath(o.cwd,e),n=await o.fs.readFile(t);if(n===null)return{exitCode:1,stdout:d,stderr:`expand: ${e}: No such file or directory
`};d+=s(n,c)}return{exitCode:0,stdout:d,stderr:``}}},l={name:`expand`,flags:[{flag:`-t`,type:`value`,valueHint:`number`},{flag:`-i`,type:`boolean`}],stdinType:`text`,needsFiles:!0};export{l as n,c as t};
//# sourceMappingURL=chunk-VJFXDYWH-CWlZv59U.mjs.map