/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as e}from"tslib";import{uniform as a,define as s,UniformGroup as t}from"../../../../GraphShaderModule.js";import{Vec4 as r,float as n,equal as i,Float as o,notEqual as c,lessThanEqual as b,lessThan as l,greaterThanEqual as u,greaterThan as p,xor as w,or as k,and as h,bitXor as m,Int as d,bitNot as g,bitRShift as y,bitShift as _,bitOr as f,bitAnd as R,tanh as v,tan as x,sinh as A,sin as O,cosh as q,cos as j,atan as B,ifElse as T,atanh as Z,asinh as M,asin as N,acosh as S,acos as C,abs as V,negate as G,mod as L,sign as P,floor as z,ceil as D,pow as E,exp as F,log2 as H,log as I,sqrt as J,mix as K,Vec2 as Q}from"../../../../graph/glsl.js";import{BaseRasterProcessorShader as U}from"./BaseRasterProcessorShader.js";import{getRangeClipFactor as W,roundOutput as X,invertValue as Y}from"./math.js";import{MultiRasterMixin as $}from"./MultiRasterMixin.js";class ee extends t{}e([a(Q)],ee.prototype,"domainRange",void 0);class ae extends($(U)){constructor(){super(...arguments),this.type="LocalShader",this.isOutputRounded=!1}_process(e){if("conditional"===this.operationName)return this._conditional(e);const{a,b:s,alpha:t}=this._getRasterValues(e),{value:r,alpha:n}=this._compute(a,s,t);return this._processResult(r,n)}_processResult(e,a){const s=W(e,this.domainRangeConfig.domainRange),t=new r(e,e,e,a).multiply(s);return this.isOutputRounded?X(t):t}_compute(e,a,s){const{operationName:t}=this;let r;switch(t){case"plus":r=e.add(a);break;case"minus":r=e.subtract(a);break;case"times":r=e.multiply(a);break;case"divide":case"floatdivide":r=e.multiply(Y(a)),s=s.multiply(n(V(P(a))));break;case"floordivide":r=z(e.multiply(Y(a))),s=s.multiply(n(V(P(a))));break;case"square":r=e.multiply(e);break;case"sqrt":r=J(e);break;case"power":r=E(e,a);break;case"ln":r=T(p(e,new o(0)),I(e),new o(0)),s=s.multiply(this._isAboveZero(e));break;case"log10":r=T(p(e,new o(0)),H(e).multiply(Y(H(new o(10)))),new o(0)),s=s.multiply(this._isAboveZero(e));break;case"log2":r=T(p(e,new o(0)),H(e),new o(0)),s=s.multiply(this._isAboveZero(e));break;case"exp":r=F(e);break;case"exp10":r=E(new o(10),e);break;case"exp2":r=E(new o(2),e);break;case"rounddown":r=z(e);break;case"roundup":r=D(e);break;case"int":r=P(e).multiply(z(V(e)));break;case"mod":r=L(e,a);break;case"negate":r=G(e);break;case"abs":r=V(e);break;case"acos":{const a=this._isAbsBiggerThanOne(e);r=T(a,new o(0),C(e)),s=T(a,new o(0),s);break}case"acosh":r=S(e);break;case"asin":{const a=this._isAbsBiggerThanOne(e);r=T(a,new o(0),N(e)),s=T(a,new o(0),s);break}case"asinh":r=M(e);break;case"atan":r=B(e);break;case"atanh":{const a=this._isAbsBiggerThanOne(e);r=T(a,new o(0),Z(e)),s=T(a,new o(0),s);break}case"atan2":r=B(e,a);break;case"cos":r=j(e);break;case"cosh":r=q(e);break;case"sin":r=O(e);break;case"sinh":r=A(e);break;case"tan":r=x(e);break;case"tanh":r=v(e);break;case"bitwiseand":r=new o(R(new d(e),new d(a)));break;case"bitwiseor":r=new o(f(new d(e),new d(a)));break;case"bitwiseleftshift":r=new o(_(new d(e),new d(a)));break;case"bitwiserightshift":r=new o(y(new d(e),new d(a)));break;case"bitwisenot":r=new o(g(new d(e)));break;case"bitwisexor":r=new o(m(new d(e),new d(a)));break;case"booleanand":r=n(h(c(e,new o(0)),c(a,new o(0))));break;case"booleanor":r=n(k(c(e,new o(0)),c(a,new o(0))));break;case"booleannot":r=n(i(e,new o(0)));break;case"booleanxor":r=n(w(c(e,new o(0)),c(a,new o(0))));break;case"greaterthan":r=n(p(e,a));break;case"greaterthanequal":r=n(u(e,a));break;case"lessthan":r=n(l(e,a));break;case"lessthanequal":r=n(b(e,a));break;case"equalto":r=n(i(e,a));break;case"notequal":r=n(c(e,a));break;case"isnull":r=n(i(s,new o(0))),s=new o(1);break;case"setnull":{const t=n(i(e,new o(0)));r=t.multiply(a),s=s.multiply(t);break}default:r=e}return{value:r,alpha:s}}_conditional(e){const{a,b:s,c:t,alpha:r}=this._getRasterValues(e),n=new o(V(P(a))),i=K(t,s,n);return this._processResult(i,r)}_isAboveZero(e){return n(p(e,new o(0)))}_isAbsBiggerThanOne(e){return p(V(e),new o(1))}}e([s],ae.prototype,"operationName",void 0),e([s],ae.prototype,"isOutputRounded",void 0),e([a(ee)],ae.prototype,"domainRangeConfig",void 0);export{ee as DomainRangeConfig,ae as LocalShader};
