// src/platform/core/history-helpers.ts

// src/features/mcp/infrastructure/runtime.ts
var MCP_SERVICE_ORDER = ["codex", "gemini", "claude"];

// src/features/gen-html/domain/storybook-mcp.ts
var STORYBOOK_MCP_SERVER_NAME = "storybook-mcp";
var STORYBOOK_MCP_SERVER_URL = "https://main--685dde4728854606b608af64.chromatic.com/mcp";
function createStorybookMcpServerInput() {
  return {
    name: STORYBOOK_MCP_SERVER_NAME,
    transport: "http",
    url: STORYBOOK_MCP_SERVER_URL
  };
}

// src/features/gen-html/application/storybook-mcp-report.ts
function sortServiceResults(serviceResults) {
  return [...serviceResults].sort(
    (left, right) => MCP_SERVICE_ORDER.indexOf(left.service) - MCP_SERVICE_ORDER.indexOf(right.service)
  );
}
function formatStorybookMcpServiceResultsMarkdown(serviceResults) {
  if (serviceResults.length === 0) {
    return "- \uAE30\uC874 \uC124\uC815\uC774 \uC788\uC5B4 \uC774\uBC88 \uC2E4\uD589\uC5D0\uC11C \uCD94\uAC00 \uB3D9\uAE30\uD654\uB294 \uC5C6\uC5C8\uC2B5\uB2C8\uB2E4.";
  }
  return sortServiceResults(serviceResults).map((result) => `- ${result.service}: \`${result.ok ? "\uC131\uACF5" : "\uC2E4\uD328"}${result.skipped ? " (\uC0DD\uB7B5)" : ""}\` - ${result.detail}`).join("\n");
}
function formatStorybookMcpHealthCheckMarkdown(healthCheck) {
  return [
    `- ${healthCheck.endpoint.label}: \`${healthCheck.endpoint.ok}\``,
    `- detail: ${healthCheck.endpoint.detail}`,
    "",
    "### \uC11C\uBE44\uC2A4\uBCC4 \uC124\uC815 \uC0C1\uD0DC",
    ...sortServiceResults(healthCheck.services).map(
      (result) => `- ${result.service}: \`${result.ok ? "\uC124\uC815\uB428" : "\uB204\uB77D\uB428"}\` - ${result.detail}`
    )
  ].join("\n");
}
function formatStorybookMcpEnsureResultMarkdown(ensureResult) {
  const desiredInput = createStorybookMcpServerInput();
  return [
    `- serverName: \`${desiredInput.name}\``,
    `- url: \`${"url" in desiredInput ? desiredInput.url : ""}\``,
    `- registrationCreated: \`${ensureResult.registrationCreated}\``,
    `- registrationUpdated: \`${ensureResult.registrationUpdated}\``,
    `- repaired: \`${ensureResult.repaired}\``,
    "",
    "### \uD5EC\uC2A4\uCCB4\uD06C",
    formatStorybookMcpHealthCheckMarkdown(ensureResult.healthCheck),
    "",
    "### \uC774\uBC88 \uC2E4\uD589\uC758 \uB3D9\uAE30\uD654 \uACB0\uACFC",
    formatStorybookMcpServiceResultsMarkdown(ensureResult.syncResults)
  ].join("\n");
}

export { formatStorybookMcpEnsureResultMarkdown, formatStorybookMcpHealthCheckMarkdown, formatStorybookMcpServiceResultsMarkdown };
