import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  docsExtensionTypeSchema
} from "./chunk-VUZD5NYQ.js";
import {
  log
} from "./chunk-35LXVE2A.js";
import {
  runCommand
} from "./chunk-RF4NA2OH.js";
import "./chunk-NMCF7XG5.js";
import "./chunk-MHV22UIU.js";
import {
  renderCommand,
  runCommand as runCommand2
} from "./chunk-BA4M4QGR.js";
import "./chunk-RDF2RA4E.js";
import {
  NO_TTY_JSON_OUTPUT_OPTION
} from "./chunk-W2FACEYT.js";
import {
  InvalidArgumentError,
  Option,
  createCommand
} from "./chunk-4CMTZJ25.js";
import "./chunk-WFQIXGJV.js";
import "./chunk-ECBO3UFC.js";
import "./chunk-YNEGRO3E.js";
import "./chunk-VC5Q2AI5.js";
import "./chunk-HWT3LUJJ.js";
import "./chunk-TOBTRYZF.js";
import "./chunk-7WVNO7VU.js";
import "./chunk-RPTAJN5Y.js";
import "./chunk-YL4347CI.js";
import {
  require_react
} from "./chunk-TODKQSCF.js";
import "./chunk-AFPDHQYI.js";
import "./chunk-HYKBBZLS.js";
import "./chunk-C5RTKQVL.js";
import "./chunk-SVUXJRFD.js";
import "./chunk-YT5BPQDJ.js";
import "./chunk-LU3R3EBR.js";
import "./chunk-XZUGLEBK.js";
import "./chunk-VASURI4S.js";
import {
  external_exports
} from "./chunk-SDLCFZRL.js";
import {
  CliError,
  CliErrorCode
} from "./chunk-MTT3QXBC.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-astro-commands/src/index.ts
init_esm_shims();

// ../cli-astro-commands/src/commands/root-command.ts
init_esm_shims();

// ../cli-astro-commands/src/commands/build.ts
init_esm_shims();
var buildCommand = (services, cliVersion) => createCommand("build").description(
  "Invoke the astro build process, forwarding all command-line arguments."
).allowExcessArguments(true).allowUnknownOption(true).passThroughOptions(true).action(async (_, command) => {
  const { execa } = await import("./execa-CMKY4VHZ.js");
  const { getRepoType, createPackageManager } = await import("./src-ZLWJZWOF.js");
  const { runCommand: runCommand3 } = await import("./render-command-BXN7ZZAH.js");
  await runCommand3(command, services, cliVersion, async (model) => {
    const repoType = await getRepoType(model.projectFolder);
    const packageManager = await createPackageManager(repoType);
    const { file, args } = packageManager.getRunBinaryCmd(
      ["astro", "build"].concat(command.args)
    );
    try {
      const subprocess = execa(file, args, {
        cwd: model.projectFolder,
        stdin: "inherit",
        stdout: "inherit",
        stderr: "pipe"
      });
      subprocess.stderr?.pipe(process.stderr);
      await subprocess;
    } catch (e) {
      throw new CliError({
        code: CliErrorCode.FailedToBuildAstroApp(),
        cause: e
      });
    }
  });
});

// ../cli-astro-commands/src/commands/connect.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var connectCommand = (services, cliVersion) => {
  return createCommand("connect").description("Connect your project to GitHub to enable Wix Vibe editing").action(async (options, command) => {
    const { renderCommand: renderCommand2 } = await import("./render-command-BXN7ZZAH.js");
    const { ConnectWixVibeCommand } = await import("./ConnectWixVibeCommand-VADKDWAS.js");
    await renderCommand2(
      command,
      services,
      cliVersion,
      /* @__PURE__ */ import_react.default.createElement(ConnectWixVibeCommand, null)
    );
  });
};

// ../cli-astro-commands/src/commands/env.ts
init_esm_shims();

// ../cli-astro-commands/src/commands/env-pull.tsx
init_esm_shims();
var import_react2 = __toESM(require_react(), 1);
var envPullCommand = (services, cliVersion) => {
  return createCommand("pull").description(
    "Pulls environment variables and merge them into .env.local file"
  ).addOption(
    new Option(NO_TTY_JSON_OUTPUT_OPTION, "Output in JSON format").hideHelp()
  ).action(async (opts, command) => {
    if (opts.json) {
      return runCommand2(command, services, cliVersion, async (model) => {
        const { nonInteractiveEnvPull } = await import("./env-pull-GFH2YDV3.js");
        return nonInteractiveEnvPull(services, model);
      });
    }
    const { EnvPullCommand } = await import("./EnvPullCommand-FFLB73W2.js");
    await renderCommand(command, services, cliVersion, /* @__PURE__ */ import_react2.default.createElement(EnvPullCommand, null));
  });
};

