/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
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 h,Vec2 as y}from"../../../../graph/glsl.js";import{oneMinus as f}from"../../utils.js";import{BaseRasterProcessorShader as g}from"./BaseRasterProcessorShader.js";import{computeMapValue as v}from"./math.js";class j extends a{}e([o(d.ofType(h,3*t))],j.prototype,"rangeMaps",void 0),e([o(d.ofType(h,2*t))],j.prototype,"noDataRanges",void 0),e([o(h)],j.prototype,"unmatchMask",void 0),e([o(h)],j.prototype,"replacementValue",void 0),e([o(y)],j.prototype,"clampRange",void 0);class x extends g{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),h=p(d,c,u),y=s(h,n.x,n.y),f=this._computeNoDataFactor(o.rrr).multiply(i(a,u));return new m(y,y,y,o.a).multiply(f)}_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[t],o[t+2],o[t+4]),s=new n(o[t+1],o[t+3],o[t+5]);r=r.add(l(p,e).multiply(l(e,s)))}return f(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};
