/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as t,__param as e}from"tslib";import has from"../../../../../../../core/has.js";import{location as i,uniform as o,texture as r,input as s,UniformGroup as n}from"../../GraphShaderModule.js";import{Float as a,Vec2 as l,Vec4 as d,Sampler2D as p,ifElse as m,greaterThan as c,dot as u,min as h,length as y,mix as g,clamp as v,texture2D as w,step as f}from"../../graph/glsl.js";import{bitset as b}from"../line/gradientStrokeConstants.js";import{BaseHittestVertexInput as x}from"./AFeatureShader.js";import{LineVertexInput as S,LineShader as L,getLineVertexData as j,getLineAntialiasing as A,LineFragmentInput as D}from"./LineShader.js";import{MosaicInfo as z}from"./MosaicInfo.js";import{getBit as C,getBitBool as F,oneMinus as G}from"./utils.js";function P(t){return f(new a(0),t).multiply(2).subtract(1)}class I extends S{}t([i(9,a)],I.prototype,"accumulatedDistance",void 0),t([i(10,a)],I.prototype,"totalLength",void 0),t([i(11,a)],I.prototype,"gradientSize",void 0),t([i(12,l)],I.prototype,"segmentDirection",void 0),t([i(13,d)],I.prototype,"tlbr",void 0);class k extends D{}class q extends n{}t([o(a)],q.prototype,"isColorPass",void 0);class M extends L{constructor(){super(...arguments),this.type="GradientStrokeShader"}vertex(t,e){const{totalLength:i,gradientSize:o,segmentDirection:r,tlbr:s}=t,n=j(this,t),l=C(t.bitset,b.isAlongLine),d=i.divide(this.view.displayZoomFactor),p=m(F(t.bitset,b.isAbsoluteSize),()=>{const t=m(c(l,new a(.5)),d,n.halfWidth);return o.divide(t)},o),h=t.accumulatedDistance.add(u(r,n.scaledOffset).divide(d)),y=s.divide(this.mosaicInfo.size.xyxy);return{...n,tlbr:y,relativePositionAlongLine:h,relativeGradientSize:p,isAlongLine:C(t.bitset,b.isAlongLine),isDiscrete:C(t.bitset,b.isDiscrete),...this.maybeRunHittest(t,e,n.halfWidth)}}fragment(t){const{isAlongLine:e,isDiscrete:i,relativePositionAlongLine:o,relativeGradientSize:r,normal:s,tlbr:n}=t,d=A(t,this.antialiasingControls.blur),p=P(s.y).multiply(h(y(s),new a(1))),u=new a(.5).multiply(p).add(new a(.5)),b=m(c(e,new a(.5)),o,u),x=m(c(i,new a(.5)),r.subtract(1),new a(0));let S=b.add(x).divide(r);S=m(c(e,new a(.5)),S,G(S));const L=g(n.xy,n.zw,new l(v(S,new a(0),new a(1)),.5)),j=w(this.mosaicTexture,L),D=t.opacity.multiply(d),z=this.getFragmentOutput(j.multiply(D),t),C=f(new a(.5),this.technique.isColorPass).multiply(has("gradient-depth-epsilon")),F=f(new a(0),s.y).multiply(new a(has("gradient-depth-bias")).subtract(C));return z.glFragDepth=v(y(s).add(F),new a(0),new a(1)),z}}t([o(z)],M.prototype,"mosaicInfo",void 0),t([r(p)],M.prototype,"mosaicTexture",void 0),t([o(q)],M.prototype,"technique",void 0),t([e(0,s(I)),e(1,s(x))],M.prototype,"vertex",null);export{k as GradientStrokeFragmentInput,M as GradientStrokeShader,I as GradientStrokeVertexInput};