// ../cli-astro-commands/src/commands/env-set.tsx
init_esm_shims();
var import_react3 = __toESM(require_react(), 1);
var envSetCommand = (services, cliVersion) => {
  return createCommand("set").description("Sets environment variable").requiredOption("--key <key>", "Name of the variable").requiredOption("--value <value>", "Value of the variable").action(async (opts, command) => {
    const { EnvSetCommand } = await import("./EnvSetCommand-MTE6RTNV.js");
    const variable = { key: opts.key, value: opts.value };
    await renderCommand(
      command,
      services,
      cliVersion,
      /* @__PURE__ */ import_react3.default.createElement(EnvSetCommand, { variable })
    );
  });
};

// ../cli-astro-commands/src/commands/env-remove.tsx
init_esm_shims();
var import_react4 = __toESM(require_react(), 1);
var envRemoveCommand = (services, cliVersion) => {
  return createCommand("remove").description("Removes an environment variable").requiredOption("--key <key>", "Name of the variable").action(async (opts, command) => {
    const { EnvRemoveCommand } = await import("./EnvRemoveCommand-LY52SB46.js");
    await renderCommand(
      command,
      services,
      cliVersion,
      /* @__PURE__ */ import_react4.default.createElement(EnvRemoveCommand, { variableKey: opts.key })
    );
  });
};

// ../cli-astro-commands/src/commands/env.ts
var envCommand = (services, cliVersion) => {
  return createCommand("env").description("Work with environment variables").addCommand(envPullCommand(services, cliVersion), { isDefault: true }).addCommand(envSetCommand(services, cliVersion)).addCommand(envRemoveCommand(services, cliVersion));
};

// ../cli-astro-commands/src/commands/preview.tsx
init_esm_shims();
var import_react5 = __toESM(require_react(), 1);

// ../cli-astro-commands/src/commands/validations.ts
init_esm_shims();
function validateBase(value) {
  const parsed = external_exports.string().url().safeParse(value);
  if (parsed.success) {
    return parsed.data;
  }
  throw new InvalidArgumentError("Value must be a valid URL");
}
var LABEL_MAX_LENGTH = 200;
function validateLabel(value) {
  const parsed = external_exports.string().max(LABEL_MAX_LENGTH).safeParse(value);
  if (parsed.success) {
    return parsed.data;
  }
  throw new InvalidArgumentError(
    `Value must be up to ${LABEL_MAX_LENGTH} characters`
  );
}
function validateReleaseComment(value) {
  const parsed = external_exports.string().max(250).safeParse(value);
  if (parsed.success) {
    return parsed.data;
  }
  throw new InvalidArgumentError(
    "The comment is limited to a maximum of 250 characters"
  );
}
function validateDocsExtensionType(value) {
  const parsed = docsExtensionTypeSchema.safeParse(value);
  if (parsed.success) {
    return parsed.data;
  }
  throw new InvalidArgumentError("Value must be a valid extension type");
}
function validateValidJson(rawJson) {
  try {
    const jsonObject = JSON.parse(rawJson);
    return jsonObject;
  } catch {
    throw new InvalidArgumentError("Value must be a valid JSON");
  }
}

// ../cli-astro-commands/src/commands/preview.tsx
var previewCommand = (services, cliVersion) => {
  return createCommand("preview").addOption(
    new Option(
      "--base-url <url>",
      "The base url for when static files have been uploaded to an external cdn"
    ).argParser(validateBase).hideHelp()
  ).addOption(
    new Option("-l, --label <label>", "A custom label for this preview").argParser(validateLabel).hideHelp()
  ).addOption(new Option("--site <site>", "(deprecated)").hideHelp()).addOption(
    new Option(NO_TTY_JSON_OUTPUT_OPTION, "Output in JSON format").hideHelp()
  ).action(async (options, command) => {
    const { baseUrl, json, label } = options;
    const { renderCommand: renderCommand2, runCommand: runCommand3 } = await import("./render-command-BXN7ZZAH.js");
    if (json) {
      return runCommand3(command, services, cliVersion, async (model) => {
        const { nonInteractivePreview } = await import("./preview-S2TH45K2.js");
        return nonInteractivePreview(services, model, { baseUrl, label });
      });
    }
    const { PreviewCommand } = await import("./PreviewCommand-IQJZO622.js");
    await renderCommand2(
      command,
      services,
      cliVersion,
      /* @__PURE__ */ import_react5.default.createElement(PreviewCommand, { baseUrl, label, environment: "preview" })
    );
  });
};

