import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs';
import { dirname } from 'node:path';
const fsStorage = {
    ensureDir(path) {
        mkdirSync(path, { recursive: true });
    },
    writeFile(path, content) {
        mkdirSync(dirname(path), { recursive: true });
        writeFileSync(path, content, 'utf8');
    },
    readFile(path) {
        return readFileSync(path, 'utf8');
    },
    exists(path) {
        return existsSync(path);
    },
};
let activeStorage = fsStorage;
export function setSessionStorage(storage) {
    activeStorage = storage;
}
export function getSessionStorage() {
    return activeStorage;
}
export function createInMemorySessionStorage() {
    const files = new Map();
    return {
        ensureDir(_path) {
            // no-op for memory
        },
        writeFile(path, content) {
            files.set(path, content);
        },
        readFile(path) {
            const content = files.get(path);
            if (content === undefined) {
                throw new Error(`File not found: ${path}`);
            }
            return content;
        },
        exists(path) {
            return files.has(path);
        },
    };
}
//# sourceMappingURL=sessionStorage.js.map