import { LRUCache } from "../../../utils/LRUCache.js";

//#region src/elements/EFMedia/shared/GlobalInputCache.ts
/**
* Global cache for MediaBunny Input instances
* Shared across all MediaEngine instances to prevent duplicate decoding
* of the same segment data
*/
var GlobalInputCache = class {
	constructor() {
		this.cache = new LRUCache(50);
	}
	/**
	* Generate standardized cache key for Input objects
	* Format: "input:{src}:{segmentId}:{renditionId}"
	*/
	generateKey(src, segmentId, renditionId) {
		return `input:${src}:${segmentId}:${renditionId || "default"}`;
	}
	/**
	* Get cached Input object
	*/
	get(src, segmentId, renditionId) {
		const key = this.generateKey(src, segmentId, renditionId);
		return this.cache.get(key);
	}
	/**
	* Cache Input object
	*/
	set(src, segmentId, input, renditionId) {
		const key = this.generateKey(src, segmentId, renditionId);
		this.cache.set(key, input);
	}
	/**
	* Check if Input is cached
	*/
	has(src, segmentId, renditionId) {
		const key = this.generateKey(src, segmentId, renditionId);
		return this.cache.has(key);
	}
	/**
	* Clear all cached Input objects
	*/
	clear() {
		this.cache.clear();
	}
	/**
	* Get cache statistics for debugging
	*/
	getStats() {
		return {
			size: this.cache.size,
			cachedKeys: Array.from(this.cache.cache.keys())
		};
	}
};
const globalInputCache = new GlobalInputCache();
globalThis.debugInputCache = globalInputCache;

//#endregion
export { globalInputCache };
//# sourceMappingURL=GlobalInputCache.js.map