/*
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/maybe","../../../../../../core/screenUtils","../../color","../../definitions","../../number","../../materialKey/MaterialKey","./util","./WGLBaseLineTemplate","./WGLDynamicMeshTemplate","../../util/Result"],(function(t,e,i,s,o,a,n,r,l,c,_){"use strict";return function(l){function c(t,n,c){var _;(_=l.call(this,t)||this)._minMaxZoom=a.i1616to32(Math.round(n*o.MIN_MAX_ZOOM_PRECISION_FACTOR),Math.round(c*o.MIN_MAX_ZOOM_PRECISION_FACTOR)),_._cimLineLayer=t;let h=0;r.isFunction(t.width)||(h=.5*i.pt2px(t.width));const p=(e,s,o)=>r.isFunction(t.width)?.5*i.pt2px(t.width(e,s,o)):h;_._dynamicPropertyMap.set("_halfWidth",p),r.isFunction(t.cap)?_._dynamicPropertyMap.set("_capType",t.cap):_._capType=t.cap,r.isFunction(t.join)?_._dynamicPropertyMap.set("_joinType",t.join):_._joinType=t.join;const m=t.color;if(r.isFunction(m)){const t=(t,e,i)=>s.premultiplyAlphaRGBA(m(t,e,i));_._dynamicPropertyMap.set("_fillColor",t)}else _._fillColor=m&&s.premultiplyAlphaRGBA(m)||0;const f=t.miterLimit;if(r.isFunction(f)){const t=(t,e,i)=>r.getLimitCosine(f(t,e,i));_._dynamicPropertyMap.set("_miterLimitCosine",t)}else _._miterLimitCosine=r.getLimitCosine(f);if(e.isSome(t.effects)){const e=t.effects;r.isFunction(e)?_._dynamicPropertyMap.set("_effects",e):_._effects=e}_._scaleFactor=t.scaleFactor||1,_._isDashed=null!=t.dashTemplate;const y=t.colorLocked?o.BITSET_GENERIC_LOCK_COLOR:0,u=t.scaleDash?o.BITSET_LINE_SCALE_DASH:0,d=t.sampleAlphaOnly?o.BITSET_GENERIC_CONSIDER_ALPHA_ONLY:0;return _.tessellationProperties._bitset=y|u|d,_._materialKey=t.materialKey,_._initializeTessellator(!0),_}return t._inheritsLoose(c,l),c.fromCIMLine=function(t,e){const[i,s]=r.getMinMaxZoom(t.scaleInfo,e);return new c(t,i,s)},c.prototype.bindFeature=function(t,e,i){const s=t.readLegacyFeature();this._dynamicPropertyMap.forEach(((t,o)=>{this[o]=t(s,e,i)})),this._halfWidth*=this._scaleFactor;const r=this._materialCache,l=(0,this._cimLineLayer.materialHash)(s,e,i),c=r.get(l);let h=null;if(c&&_.ok(c.spriteMosaicItem)&&(h=c.spriteMosaicItem),h){this._hasPattern=!0;const{rect:t,width:e,height:i}=h,s=t.x+o.SPRITE_PADDING,n=t.y+o.SPRITE_PADDING,r=s+e,l=n+i;this.tessellationProperties._tl=a.i1616to32(s,n),this.tessellationProperties._br=a.i1616to32(r,l)}else this._hasPattern=!1,this.tessellationProperties._tl=0,this.tessellationProperties._br=0;this.tessellationProperties._fillColor=this._fillColor,this.tessellationProperties._halfWidth=this._halfWidth,this.tessellationProperties.offset=0,this.tessellationProperties._halfReferenceWidth=this.tessellationProperties._halfWidth;const p=n.LineMaterialKey.load(this._materialKey);h&&(p.sdf=h.sdf,p.pattern=!0,p.textureBinding=h.textureBinding),this._materialKey=p.data},c}(l(c))}));
