/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{toConst as t}from"../../../../core/compilerUtils.js";import{MemCachePool as s}from"../../../../core/MemCachePool.js";import i from"../../../../core/PooledArray.js";class e{constructor(t,e){this._last=new i,this._incarnation=0,this._cache=new s(t,e)}destroy(){this._last?.forAll(t=>t.dispose()),this._last?.prune(),this._last=null,this._cache.destroy()}set interactive(t){t&&!this._last?this._last=new i:t||(this._last?.forAll(t=>t.dispose()),this._last=null)}clean(){this._last?.filterInPlace(t=>!(t.incarnation<this._incarnation)||(this._cache.put(t.key,t),!1))}frame(){++this._incarnation}pop(t){if(this._last){const s=this._last.find(s=>s.key===t);if(s)return this._last.removeUnordered(s),s}return this._cache.pop(t)}put(t){t.incarnation=this._incarnation,this._last?this._last.push(t):this._cache.put(t.key,t)}get usedMemory(){return this._last?.reduce((t,s)=>t+s.usedMemory,0)??0}get last(){return t(this._last)}}export{e as FBOPool};