// ../cli-astro-commands/src/commands/promote.tsx
init_esm_shims();
var import_react6 = __toESM(require_react(), 1);
var promoteCommand = (services, cliVersion) => {
  return createCommand("promote").addOption(
    new Option(
      "--base-url <url>",
      "The base url for when static files have been uploaded to an external cdn"
    ).argParser(validateBase).hideHelp()
  ).addOption(
    new Option("-l, --label <label>", "A custom label for this preview").argParser(validateLabel).hideHelp()
  ).action(async (options, command) => {
    const { baseUrl, label } = options;
    const { renderCommand: renderCommand2 } = await import("./render-command-BXN7ZZAH.js");
    const { PromoteCommand } = await import("./PromoteCommand-DMGGXC5F.js");
    await renderCommand2(
      command,
      services,
      cliVersion,
      /* @__PURE__ */ import_react6.default.createElement(PromoteCommand, { baseUrl, label })
    );
  });
};

// ../cli-astro-commands/src/commands/release.tsx
init_esm_shims();
var import_react7 = __toESM(require_react(), 1);
var releaseCommand = (services, cliVersion) => {
  return createCommand("release").description("Release a new version of your application").addOption(
    new Option(
      "--base-url <url>",
      "The base url for when static files have been uploaded to an external cdn"
    ).argParser(validateBase).hideHelp()
  ).addOption(
    new Option("-l, --label <label>", "A custom label for this preview").argParser(validateLabel).hideHelp()
  ).option(
    "-c, --comment <comment>",
    "The comment for your release version, not visible by users",
    validateReleaseComment
  ).addOption(
    new Option(
      "-t, --version-type <type>",
      "The type of version you would like to create"
    ).choices(["major", "minor"])
  ).action(async (options, command) => {
    const { renderCommand: renderCommand2 } = await import("./render-command-BXN7ZZAH.js");
    const { ReleaseCommand } = await import("./ReleaseCommand-JBIRZTOC.js");
    const { baseUrl, label, comment } = options;
    const versionType = options.versionType ? {
      major: "MAJOR" /* MAJOR */,
      minor: "MINOR" /* MINOR */
    }[options.versionType] : void 0;
    await renderCommand2(
      command,
      services,
      cliVersion,
      /* @__PURE__ */ import_react7.default.createElement(
        ReleaseCommand,
        {
          baseUrl,
          label,
          comment,
          versionType
        }
      )
    );
  });
};

// ../cli-astro-commands/src/commands/dev.tsx
init_esm_shims();
var import_react8 = __toESM(require_react(), 1);
var devCommand = (services, cliVersion) => {
  return createCommand("dev").option(
    "--port <port>",
    "Specify which port to run on. Defaults to 4321.",
    (value) => {
      return parseInt(value, 10);
    }
  ).option(
    "--allowed-hosts <allowedHosts>",
    "Specify a comma-separated list of allowed hosts or allow any hostname."
  ).addOption(
    new Option(
      "--base-url <url>",
      "The base url for when static files have been uploaded to an external cdn"
    ).argParser(validateBase).hideHelp()
  ).action(async (options, command) => {
    const { DevCommand } = await import("./DevCommand-VW6RFNCM.js");
    const { renderCommand: renderCommand2 } = await import("./render-command-BXN7ZZAH.js");
    await renderCommand2(
      command,
      services,
      cliVersion,
      /* @__PURE__ */ import_react8.default.createElement(
        DevCommand,
        {
          port: options.port,
          allowedHosts: options.allowedHosts,
          serverExposedUrl: options.baseUrl
        }
      )
    );
  });
};

// ../cli-astro-commands/src/commands/generate.tsx
init_esm_shims();
var import_react10 = __toESM(require_react(), 1);

