/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{isSome as o}from"../../../../../core/arrayUtils.js";import{disposable as r,makeHandle as t}from"../../../../../core/handleUtils.js";import{createResolver as s}from"../../../../../core/promiseUtils.js";class e{constructor(){this._previousActions=new Map}async lock(e){const{_previousActions:i}=this,l=e.map(o=>i.get(o)).filter(o),c=Promise.allSettled(l),a=s(),n=t(()=>a.resolve()),m=a.promise.finally(()=>{for(const o of e)i.get(o)===m&&i.delete(o)});for(const o of e)i.set(o,m);return await c,r(n)}}export{e as TileLocks};
