import fs from "node:fs";
import os from "node:os";
import path from "node:path";
export function getClaudeProjectSlug(projectPath) {
    return projectPath.replace(/[^a-zA-Z0-9]/g, "-");
}
export function getClaudeTranscriptDirForProfileDir(profileDir) {
    return path.join(os.homedir(), ".claude", "projects", getClaudeProjectSlug(profileDir));
}
export function getReferencedClaudeTranscriptIds(sessionFilePath) {
    if (!fs.existsSync(sessionFilePath)) {
        return [];
    }
    try {
        const raw = JSON.parse(fs.readFileSync(sessionFilePath, "utf-8"));
        const ids = [
            raw.sessionId,
            raw.generalSessionId,
            raw.codingSessionId,
        ].filter((value) => typeof value === "string" && value.length > 0);
        // Include recently-rotated session IDs so data collection captures them
        if (Array.isArray(raw.previousSessionIds)) {
            for (const entry of raw.previousSessionIds) {
                if (typeof entry === "object" && entry !== null &&
                    typeof entry.id === "string") {
                    ids.push(entry.id);
                }
            }
        }
        return [...new Set(ids)];
    }
    catch {
        return [];
    }
}
//# sourceMappingURL=claude-transcripts.js.map