import"../../errors-pXKbCKbL.js";import"../../editor-BmJI32_P.js";import{r as e}from"../../format-a_tYXjv9.js";import"../../fsStore-BzLA1cBc.js";import"../../base-xqced3zT.js";import"../../config-Bphz_1Sc.js";import"../../template-Cpbt9qy8.js";import"../../xling-DyktHkvX.js";import"../../claudeDefault-B8XYzR_k.js";import"../../claude-F-aLoUUK.js";import"../../codex-BDB0z8Gw.js";import"../../gemini-CPA89gOH.js";import{t}from"../../dispatcher-1aCGdFHn.js";import{Args as n,Command as r,Flags as i}from"@oclif/core";import a from"node:readline/promises";import{stdin as o,stdout as s}from"node:process";var c=class c extends r{static summary=`Switch Codex profiles or Claude settings variants`;static description=`
    Switch to a different profile configuration for Codex
    or activate a specific settings.<variant>.json for Claude.
  `;static examples=[`<%= config.bin %> <%= command.id %> oss --tool codex`,`<%= config.bin %> <%= command.id %> production --tool codex`,`<%= config.bin %> <%= command.id %> hxi --tool claude --scope user`];static args={profile:n.string({description:`Profile name to switch to`,required:!0})};static flags={tool:i.string({char:`t`,description:`AI CLI tool to manage`,options:[`claude`,`codex`,`gemini`,`xling`],default:`claude`}),scope:i.string({char:`s`,description:`Configuration scope`,options:[`user`,`project`,`local`,`system`],default:`user`}),json:i.boolean({description:`Output JSON instead of interactive text`,default:!1}),force:i.boolean({description:`Skip confirmation prompts (Claude only)`,default:!1}),backup:i.boolean({description:`Create a .bak backup when switching (Claude only)`,default:!1})};async run(){let{args:e,flags:n}=await this.parse(c);try{let r=new t,i=n.tool===`claude`?await this.#e(r,e.profile,n):await r.execute({tool:n.tool,scope:n.scope,action:`switch-profile`,profile:e.profile});if(!i)return;this.#n(i,e.profile,n)}catch(e){this.error(e.message,{exit:1})}}async#e(e,t,n){n.json&&!n.force&&this.error(`--json requires --force when switching Claude settings.`,{exit:1});let r=await e.execute({tool:`claude`,scope:n.scope,action:`switch-profile`,profile:t,switchOptions:{preview:!0}});if(r.diff)this.log(`Proposed changes:
`+r.diff);else return this.log(`No differences detected. Current settings already match the selected variant.`),r;let i=!!n.backup;if(!n.force&&!i){let e=await this.#t();if(e===`cancel`)return this.log(`Switch cancelled.`),null;i=e===`backup`}let a=await e.execute({tool:`claude`,scope:n.scope,action:`switch-profile`,profile:t,switchOptions:{backup:i}});return a.diff=r.diff,a}async#t(){let e=a.createInterface({input:o,output:s});try{for(;;){let t=(await e.question(`Choose action ([o]verwrite/[b]ackup/[c]ancel): `)).trim().toLowerCase();if([`overwrite`,`backup`,`cancel`].includes(t))return t;if([`o`,`b`,`c`].includes(t))return{o:`overwrite`,b:`backup`,c:`cancel`}[t]}}finally{e.close()}}#n(t,n,r){if(r.json){this.log(e(t));return}if(t.preview){this.log(`Preview only. No changes applied.`),t.diff&&this.log(t.diff);return}this.log(t.message??`Switched to profile: ${n}`),t.filePath&&this.log(`  File: ${t.filePath}`),t.diff&&this.log(`Applied diff:
`+t.diff)}};export{c as default};