import e from"node:path";const t=`openclaw`,n=new Set([t]),r=/^(?:((?:pnpm|npm|bunx|npx)\s+))?(openclaw)\b/;function i(r=process.argv){let i=r[1];if(!i)return t;let a=e.basename(i).trim();return n.has(a)?a:t}function a(e,t=i()){return!e.trim()||!r.test(e)?e:e.replace(r,(e,n)=>`${n??``}${t}`)}const o=/^[a-z0-9][a-z0-9_-]{0,63}$/i;function s(e){return e?o.test(e):!1}function c(e){let t=e?.trim();return!t||t.toLowerCase()===`default`||!s(t)?null:t}const l=/^(?:pnpm|npm|bunx|npx)\s+openclaw\b|^openclaw\b/,u=/(?:^|\s)--profile(?:\s|=|$)/,d=/(?:^|\s)--dev(?:\s|$)/;function f(e,t=process.env){let n=a(e,i()),r=c(t.OPENCLAW_PROFILE);return!r||!l.test(n)||u.test(n)||d.test(n)?n:n.replace(l,e=>`${e} --profile ${r}`)}export{a as n,i as r,f as t};
