import { existsSync, mkdirSync, readFileSync } from 'node:fs';
import a from './index5.mjs';
import { i as inquirer } from './index6.mjs';
import { i18n } from './index2.mjs';
import { writeFileAtomic } from './fs-operations.mjs';
import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
import '../shared/ccjk.BAGoDD49.mjs';
import 'node:readline';
import 'stream';
import 'node:tty';
import 'node:process';
import 'node:async_hooks';
import '../shared/ccjk.Cjgrln_h.mjs';
import 'node:util';
import 'tty';
import 'fs';
import 'child_process';
import 'node:path';
import 'node:os';
import 'node:crypto';
import 'buffer';
import 'string_decoder';
import 'node:url';
import 'node:fs/promises';

const TEAM_DIR = ".ccjk/team";
const CONFIG_FILE = join(TEAM_DIR, "config.json");
async function teamInit() {
  if (!existsSync(TEAM_DIR)) {
    mkdirSync(TEAM_DIR, { recursive: true });
  }
  const { name } = await inquirer.prompt({
    type: "input",
    name: "name",
    message: i18n.t("team:enterTeamName"),
    default: "my-team"
  });
  const config = {
    name,
    members: [],
    sharedSettings: {}
  };
  writeFileAtomic(CONFIG_FILE, JSON.stringify(config, null, 2));
  console.log(a.green(`\u2714 ${i18n.t("team:teamInitialized")}: ${name}`));
}
async function teamShare() {
  if (!existsSync(CONFIG_FILE)) {
    console.log(a.yellow(i18n.t("team:noTeamConfig")));
    return;
  }
  const config = JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
  console.log(a.green(i18n.t("team:shareConfig")));
  console.log(JSON.stringify(config, null, 2));
}
async function teamSync() {
  if (!existsSync(CONFIG_FILE)) {
    console.log(a.yellow(i18n.t("team:noTeamConfig")));
    return;
  }
  console.log(a.green(`\u2714 ${i18n.t("team:syncComplete")}`));
}

export { teamInit, teamShare, teamSync };
