const prompts = require('@clack/prompts');
const { PROFILES } = require('./profiles');

async function askInstallQuestions({ cwd }) {
  const targetDirectory = await prompts.text({
    message: 'Install RTExit into which directory?',
    initialValue: cwd,
  });

  const language = await prompts.select({
    message: 'Choose interface language',
    options: [
      { value: 'en', label: 'English' },
      { value: 'ar', label: 'Arabic' },
    ],
  });

  const document_output_language = await prompts.select({
    message: 'Choose report language',
    options: [
      { value: 'en', label: 'English' },
      { value: 'ar', label: 'Arabic' },
    ],
  });

  const ides = await prompts.multiselect({
    message: 'Which AI IDEs are you using? (space to select, enter to confirm)',
    options: [
      { value: 'agents',  label: 'Cursor / Windsurf / VS Code  (.agents/skills/)' },
      { value: 'claude',  label: 'Claude Code                  (.claude/skills/)' },
      { value: 'trae',    label: 'Trae                         (.trae/skills/)' },
      { value: 'codex',   label: 'Codex / OpenAI               (.codex/skills/)' },
    ],
    initialValues: ['agents'],
    required: true,
  });

  const profileOptions = [
    { value: 'all', label: 'All Skills (Full install — everything)', hint: 'recommended for full red team ops' },
    ...Object.entries(PROFILES).map(([key, p]) => ({
      value: key,
      label: `${p.label}`,
      hint: p.description,
    })),
  ];

  const profiles = await prompts.multiselect({
    message: 'Which skill profiles do you need? (space to select, enter to confirm)',
    options: profileOptions,
    initialValues: ['all'],
    required: true,
  });

  const confirmed = await prompts.confirm({
    message: `Install RTExit into ${targetDirectory}?`,
    initialValue: true,
  });

  return { targetDirectory, language, document_output_language, ides, profiles, confirmed };
}

module.exports = { askInstallQuestions };