// ../cli-astro-commands/src/commands/generate-manifest.tsx
init_esm_shims();
var import_react9 = __toESM(require_react(), 1);
var generateManifestCommand = (services, cliVersion) => createCommand("manifest").description("Generate manifest for project extensions").action(async (_, command) => {
  const { renderCommand: renderCommand2 } = await import("./render-command-BXN7ZZAH.js");
  const { GenerateManifestCommand } = await import("./GenerateManifestCommand-NDHCZHTX.js");
  await renderCommand2(
    command,
    services,
    cliVersion,
    /* @__PURE__ */ import_react9.default.createElement(GenerateManifestCommand, null)
  );
});

// ../cli-astro-commands/src/commands/generate.tsx
var generateCommand = (services, cliVersion) => {
  return createCommand("generate").description("Generate a new extension for your project").addCommand(generateManifestCommand(services, cliVersion), { hidden: true }).addOption(
    new Option("--type <type>", "Extension type to generate").argParser(validateDocsExtensionType).conflicts("params")
  ).addOption(
    new Option(
      "--params <json>",
      "Generate an extension non-interactively from a JSON object"
    ).conflicts("type").implies({ json: true }).argParser(validateValidJson)
  ).addOption(
    new Option(NO_TTY_JSON_OUTPUT_OPTION, "Output in JSON format").hideHelp()
  ).addOption(
    new Option(
      "--experimental",
      "Include experimental generators in the picker"
    ).hideHelp()
  ).action(async (options, command) => {
    const { type, experimental = false, params } = options;
    const { runCommand: runCommand3, renderCommand: renderCommand2 } = await import("./render-command-BXN7ZZAH.js");
    if (params !== void 0) {
      await runCommand3(command, services, cliVersion, async (model) => {
        const { nonInteractiveGenerateExtension } = await import("./generate-extensions-LUTOVD5E.js");
        try {
          const result = await nonInteractiveGenerateExtension(
            services,
            model,
            params
          );
          log(JSON.stringify({ success: true, ...result }));
        } catch (e) {
          log(
            JSON.stringify({
              success: false,
              error: e instanceof Error ? e.message : String(e)
            })
          );
          throw e;
        }
      });
    } else {
      const { GenerateCommand } = await import("./GenerateCommand-MA63UMK6.js");
      await renderCommand2(
        command,
        services,
        cliVersion,
        /* @__PURE__ */ import_react10.default.createElement(
          GenerateCommand,
          {
            docsExtensionType: type,
            experimental
          }
        )
      );
    }
  });
};

// ../cli-astro-commands/src/commands/translation.tsx
init_esm_shims();

// ../cli-astro-commands/src/commands/translation-pull.tsx
init_esm_shims();
var import_react11 = __toESM(require_react(), 1);
var translationPullCommand = (services, cliVersion) => {
  return createCommand("pull").description(
    "Pulls Wix Multilingual translations and saves them to your project directory"
  ).addOption(
    new Option(NO_TTY_JSON_OUTPUT_OPTION, "Output in JSON format").hideHelp()
  ).action(async (opts, command) => {
    if (opts.json) {
      return runCommand2(command, services, cliVersion, async (model) => {
        const { nonInteractiveTranslationPull } = await import("./translation-pull-IP7JFGHV.js");
        return nonInteractiveTranslationPull(services, model);
      });
    }
    const { TranslationPullCommand } = await import("./TranslationPullCommand-3KZPOF6A.js");
    await renderCommand(
      command,
      services,
      cliVersion,
      /* @__PURE__ */ import_react11.default.createElement(TranslationPullCommand, null)
    );
  });
};

// ../cli-astro-commands/src/commands/translation-push.tsx
init_esm_shims();
var import_react12 = __toESM(require_react(), 1);
var translationPushCommand = (services, cliVersion) => {
  return createCommand("push").description(
    "Pushes local translation file `src/translations.json` to Wix Multilingual"
  ).addOption(
    new Option(NO_TTY_JSON_OUTPUT_OPTION, "Output in JSON format").hideHelp()
  ).action(async (opts, command) => {
    if (opts.json) {
      return runCommand2(command, services, cliVersion, async (model) => {
        const { nonInteractiveTranslationPush } = await import("./translation-push-CJ6CYPQH.js");
        return nonInteractiveTranslationPush(services, model);
      });
    }
    const { TranslationPushCommand } = await import("./TranslationPushCommand-KJTMJXSE.js");
    await renderCommand(
      command,
      services,
      cliVersion,
      /* @__PURE__ */ import_react12.default.createElement(TranslationPushCommand, null)
    );
  });
};

