// Force strict mode and setup for ESM
"use strict";
import {
  getEffectiveSupportedModes
} from "./chunk-XU2SISL3.js";
import {
  init_esbuild_shims
} from "./chunk-5O2XNYP6.js";
import {
  __name
} from "./chunk-J2S4EL5Y.js";

// packages/cli/src/services/commandMetadata.ts
init_esbuild_shims();
function getCommandSourceBadge(command) {
  switch (command.source) {
    case "bundled-skill":
      return "[Skill]";
    case "skill-dir-command":
      if (command.sourceDetail === "user") {
        return "[User]";
      }
      if (command.sourceDetail === "project") {
        return "[Project]";
      }
      return "[Custom]";
    case "plugin-command":
      return command.sourceDetail === "extension" ? "[Extension]" : "[Plugin]";
    case "mcp-prompt":
      return "[MCP]";
    case "builtin-command":
    default:
      return null;
  }
}
__name(getCommandSourceBadge, "getCommandSourceBadge");
function getCommandSourceGroup(command) {
  switch (command.source) {
    case "builtin-command":
      return { key: "built-in", title: "Built-in Commands", order: 0 };
    case "bundled-skill":
      return { key: "bundled-skill", title: "Bundled Skills", order: 1 };
    case "skill-dir-command":
      return { key: "custom", title: "Custom Commands", order: 2 };
    case "plugin-command":
      return { key: "plugin", title: "Plugin Commands", order: 3 };
    case "mcp-prompt":
      return { key: "mcp", title: "MCP Commands", order: 4 };
    default:
      return { key: "other", title: "Other Commands", order: 5 };
  }
}
__name(getCommandSourceGroup, "getCommandSourceGroup");
function formatSupportedModes(command) {
  const modes = getEffectiveSupportedModes(command);
  const hasInteractive = modes.includes("interactive");
  const hasNonInteractive = modes.includes("non_interactive");
  const hasAcp = modes.includes("acp");
  if (hasInteractive && hasNonInteractive && hasAcp) {
    return "[all]";
  }
  if (!hasInteractive && hasNonInteractive && hasAcp) {
    return "[headless]";
  }
  if (hasInteractive && !hasNonInteractive && !hasAcp) {
    return "[interactive]";
  }
  return modes.map((mode) => {
    switch (mode) {
      case "interactive":
        return "[i]";
      case "non_interactive":
        return "[ni]";
      case "acp":
        return "[acp]";
      default:
        return `[${mode}]`;
    }
  }).join(" ");
}
__name(formatSupportedModes, "formatSupportedModes");
function getCommandDisplayName(command, options = {}) {
  const prefix = options.prefix ?? "";
  const baseLabel = `${prefix}${command.name}`;
  if (options.matchedAlias) {
    return `${baseLabel} (alias: ${options.matchedAlias})`;
  }
  if (options.includeAliases === false) {
    return baseLabel;
  }
  const altNames = command.altNames?.filter(Boolean);
  if (!altNames || altNames.length === 0) {
    return baseLabel;
  }
  return `${baseLabel} (${altNames.join(", ")})`;
}
__name(getCommandDisplayName, "getCommandDisplayName");
function getCommandSubcommandNames(command) {
  return command.subCommands?.filter((subCommand) => !subCommand.hidden).map((subCommand) => subCommand.name) ?? [];
}
__name(getCommandSubcommandNames, "getCommandSubcommandNames");

export {
  getCommandSourceBadge,
  getCommandSourceGroup,
  formatSupportedModes,
  getCommandDisplayName,
  getCommandSubcommandNames
};
/**
 * @license
 * Copyright 2025 Qwen
 * SPDX-License-Identifier: Apache-2.0
 */
