import { callGraph } from "../lib/graph-client.js";
import { log, trunc } from "../lib/log.js";
import { shapeEvent } from "./calendar-list.js";
const FIELDS = "id,subject,start,end,location,attendees,isAllDay,organizer,bodyPreview,body,webLink";
export async function runCalendarEvent(config, args) {
    const eventId = args.eventId.trim();
    if (!eventId) {
        throw new Error("calendar-event: eventId is required.");
    }
    const startMs = Date.now();
    const raw = await callGraph(config, async (client) => {
        return (await client
            .api(`/me/events/${encodeURIComponent(eventId)}`)
            .select(FIELDS)
            .get());
    }, { tool: "calendar-event" });
    const base = shapeEvent(raw);
    const detail = {
        ...base,
        bodyPreview: (raw.bodyPreview ?? "").slice(0, 1024),
        body: (raw.body?.content ?? "").slice(0, 16384),
        webLink: raw.webLink ?? null,
    };
    log({
        event: "calendar-event",
        account: config.accountId,
        eventId: trunc(eventId, 12),
        elapsedMs: Date.now() - startMs,
    });
    return detail;
}
//# sourceMappingURL=calendar-event.js.map