/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import e from"../../../../request.js";import{destroyMaybe as t}from"../../../../core/maybe.js";import{isAbortError as i}from"../../../../core/promiseUtils.js";import r from"../../tiling/TileKey.js";class l{constructor(e,t){this._tilemap=e,this._tileIndexUrl=t}destroy(){this._tilemap=t(this._tilemap),this._tileIndexPromise=null}async fetchTileIndex(t){return this._tileIndexPromise||(this._tileIndexPromise=e(this._tileIndexUrl,{query:{...t?.query}}).then(e=>e.data.index)),this._tileIndexPromise}dataKey(e,t){const{level:l,row:s,col:o}=e,n=new r(e);return this._tilemap.fetchAvailabilityUpsample(l,s,o,n,t).then(()=>(n.world=e.world,n)).catch(e=>{if(i(e))throw e;return null})}}export{l as default};
