/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import{maxMapSizeGpu as t}from"../../../../../../../../../layers/raster/functions/pixelUtils.js";import{uniform as o,define as r,UniformGroup as a}from"../../../../GraphShaderModule.js";import{mix as p,clamp as s,max as i,Vec4 as m,Vec3 as n,step as l,sign as c,dot as u,FixedArray as d,Float as g,Vec2 as h}from"../../../../graph/glsl.js";import{oneMinus as y}from"../../utils.js";import{BaseRasterProcessorShader as f}from"./BaseRasterProcessorShader.js";import{computeMapValue as v}from"./math.js";class j extends a{}e([o(d.ofType(g,3*t))],j.prototype,"rangeMaps",void 0),e([o(d.ofType(g,2*t))],j.prototype,"noDataRanges",void 0),e([o(g)],j.prototype,"unmatchMask",void 0),e([o(g)],j.prototype,"replacementValue",void 0),e([o(h)],j.prototype,"clampRange",void 0);class x extends f{constructor(){super(...arguments),this.type="RemapShader"}_process(e){const o=this._getPixel(e),{rangeMaps:r,unmatchMask:a,clampRange:n,replacementValue:l}=this.remapConfig,{mapValue:c,includeMask:u}=v(o.r,r,t),d=this.replaceUnmatched?l:a.multiply(o.r),g=p(d,c,u),h=s(g,n.x,n.y),y=this._computeNoDataFactor(o.rrr).multiply(i(a,u));return new m(h,h,h,o.a).multiply(y)}_computeNoDataFactor(e){const{noDataRanges:o}=this.remapConfig;let r=new n(0,0,0);for(let a=0;a<t/3;a++){const t=6*a,p=new n(o.get(t),o.get(t+2),o.get(t+4)),s=new n(o.get(t+1),o.get(t+3),o.get(t+5));r=r.add(l(p,e).multiply(l(e,s)))}return y(c(u(r,new n(1,1,1))))}}e([o(j)],x.prototype,"remapConfig",void 0),e([r],x.prototype,"replaceUnmatched",void 0);export{x as RemapShader};
