/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import e from"../../../../request.js";import r from"../../../../core/Logger.js";import{isAborted as t,createAbortError as s}from"../../../../core/promiseUtils.js";import{isRefreshableLayer as i}from"../../../../layers/mixins/RefreshableLayer.js";import{useFetchTileForLayer as o}from"../../terrain/terrainUtils.js";async function a(a,m,l){const n=a.layer;if(o(n)){const e=await n.fetchTile(m[0],m[1],m[2],l);if(t(l))throw r.getLogger(a).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),s();return e}let f=a.getTileUrl(m);return i(n)&&n.refreshTimestamp&&(f+=`${f.includes("?")?"&":"?"}_ts=${n.refreshTimestamp}`),(await e(f,{...l,responseType:"image",imageWithType:a.hasMixedImageFormats})).data}export{a as fetchTile};
