/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import t from"../../request.js";import e from"../../core/Error.js";import{join as s}from"../../core/urlUtils.js";async function i({fieldName:i,statisticsInfo:a,errorContext:o,fieldsIndex:r,path:n,customParameters:l,apiKey:c,signal:f}){if(null==a)throw new e(`${o}:no-cached-statistics`,"Cached statistics are not available for this layer");const d=r.get(i);if(null==d)throw new e(`${o}:field-unexisting`,`Field '${i}' does not exist on the layer`);const h=a.find(t=>t.name===d.name);if(null==h)throw new e(`${o}:no-cached-statistics`,"Cached statistics for this attribute are not available");const m=s(n,h.href),{data:u}=await t(m,{query:{f:"json",...l,token:c},responseType:"json",signal:f});return u}export{i as fetchStatistics};
