#!/usr/bin/env node
//#region src/util/exportToFile/index.ts
function convertEvalResultToTableCell(result) {
	let resultText;
	const outputTextDisplay = typeof result.response?.output === "object" ? JSON.stringify(result.response.output) : result.response?.output || result.error || "";
	if (result.testCase.assert) if (result.success) resultText = `${outputTextDisplay || result.error || ""}`;
	else resultText = `${outputTextDisplay}`;
	else if (result.error) resultText = `${result.error}`;
	else resultText = outputTextDisplay;
	return {
		...result,
		id: result.id || `${result.testIdx}-${result.promptIdx}`,
		text: resultText || "",
		prompt: result.prompt.raw,
		provider: result.provider?.label || result.provider?.id || "unknown provider",
		pass: result.success,
		cost: result.cost || 0,
		audio: result.response?.audio ? {
			id: result.response.audio.id,
			expiresAt: result.response.audio.expiresAt,
			data: result.response.audio.data,
			blobRef: result.response.audio.blobRef,
			transcript: result.response.audio.transcript,
			format: result.response.audio.format,
			sampleRate: result.response.audio.sampleRate,
			channels: result.response.audio.channels,
			duration: result.response.audio.duration
		} : void 0,
		video: result.response?.video ? {
			id: result.response.video.id,
			blobRef: result.response.video.blobRef,
			storageRef: result.response.video.storageRef,
			url: result.response.video.url,
			format: result.response.video.format,
			size: result.response.video.size,
			duration: result.response.video.duration,
			thumbnail: result.response.video.thumbnail,
			spritesheet: result.response.video.spritesheet,
			model: result.response.video.model,
			aspectRatio: result.response.video.aspectRatio,
			resolution: result.response.video.resolution
		} : void 0
	};
}
function convertTestResultsToTableRow(results, varsForHeader) {
	const row = {
		description: results[0].description || void 0,
		outputs: [],
		vars: results[0].testCase.vars ? Object.values(varsForHeader).map((varName) => {
			const varValue = results[0].testCase.vars?.[varName] || "";
			if (typeof varValue === "string") return varValue;
			return JSON.stringify(varValue);
		}).flat() : [],
		test: results[0].testCase,
		testIdx: results[0].testIdx
	};
	for (const result of results) row.outputs[result.promptIdx] = convertEvalResultToTableCell(result);
	return row;
}

//#endregion
export { convertTestResultsToTableRow as t };
//# sourceMappingURL=exportToFile-B1s42t-e.js.map