text: // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  // See https://js.arcgis.com/4.11/esri/copyright.txt for details.
  //>>built
  define("require exports ../../../../../../core/tsSupport/extendsHelper ../../../../../../core/Logger ../../../../../../core/screenUtils ../../color ../../definitions ../../enums ../../LineTess ../../number ../../TileClipper ../../Utils ../../WGLDisplayRecord ../../materialKey/MaterialKey ./WGLMeshTemplate".split(" "),function(B,N,S,T,J,O,P,r,f,t,U,Q,V,K,W){Object.defineProperty(N,"__esModule",{value:!0});var L=T.getLogger("esri.views.2d.engine.webgl.WGLLineTemplate"),G=f.allocTriangles(20),M=f.allocTriangles(20),
  H=[f.allocExtrudeVectors(),f.allocExtrudeVectors()],R=f.allocExtrudeVectors(),I=P.TILE_SIZE+8,h=new f.Tessellator({distanceAlongCorrection:!0}),F=new U.TileClipper(0,0,0,1,8);F.setExtent(P.TILE_SIZE);B=function(B){function k(c,b,a,e,d,p,g,l,y,f,q,k){var m=B.call(this)||this;m.width=a;m.capType=e;m.joinType=d;m.fillColor=p;m.tl=g;m.br=l;m.hasPattern=y;m.isDashed=f;m.isColorLocked=q;m.isOutline=k;m.geometryType=r.WGLGeometryType.LINE;c=K.LineMaterialKey.load(K.createMaterialKey(m.geometryType,c,k));
  b&&(c.sdf=b.sdf,c.pattern=!0,c.textureBinding=b.textureBinding);m._materialKey=c.data;m._bitset=q?1:0;return m}S(k,B);k.fromCIMLine=function(c,b,a,e){var d=b.color,p=b.isDashed,g=b.cap;p&&g===r.CapType.ROUND&&(g=r.CapType.SQUARE);var l=b.join,y=J.pt2px(b.width),d=d&&O.premultiplyAlphaRGBA(d)||0;if(!a)return new k(c,a,y,g,l,d,0,0,!1,p,b.colorLocked,e);var f=a.rect,q=f.x+1+a.width,h=f.y+1+a.height,f=t.i1616to32(f.x+1,f.y+1),q=t.i1616to32(q,h);return new k(c,a,y,g,l,d,f,q,!0,p,b.colorLocked,e)};k.fromSimpleLine=
  function(c,b,a,e){var d=a.color,p="solid"!==a.style&&"none"!==a.style,g=Q.getCapType(a.cap||"round",p),l=Q.getJoinType(a.join||"round"),d=d&&"none"!==a.style&&O.premultiplyAlphaRGBA(d)||0;"none"===a.style&&(d=0);if(!e)return new k(c,e,J.pt2px(a.width),g,l,d,0,0,!1,p,!1,b);var f=e.rect,h=f.x+1+e.width,q=f.y+1+e.height,f=t.i1616to32(f.x+1,f.y+1),h=t.i1616to32(h,q);return new k(c,e,J.pt2px(a.width),g,l,d,f,h,!0,p,!1,b)};k.fromPictureLineSymbol=function(c,b,a,e){L.error("PictureLineSymbol support does not exist!");
  return null};k.prototype.writeMesh=function(c,b,a,e,d,f,g,l){this.halfWidth=0<this.width?.5*(this.width+1/f):0;f=b.indexVector;var p=b.get("geometry"),h=b.get("visibility"),k=this.halfWidth,E=new V(e,this.geometryType,this._materialKey),m=K.LineMaterialKey.load(this._materialKey);b=b.getVector("geometry").vertexCount;E.vertexFrom=b;E.indexFrom=f.length;switch(a){case "esriGeometryPolyline":a=this._clipLines(d.geometry.paths);if(0===a.length)break;this._write(E,f,p,h,b,e,k,a,m,g,l);c.push(E);break;
  case "esriGeometryPolygon":a=this._clipLines(d.geometry.rings);if(0===a.length)break;this._write(E,f,p,h,b,e,k,a,m,g,l);c.push(E);break;default:L.error("Unable to handle geometryType: "+a)}};k.prototype._clipLines=function(c){for(var b=[],a=!1,e=0;e<c.length;){var d=[],f=c[e];F.reset(2);var g=f[0],l=g[0],g=g[1];if(a)F.moveTo(l,g);else{if(-8>l||l>I||-8>g||g>I){a=!0;continue}d.push({x:l,y:g})}for(var h=!1,k=f.length,q=1;q<k;++q)if(l+=f[q][0],g+=f[q][1],a)F.lineTo(l,g);else{if(-8>l||l>I||-8>g||g>I){h=
  !0;break}d.push({x:l,y:g})}if(h)a=!0;else{if(a){if(d=F.resultWithStarts())for(a=0;a<d.length;a++)b.push(d[a])}else b.push({line:d,start:0});e++;a=!1}}return b};k.prototype._write=function(c,b,a,e,d,k,g,l,y,r,q){for(var p=0,m=0;m<l.length;m++){var C=l[m],x=C.line;if(!(2>x.length))for(var n=x[0],u=x[x.length-1],D=u.x-n.x,n=u.y-n.y,D=1E-6>D*D+n*n,A=C.start%65535,C=H[1],n=0;n<x.length;n++){var z=x[n],u=C===H[n%2]?H[(n+1)%2]:H[n%2],v=0===n,w=n===x.length-1;w&&D&&!this.hasPattern?f.copyExtrudeVectors(u,
  R):(this._computeExtrudeVectors(u,n,x,D),p+=this._writeVertices(a,e,k,g,z.x,z.y,u,A,p,y,r,q),null==u.capCenter||D&&w||this._writePieIndices(c,b,d,u),D&&v&&!this.hasPattern&&f.copyExtrudeVectors(R,u));v||this._writeBridgeIndices(c,b,d,C,u);if(!w){var w=x[n+1],v=[w.x-z.x,w.y-z.y],t=f.length(v),v=[v[0]/t,v[1]/t],t=A+t;if(65535<t){var B=(65535-A)/(t-A),A=z.x+(w.x-z.x)*B,z=z.y+(w.y-z.y)*B,w=C;h.buttCap(w,v,v);p+=this._writeVertices(a,e,k,g,A,z,w,65535,p,y,r,q);h.bridge(G,u,w);this._writeBridgeIndices(c,
  b,d,u,w);h.buttCap(w,v,v);A=t-65535}else A=t,C=u}}}c.vertexCount=p};k.prototype._writeVertices=function(c,b,a,e,d,f,g,l,h,k,q,r){var m=0,p=t.i1616to32(d,f),x=g.vectors;g=x.items;for(x=x.count;m<x;++m){var n=g[m].vector,u=n[0],n=n[1],y=g[m].texCoords,A=y[0],z=y[1],v=g[m].direction,y=v[0],w=v[1],v=t.i1616to32(l,31*e),u=t.i8888to32(Math.round(31*u),Math.round(31*n),Math.round(31*A),Math.round(31*z)),n=t.i8888to32(Math.round(31*y),Math.round(31*w),0,this._bitset);c.push(p);c.push(a);c.push(this.fillColor);
  c.push(u);c.push(v);c.push(this.tl);c.push(this.br);c.push(n);this._writeVV(c,q,k);b.push(r);g[m].base={index:h+m,point:[d,f]}}return m};k.prototype._writeVV=function(c,b,a){a.hasVV()&&(c.push(b[r.VVType.SIZE]),c.push(b[r.VVType.COLOR]),c.push(b[r.VVType.OPACITY]))};k.prototype._writeBridgeIndices=function(c,b,a,e,d){h.bridge(G,e,d);for(e=0;e<G.count;++e)d=G.items[e],b.push(a+d.v1.base.index),b.push(a+d.v2.base.index),b.push(a+d.v3.base.index),c.indexCount+=3};k.prototype._writePieIndices=function(c,
  b,a,e){h.pie(M,e);for(e=0;e<M.count;++e){var d=M.items[e];b.push(a+d.v1.base.index);b.push(a+d.v2.base.index);b.push(a+d.v3.base.index);c.indexCount+=3}};k.prototype._computeExtrudeVectors=function(c,b,a,e){var d=a[b],h=[void 0,void 0],g=[void 0,void 0];if(0<b&&b<a.length-1){var l=a[(b+a.length-1)%a.length],k=a[(b+1)%a.length];f.normalize(h,[d.x-l.x,d.y-l.y]);f.normalize(g,[k.x-d.x,k.y-d.y])}else if(0===b)k=a[(b+1)%a.length],f.normalize(g,[k.x-d.x,k.y-d.y]),e?(l=a[a.length-2],f.normalize(h,[d.x-l.x,
  d.y-l.y])):h=g;else if(b===a.length-1)l=a[(b+a.length-1)%a.length],f.normalize(h,[d.x-l.x,d.y-l.y]),e?(l=a[1],f.normalize(g,[l.x-d.x,l.y-d.y])):g=h;else{console.error("Vertex index 'i' out of range.");return}e||0!==b?e||b!==a.length-1?this._computeJoinExtrudeVectors(c,h,g):this._computeCapExtrudeVectors(c,h,g,f.CapPosition.END):this._computeCapExtrudeVectors(c,h,g,f.CapPosition.START)};k.prototype._computeCapExtrudeVectors=function(c,b,a,e){switch(this.capType){case r.CapType.BUTT:h.buttCap(c,b,a);
  break;case r.CapType.ROUND:var d=f.getNumberOfSlices(Math.PI);h.roundCap(c,b,a,e,d,e===f.CapPosition.START?-1:1);break;case r.CapType.SQUARE:this.isDashed?h.squareCapForDashedLines(c,b,a,e):h.squareCap(c,b,a,e);break;default:L.error("Encountered unknown cap type: "+this.capType+", defaulting to BUTT"),h.buttCap(c,b,a)}};k.prototype._computeJoinExtrudeVectors=function(c,b,a){var e=f.getRads(b,a);if(e>Math.PI-.05)h.rectJoin(c,b,a);else if(this.joinType===r.JoinType.MITER||.1>e).05>e?h.fastMiterJoin(c,
  b,a):e<f.MITER_SAFE_RADS?h.miterJoin(c,b,a):h.bevelJoin(c,b,a,f.SYSTEM_MAG_LIMIT);else if(this.joinType===r.JoinType.BEVEL)h.bevelJoin(c,b,a,1);else if(this.joinType===r.JoinType.ROUND){var d=f.getNumberOfSlices(e);2.3>e?2>d||.5>e?h.bevelJoin(c,b,a,1):h.roundJoin(c,b,a,d):h.unitRoundJoin(c,b,a,d)}};return k}(W.default);N.default=B});