/**
 * Calendar module setup — collects Google OAuth credential paths from the user.
 * Does NOT install anything; returns config values to store.
 */
export async function setup(systemConfig, readline) {
  const question = (prompt) =>
    new Promise((resolve) => readline.question(prompt, resolve));

  console.log("\nCalendar Module Setup");
  console.log("─────────────────────────────────────────────");
  console.log("Google OAuth credentials are required for calendar sync.");
  console.log("If you skip these, calendar sync will be disabled until set.\n");

  const defaultCreds = `${process.env.HOME}/.credentials/google-oauth.json`;
  const defaultToken = `${process.env.HOME}/.credentials/google-token.json`;

  const rawCreds = await question(`Google OAuth credentials path [${defaultCreds}]: `);
  const rawToken = await question(`Google token path [${defaultToken}]: `);

  const GOOGLE_CREDENTIALS_PATH = rawCreds.trim() || defaultCreds;
  const GOOGLE_TOKEN_PATH = rawToken.trim() || defaultToken;

  const orbitUrl = await question(
    `Orbit service URL (leave blank to disable) [${systemConfig.ports?.orbit ? `http://127.0.0.1:${systemConfig.ports.orbit}` : ""}]: `
  );

  console.log("\nCalendar module configured.");

  return {
    GOOGLE_CREDENTIALS_PATH,
    GOOGLE_TOKEN_PATH,
    ...(orbitUrl.trim() ? { ORBIT_URL: orbitUrl.trim() } : {}),
  };
}
