/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{maxMapSizeGpu as t}from"../../../../../../../../../layers/raster/functions/pixelUtils.js";import{step as e,Vec3 as n,sign as r,dot as l,abs as g,Vec4 as o,floor as u,Float as i,mix as s}from"../../../../graph/glsl.js";function c(t){const e=r(t),n=t.add(g(e).subtract(1));return e.multiply(e).divide(n)}function w(t){return new o(u(t.rgb.add(.5)),t.a)}function a(t,n){return e(n.x,t).multiply(e(t,n.y))}function d(g,o){let u=new n(0,0,0);const i=new n(g);for(let r=0;r<t/3;r++){const t=6*r,l=new n(o.get(t),o.get(t+2),o.get(t+4)),g=new n(o.get(t+1),o.get(t+3),o.get(t+5));u=u.add(e(l,i).multiply(e(i,g)))}return r(l(u,new n(1,1,1)))}function f(t,g,o){const u=new n(t);let c=new n(0,0,0),w=new i(0);for(let r=0;r<o/3;r++){const t=9*r,l=new n(g.get(t),g.get(t+3),g.get(t+6)),o=new n(g.get(t+1),g.get(t+4),g.get(t+7)),i=e(l,u).multiply(e(u,o)),a=new n(g.get(t+2),g.get(t+5),g.get(t+8));w=s(w,a.x,i.x),w=s(w,a.y,i.y),w=s(w,a.z,i.z),c=c.add(i)}return{mapValue:w,includeMask:r(l(c,new n(1,1,1)))}}export{f as computeMapValue,d as computeSingleBandRangeFactor,a as getRangeClipFactor,c as invertValue,w as roundOutput};
