export class ReportExporter {
    now;
    constructor(now = () => new Date()) {
        this.now = now;
    }
    create(name, data) {
        const trimmed = name.trim();
        if (trimmed.length === 0) {
            throw new Error("Report name is required");
        }
        return {
            generatedAt: this.now().toISOString(),
            name: trimmed,
            data
        };
    }
    toJson(report) {
        return `${JSON.stringify(report, sortKeys, 2)}\n`;
    }
}
function sortKeys(_key, value) {
    if (value === null || Array.isArray(value) || typeof value !== "object") {
        return value;
    }
    return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)));
}
//# sourceMappingURL=ReportExporter.js.map