// ../cli-astro-commands/src/commands/translation.tsx
var translationCommand = (services, cliVersion) => {
  return createCommand("translation").description("Work with site translations").addCommand(translationPullCommand(services, cliVersion)).addCommand(translationPushCommand(services, cliVersion));
};

// ../cli-astro-commands/src/commands/skills.ts
init_esm_shims();

// ../cli-astro-commands/src/commands/skills-add.ts
init_esm_shims();
var skillsAddCommand = (services, cliVersion) => {
  const args = ["--yes", "skills", "add", "wix/skills", "-y"];
  const npxExecutable = process.env.WIX_CLI_NPX_PATH ?? "npx";
  return createCommand("add").description("Add Wix skills to your project").action(async (_, command) => {
    const { runCommand: runCommand3 } = await import("./render-command-BXN7ZZAH.js");
    await runCommand3(command, services, cliVersion, async (model) => {
      try {
        await runCommand(`${npxExecutable} ${args.join(" ")}`, {
          cwd: model.projectFolder,
          output: process.stdout
        });
      } catch (e) {
        throw new CliError({
          code: CliErrorCode.FailedToRunExternalCommand({
            file: "npx",
            args: [...args]
          }),
          cause: e
        });
      }
    });
  });
};

// ../cli-astro-commands/src/commands/skills-update.ts
init_esm_shims();
var skillsUpdateCommand = (services, cliVersion) => {
  const args = ["--yes", "skills", "update"];
  const npxExecutable = process.env.WIX_CLI_NPX_PATH ?? "npx";
  return createCommand("update").description("Update installed skills to the latest version").action(async (_, command) => {
    const { runCommand: runCommand3 } = await import("./render-command-BXN7ZZAH.js");
    await runCommand3(command, services, cliVersion, async (model) => {
      try {
        await runCommand(`${npxExecutable} ${args.join(" ")}`, {
          cwd: model.projectFolder,
          output: process.stdout
        });
      } catch (e) {
        throw new CliError({
          code: CliErrorCode.FailedToRunExternalCommand({
            file: "npx",
            args: [...args]
          }),
          cause: e
        });
      }
    });
  });
};

// ../cli-astro-commands/src/commands/skills.ts
var skillsCommand = (services, cliVersion) => {
  return createCommand("skills").description("Manage Wix skills").addCommand(skillsAddCommand(services, cliVersion)).addCommand(skillsUpdateCommand(services, cliVersion));
};

// ../cli-astro-commands/src/commands/schema.ts
init_esm_shims();

// ../cli-astro-commands/src/commands/schema-generate-extensions.ts
init_esm_shims();
var schemaGenerateExtensionsCommand = (services, cliVersion) => createCommand("generate").description(
  "Print a JSON schema of all available extension types and their required inputs"
).addOption(
  new Option(
    "--type <type>",
    "Print the schema for a single extension type instead of the full schema"
  ).argParser(validateDocsExtensionType)
).addOption(
  new Option(NO_TTY_JSON_OUTPUT_OPTION, "Output in JSON format").default(true).hideHelp()
).action(async (opts, command) => {
  await runCommand2(command, services, cliVersion, async (model) => {
    const { nonInteractiveSchemaGenerateExtensions } = await import("./schema-generate-extensions-4COLAUBL.js");
    return nonInteractiveSchemaGenerateExtensions(services, model, {
      type: opts.type
    });
  });
});

// ../cli-astro-commands/src/commands/schema.ts
var schemaCommand = (services, cliVersion) => createCommand("schema").description("Print machine-readable schemas for CLI commands").addCommand(schemaGenerateExtensionsCommand(services, cliVersion));

// ../cli-astro-commands/src/commands/root-command.ts
var getRootCommand = async (services, cliVersion) => {
  return createCommand("astro").enablePositionalOptions(true).addCommand(buildCommand(services, cliVersion)).addCommand(connectCommand(services, cliVersion)).addCommand(envCommand(services, cliVersion)).addCommand(previewCommand(services, cliVersion)).addCommand(skillsCommand(services, cliVersion)).addCommand(promoteCommand(services, cliVersion), { hidden: true }).addCommand(releaseCommand(services, cliVersion)).addCommand(devCommand(services, cliVersion)).addCommand(generateCommand(services, cliVersion)).addCommand(schemaCommand(services, cliVersion)).addCommand(translationCommand(services, cliVersion), { hidden: true });
};
export {
  getRootCommand
};
//# sourceMappingURL=src-VZO2YWN3.js.map