/**
 * A cache for inflight requests to the Management Api. Use this class to cache requests and avoid duplicate calls.
 * @class UmbManagementApiInflightRequestCache
 * @template ResponseModelType
 */
export class UmbManagementApiInFlightRequestCache {
    #entries = new Map();
    /**
     * Checks if an entry exists in the cache
     * @param {string} key - The ID of the entry to check
     * @returns {boolean} - True if the entry exists, false otherwise
     * @memberof UmbManagementApiInflightRequestCache
     */
    has(key) {
        return this.#entries.has(key);
    }
    /**
     * Adds an entry to the cache
     * @param {string} key - A unique key representing the promise
     * @param {Promise<UmbApiResponse<RequestResolvedType<ResponseModelType>>>} promise - The promise to cache
     * @memberof UmbManagementApiInflightRequestCache
     */
    set(key, promise) {
        this.#entries.set(key, {
            key,
            requestPromise: promise,
            timestamp: new Date().toISOString(),
        });
    }
    /**
     * Retrieves an entry from the cache
     * @param {string} key - The ID of the entry to retrieve
     * @returns {Promise<RequestResolvedType<ResponseModelType>> | undefined} - The cached promise or undefined if not found
     * @memberof UmbManagementApiInflightRequestCache
     */
    get(key) {
        return this.#entries.get(key);
    }
    /**
     * Deletes an entry from the cache
     * @param {string} key - The ID of the entry to delete
     * @memberof UmbManagementApiInflightRequestCache
     */
    delete(key) {
        this.#entries.delete(key);
    }
    /**
     * Clears all entries from the cache
     * @memberof UmbManagementApiInflightRequestCache
     */
    clear() {
        this.#entries.clear();
    }
}
