/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import{uniform as e,UniformGroup as n}from"../../../GraphShaderModule.js";import{Float as s,texture2D as i,Vec2 as o,Vec4 as r,FixedArray as d,sqrt as l,dot as g,Vec3 as p,abs as w,step as c}from"../../../graph/glsl.js";class u extends n{}function a(t){const e=w(t),n=c(e,new o(1,1)).multiply(e),i=new s(2).subtract(e),r=c(new s(1),e).multiply(i);return n.add(r)}function y(t,e,n){const l=new s(1).divide(n),g=i(t,a(l.multiply(new o(-1,-1)).add(e))),p=i(t,a(l.multiply(new o(0,-1)).add(e))),w=i(t,a(l.multiply(new o(1,-1)).add(e))),c=i(t,a(l.multiply(new o(-1,0)).add(e))),u=i(t,a(e)),y=i(t,a(l.multiply(new o(1,0)).add(e))),m=i(t,a(l.multiply(new o(-1,1)).add(e))),f=i(t,a(l.multiply(new o(0,1)).add(e))),Z=i(t,a(l.multiply(new o(1,1)).add(e))),x=new r(g.a,p.a,w.a,c.a),z=new r(y.a,m.a,f.a,Z.a),A=x.multiply(z),h=A.xy.multiply(A.zw),v=h.x.multiply(h.y).multiply(u.a);let b=new d(new s(0),10);return b=b.set(0,g.r),b=b.set(1,p.r),b=b.set(2,w.r),b=b.set(3,c.r),b=b.set(4,u.r),b=b.set(5,y.r),b=b.set(6,m.r),b=b.set(7,f.r),b=b.set(8,Z.r),b=b.set(9,v),b}function m(t,e){const n=new r(t.get(5),t.get(3),t.get(7),t.get(1)).multiply(2),s=new p(t.get(2),n[0],t.get(8)),i=new p(t.get(0),n[1],t.get(6)),d=g(s.subtract(i),new p(1)),l=new p(t.get(6),n[2],t.get(8)),w=new p(t.get(0),n[3],t.get(2)),c=g(l.subtract(w),new p(1));return new o(d,c).multiply(e)}function f(t,e,n){const{factor:i}=e,o=m(t,i),d=l(g(o,o).add(1)),w=t.get(9),{sinZsinAs:c,sinZcosAs:u,cosZs:a,weights:y}=e;if(!n){const t=Z({sinZsinA:c.get(0),sinZcosA:u.get(0),cosZ:a.get(0),weights:new s(1),dzxy:o,dzd:d});return new r(t,t,t,w)}const f=Z({sinZsinA:new p(c.get(0),c.get(1),c.get(2)),sinZcosA:new p(u.get(0),u.get(1),u.get(2)),cosZ:new p(a.get(0),a.get(1),a.get(2)),weights:new p(y.get(0),y.get(1),y.get(2)),dzxy:o,dzd:d}),x=Z({sinZsinA:new p(c.get(3),c.get(4),c.get(5)),sinZcosA:new p(u.get(3),u.get(5),u.get(5)),cosZ:new p(a.get(3),a.get(4),a.get(5)),weights:new p(y.get(3),y.get(4),y.get(5)),dzxy:o,dzd:d}),z=g(f.add(x),new p(1));return new r(z,z,z,w)}function Z(t){const e=t.sinZsinA.multiply(t.dzxy.y),n=t.sinZcosA.multiply(t.dzxy.x),i=e.subtract(n),o=t.cosZ.add(i).divide(t.dzd);return o.multiply(c(new s(0),o)).multiply(t.weights)}function x(t,e){const{pixelSizeFactor:n}=t,s=[t.factor[0]/e[0],t.factor[1]/e[1]];if(n>0){const{zFactor:i,pixelSizePower:o,gcsFactor:r}=t,d=e[0]*r,l=e[1]*r;s[0]=(i+d**o*n)/(8*d),s[1]=(i+l**o*n)/(8*l)}return s}t([e(d.ofType(s,6))],u.prototype,"sinZcosAs",void 0),t([e(d.ofType(s,6))],u.prototype,"sinZsinAs",void 0),t([e(d.ofType(s,6))],u.prototype,"cosZs",void 0),t([e(d.ofType(s,6))],u.prototype,"weights",void 0),t([e(s)],u.prototype,"minValue",void 0),t([e(s)],u.prototype,"maxValue",void 0),t([e(o)],u.prototype,"factor",void 0);export{u as HillshadeConfig,m as computeDeltaZ,x as computeZFactor,y as getSurfaceValues,f as hillshade,a as mirror};
