import {
  escapeMarkdown
} from "./chunk-NUFPTHKU.js";
import {
  getDataset
} from "./chunk-ITN2QGHF.js";
import "./chunk-CAY57CKF.js";
import "./chunk-KOO5733S.js";

// src/tools/get-dataset.ts
function formatDatasetResponse(dataset) {
  const lines = [];
  lines.push(`# Dataset: ${escapeMarkdown(dataset.name)}
`);
  lines.push(`**Slug**: ${escapeMarkdown(dataset.slug)}`);
  lines.push(`**ID**: ${escapeMarkdown(dataset.id)}`);
  if (Array.isArray(dataset.columnTypes) && dataset.columnTypes.length > 0) {
    lines.push("\n## Columns\n");
    lines.push("| Name | Type |");
    lines.push("|------|------|");
    for (const col of dataset.columnTypes) {
      lines.push(`| ${escapeMarkdown(col.name)} | ${escapeMarkdown(col.type)} |`);
    }
  }
  if (Array.isArray(dataset.data) && dataset.data.length > 0) {
    lines.push(`
## Records (${dataset.data.length} shown)
`);
    for (const record of dataset.data) {
      lines.push(`**${escapeMarkdown(record.id)}**: ${escapeMarkdown(JSON.stringify(record.entry))}`);
    }
  } else {
    lines.push("\nNo records in this dataset.");
  }
  return lines.join("\n");
}
async function handleGetDataset(params) {
  const dataset = await getDataset(params.slugOrId);
  if (params.format === "json") {
    return JSON.stringify(dataset, null, 2);
  }
  return formatDatasetResponse(dataset);
}
export {
  formatDatasetResponse,
  handleGetDataset
};
//# sourceMappingURL=get-dataset-BEVNXQNF.js.map