/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t,__param as i}from"tslib";import{location as e,uniform as s,input as l}from"../../GraphShaderModule.js";import{dot as o,Vec2 as a,Float as n,max as r,Vec4 as d,mix as m,length as p,clamp as u,Vec3 as y,step as c,min as h}from"../../graph/glsl.js";import{AAnimatedPolyShader as x,PolyHittestVertexInput as v,PolyVertexInput as f,PolyFragmentInput as w}from"./AAnimatedPolyShader.js";import{getValue as b}from"./AAnimatedShader.js";import{distPointSegment as g}from"../shaders/hittestUtils.js";import{getLineAntialiasing as S,getLineThinFactor as P,AntialiasingControls as z}from"../shaders/LineShader.js";class A extends f{}t([e(10,n)],A.prototype,"accumulatedDistance",void 0),t([e(11,a)],A.prototype,"normal",void 0),t([e(12,a)],A.prototype,"segmentDirection",void 0);class D extends w{}class j extends x{constructor(){super(...arguments),this.type="AnimatedLineShader"}vertex(t,i){const{animationPointerAndBaseSizeAndReferenceSize:e}=t,s=e.xy,{distanceToPx:l,ndc:p,z:u,color:y,isOutline:c,strokeWidth:h,isSDF:x,baseSize:v,scale:f,scaleSymbolsProportionally:w,evalParams:g}=this._vertexPoly(t),S=t.sizing.xy,P=S.x.multiply(v).divide(S.y),z=b(s,6,g).a,A=t.accumulatedDistance.subtract(z),{normal:D}=t,j=t.normal.y,C=A.divide(this.view.displayZoomFactor).add(o(t.segmentDirection,t.offset)).divide(P),F=j.add(1).divide(2),R=new a(C,F),W=t.tlbr.divide(this.mosaicInfo.size.xyxy),M=v.divide(2),O=new n(.5).multiply(this.antialiasingControls.antialiasing),T=r(M.add(O),new n(.45)).add(new n(.1).multiply(O));return{glPosition:new d(p,u,1),tlbr:W,uv:R,color:y.multiply(new n(1).subtract(c)),outlineColor:y.multiply(c),distanceToPx:l,strokeWidth:h.multiply(m(new n(1),f,w)),isOutline:c,isSDF:x,halfWidth:T,normal:D,...this.maybeRunHittest(t,i,T)}}fragment(t){const i=this._fragmentPoly(t),e=S(t,this.antialiasingControls.blur),{halfWidth:s,normal:l}=t,o=P(s),a=p(l).multiply(s),r=u(o.multiply(s.subtract(a)).divide(o.subtract(new n(1))),new n(0),new n(1));return this.getFragmentOutput(i.multiply(r).multiply(e),t)}hittest(t,i,e){const{viewMat3:s,tileMat3:l}=this.view,o=s.multiply(l),a=o.multiply(new y(t.pos,1)),n=o.multiply(new y(i.nextPos1,1)),r=o.multiply(new y(i.nextPos2,1)),{distance:d,smallSymbolDistance:m,smallSymbolSizeThreshold:p}=this.hittestRequest,u=c(e,p.multiply(.5)).multiply(d.subtract(m)),x=this.hittestRequest.position;return h(g(x,a.xy,n.xy),g(x,a.xy,r.xy)).subtract(e).add(u)}}t([s(z)],j.prototype,"antialiasingControls",void 0),t([i(0,l(A)),i(1,l(v))],j.prototype,"vertex",null),t([i(0,l(D))],j.prototype,"fragment",null);export{j as AnimatedLineShader};
