/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../../../../chunks/_rollupPluginBabelHelpers","../../../../../../core/Logger","../../../../../../core/screenUtils","../../../../../../symbols/cim/enums","../../color","../../definitions","../../number","../../Utils","../../materialKey/MaterialKey","./util","./WGLBaseLineTemplate","./WGLMeshTemplate"],(function(e,t,i,l,r,n,o,s,a,_,c,p){"use strict";const u=t.getLogger("esri.views.2d.engine.webgl.WGLLineTemplate");return function(t){function c(e,i,l,r,s,c,p,u,m,L,y,d,f,h,S,T,O,I,A,E){var M;M=t.call(this)||this;const P=a.LineMaterialKey.load(e);i&&(P.sdf=i.sdf,P.pattern=!0,P.textureBinding=i.textureBinding),M._capType=r,M._joinType=s,M._miterLimitCosine=_.getLimitCosine(c),M.tessellationProperties._fillColor=p,M.tessellationProperties._tl=u,M.tessellationProperties._br=m,M._hasPattern=L,M._isDashed=y,M._zOrder=O,M._effects=I,M._minMaxZoom=o.i1616to32(Math.round(A*n.MIN_MAX_ZOOM_PRECISION_FACTOR),Math.round(E*n.MIN_MAX_ZOOM_PRECISION_FACTOR)),M._materialKey=P.data;const N=h?n.BITSET_TYPE_FILL_OUTLINE:0,D=(f?n.BITSET_GENERIC_LOCK_COLOR:0)|N|(d?n.BITSET_LINE_SCALE_DASH:0)|(S?n.BITSET_GENERIC_CONSIDER_ALPHA_ONLY:0);return M.tessellationProperties._bitset=D,M.tessellationProperties._halfWidth=.5*l,M.tessellationProperties._halfReferenceWidth=.5*T,M.tessellationProperties.offset=0,M._initializeTessellator(!1),M}return e._inheritsLoose(c,t),c.fromCIMLine=function(e,t,s){const a=e.color,p=e.scaleFactor||1,u=!!e.dashTemplate;let m=e.cap;u&&m===l.CapType.ROUND&&(m=l.CapType.SQUARE);const L=e.join,y=i.pt2px(e.width)*p,d=i.pt2px(e.referenceWidth),f=i.pt2px(e.miterLimit),h=a&&r.premultiplyAlphaRGBA(a)||0,[S,T]=_.getMinMaxZoom(e.scaleInfo,s),O=!1;if(!t)return new c(e.materialKey,t,y,m,L,f,h,0,0,!1,u,e.scaleDash,e.colorLocked,O,e.sampleAlphaOnly,d,e.zOrder,e.effects,S,T);const{rect:I,width:A,height:E}=t,M=I.x+n.SPRITE_PADDING,P=I.y+n.SPRITE_PADDING,N=M+A,D=P+E,g=o.i1616to32(M,P),C=o.i1616to32(N,D),R=!1;return new c(e.materialKey,t,y,m,L,f,h,g,C,!0,u,e.scaleDash,e.colorLocked,R,e.sampleAlphaOnly,d,e.zOrder,e.effects,S,T)},c.fromFillOutline=function(e){var t;const i=a.FillMaterialKey.load(e.materialKey);return a.hasOutlineFillSymbology(i)&&e.outline&&"esriSLSSolid"===(null==(t=e.outline)?void 0:t.style)?c.fromSimpleLine({hash:"",materialKey:e.materialKey,...e.outline},null,!0):null},c.fromSimpleLine=function(e,t,l=!1){const{color:a}=e,p="esriSLSSolid"!==e.style&&"esriSLSNull"!==e.style,u=s.getCapType(e.cap||"round"),m=s.getJoinType(e.join||"round");let L=a&&"esriSLSNull"!==e.style&&r.premultiplyAlphaRGBAArray(a)||0;"esriSLSNull"===e.style&&(L=0);const y=i.pt2px(e.width),d=e.miterLimit;if(!t)return new c(e.materialKey,t,y,u,m,d,L,0,0,!1,p,!0,!1,l,!1,y,0,null,_.DEFAULT_MIN_ZOOM,_.DEFAULT_MAX_ZOOM);const{rect:f,width:h,height:S}=t,T=f.x+n.SPRITE_PADDING,O=f.y+n.SPRITE_PADDING,I=T+h,A=O+S,E=o.i1616to32(T,O),M=o.i1616to32(I,A);return new c(e.materialKey,t,y,u,m,d,L,E,M,!0,p,!0,!1,l,!1,y,0,null,_.DEFAULT_MIN_ZOOM,_.DEFAULT_MAX_ZOOM)},c.fromPictureLineSymbol=function(e,t,i,l){return u.error("PictureLineSymbol support does not exist!"),null},c}(c(p))}));
