/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import{property as e,subclass as s}from"../../../core/accessorSupport/decorators.js";import n from"./BaseRasterFunction.js";import r from"./CompositeBandFunctionArguments.js";import{compositeBands as o}from"./pixelUtils.js";let i=class extends n{constructor(){super(...arguments),this.functionName="CompositeBand",this.functionArguments=null,this.rasterArgumentNames=["rasters"]}_bindSourceRasters(){const{sourceRasterInfos:t}=this,e=t[0];this.outputPixelType=this._getOutputPixelType(e.pixelType);const s=e.clone();if(s.attributeTable=null,s.colormap=null,s.pixelType=this.outputPixelType,s.bandCount=t.map(({bandCount:t})=>t).reduce((t,e)=>t+e),t.every(({statistics:t})=>null!=t&&t.length)){const e=[];t.forEach(({statistics:t})=>null!=t&&e.push(...t)),s.statistics=e}if(t.every(({histograms:t})=>null!=t&&t.length)){const e=[];t.forEach(({histograms:t})=>null!=t&&e.push(...t)),s.histograms=e}s.multidimensionalInfo&&s.multidimensionalInfo.variables.forEach(e=>{const s=t.map(t=>t.multidimensionalInfo?.variables.find(({name:t})=>t===e.name)),n=s.map(t=>t?.statistics?.length?t.statistics:null),r=s.map(t=>t?.histograms?.length?t.histograms:null);e.statistics=n.every(t=>null!=t)?n.flat():null,e.histograms=r.every(t=>null!=t)?r.flat():null}),s.bandCount>1&&(s.colormap=null,s.attributeTable=null);const n=t.every(t=>t.keyProperties.BandProperties?.length)?t.flatMap(t=>t.keyProperties.BandProperties):void 0;s.keyProperties={...s.keyProperties,BandProperties:n},this.rasterInfo=s;return{success:!0,supportsGPU:s.bandCount<=3}}_processPixels(t){const{pixelBlocks:e}=t;if(!e)return null;const s=e?.[0];return null==s?null:o(e)}_getWebGLParameters(){return{bandCount:this.rasterInfo.bandCount}}};t([e({json:{write:!0,name:"rasterFunction"}})],i.prototype,"functionName",void 0),t([e({type:r,json:{write:!0,name:"rasterFunctionArguments"}})],i.prototype,"functionArguments",void 0),t([e()],i.prototype,"rasterArgumentNames",void 0),i=t([s("esri.layers.raster.functions.CompositeBandFunction")],i);const a=i;export{a as default};
