/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import e from"../../request.js";import t from"../../geometry/Extent.js";import i from"../../geometry/Point.js";import r from"../../layers/support/RasterInfo.js";import s from"../../layers/support/RasterStorageInfo.js";import{parseUrl as a,encode as l,asValidOptions as o}from"../utils.js";async function n(n,m,p){const f=a(n),u=l({...f?.query,f:"json"}),h=o(u,p),d=`${f?.path}/${m}/info`,c=e(`${d}`,h),g=e(`${d}/keyProperties`,h),x=await Promise.allSettled([c,g]),y="fulfilled"===x[0].status?x[0].value.data:null,v="fulfilled"===x[1].status?x[1].value.data:null;let P=null;y.statistics?.length&&(P=y.statistics.map(e=>({min:e[0],max:e[1],avg:e[2],stddev:e[3]})));const S=t.fromJSON(y.extent),j=Math.ceil(S.width/y.pixelSizeX-.1),w=Math.ceil(S.height/y.pixelSizeY-.1),b=S.spatialReference,k=new i({x:y.pixelSizeX,y:y.pixelSizeY,spatialReference:b}),z=y.histograms?.length?y.histograms:null,L=new s({origin:y.origin,blockWidth:y.blockWidth,blockHeight:y.blockHeight,firstPyramidLevel:y.firstPyramidLevel,maximumPyramidLevel:y.maxPyramidLevel});return new r({width:j,height:w,bandCount:y.bandCount,extent:S,spatialReference:b,pixelSize:k,pixelType:y.pixelType.toLowerCase(),statistics:P,histograms:z,keyProperties:v,storageInfo:L})}export{n as getCatalogItemRasterInfo};
