"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SnippetCache = void 0;
class SnippetCache {
    constructor(options) {
        this.options = options;
        this.cache = new Map();
    }
    async getSnippet(snippetId) {
        if (this.cache.has(snippetId)) {
            return this.cache.get(snippetId);
        }
        try {
            const snippet = await this.options.apiClient.getSnippet(snippetId, false, true, this.options.workspaceId);
            this.cache.set(snippetId, snippet);
            return snippet;
        }
        catch {
            return undefined;
        }
    }
    setSnippet(snippetId, snippet) {
        this.cache.set(snippetId, snippet);
    }
    getCachedSnippets() {
        return Object.fromEntries(this.cache);
    }
}
exports.SnippetCache = SnippetCache;
