import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
import { Command } from "commander";
import chalk from "chalk";
import open from "open";
import inquirer from "inquirer";
function registerSignupCommand(program) {
  program.command("signup").alias("register").description("Sign up for StackMemory hosted service").option("--no-open", "Do not automatically open browser").action(async (options) => {
    console.log(chalk.cyan("\u{1F680} StackMemory Hosted Service Signup\n"));
    const signupUrl = "https://stackmemory.ai/signup";
    if (options.open !== false) {
      console.log(chalk.gray("Opening signup page in your browser..."));
      try {
        await open(signupUrl);
        console.log(chalk.green("\u2713 Opened: ") + chalk.cyan(signupUrl));
      } catch (error) {
        console.log(chalk.yellow("Could not open browser automatically."));
        console.log(chalk.gray("Please visit: ") + chalk.cyan(signupUrl));
      }
    } else {
      console.log(chalk.gray("Visit this URL to sign up:"));
      console.log(chalk.cyan(signupUrl));
    }
    console.log(chalk.gray("\nAfter signing up, you can login with:"));
    console.log(chalk.cyan("  stackmemory login"));
    const { proceed } = await inquirer.prompt([
      {
        type: "confirm",
        name: "proceed",
        message: "Have you completed signup and want to login now?",
        default: false
      }
    ]);
    if (proceed) {
      const { registerLoginCommand } = await import("./login.js");
      const loginCmd = new Command();
      registerLoginCommand(loginCmd);
      console.log(chalk.cyan("\n\u{1F510} Proceeding to login...\n"));
      await loginCmd.parseAsync(["node", "stackmemory", "login"]);
    } else {
      console.log(chalk.gray("\nWhen ready, run: ") + chalk.cyan("stackmemory login"));
    }
  });
}
export {
  registerSignupCommand
};
//# sourceMappingURL=signup.js.map
