/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as t}from"tslib";import{maxMapSizeGpu as e}from"../../../../../../../../../layers/raster/functions/pixelUtils.js";import{uniform as o,define as s,UniformGroup as r}from"../../../../GraphShaderModule.js";import{Vec3 as i,abs as a,sign as l,step as p,FixedArray as n,Float as u}from"../../../../graph/glsl.js";import{BaseRasterProcessorShader as m}from"./BaseRasterProcessorShader.js";class c extends r{}t([o(n.ofType(u,6))],c.prototype,"includedRanges",void 0),t([o(n.ofType(u,e))],c.prototype,"noDataValues",void 0);class g extends m{constructor(){super(...arguments),this.type="MaskShader",this.isMultiband=!0}_process(t){const e=this._getPixel(t),o=this._computeNoDataFactor(e.r),s=this._computeRangeFactor(e.rgb);let r;if(this.isMultiband){const t=this._computeNoDataFactor(e.g),a=this._computeNoDataFactor(e.b),l=new i(o,t,a).multiply(s);r=l.x.multiply(l.y).multiply(l.z)}else r=o.multiply(s.x);return e.multiply(r)}_computeNoDataFactor(t){const{noDataValues:o}=this.maskConfig;let s=new i(1);for(let r=0;r<e/3;r++){const e=3*r,p=new i(o.get(e+0),o.get(e+1),o.get(e+2)),n=a(l(p.subtract(t)));s=s.multiply(n)}return s.x.multiply(s.y).multiply(s.z)}_computeRangeFactor(t){const{includedRanges:e}=this.maskConfig,o=new i(e.get(0),e.get(2),e.get(4)),s=new i(e.get(1),e.get(3),e.get(5));return p(o,t).multiply(p(t,s))}}t([s],g.prototype,"isMultiband",void 0),t([o(c)],g.prototype,"maskConfig",void 0);export{g as MaskShader};
