/*
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","../enums","../Utils","./WGLGeometryBrush","../materialKey/MaterialKey","../../../../webgl/enums"],(function(e,t,a,n,o,i,r){"use strict";const s=e=>n.createProgramDescriptor(e.data,{geometry:[{location:0,name:"a_pos",count:2,type:r.DataType.SHORT},{location:1,name:"a_id",count:4,type:r.DataType.UNSIGNED_BYTE},{location:2,name:"a_color",count:4,type:r.DataType.UNSIGNED_BYTE,normalized:!0},{location:3,name:"a_haloColor",count:4,type:r.DataType.UNSIGNED_BYTE,normalized:!0},{location:4,name:"a_texAndSize",count:4,type:r.DataType.UNSIGNED_BYTE},{location:5,name:"a_refSymbolAndPlacementOffset",count:4,type:r.DataType.UNSIGNED_BYTE},{location:6,name:"a_glyphData",count:4,type:r.DataType.UNSIGNED_BYTE},{location:7,name:"a_vertexOffset",count:2,type:r.DataType.SHORT},{location:8,name:"a_texCoords",count:2,type:r.DataType.UNSIGNED_SHORT}]});let l=function(n){function o(){return n.apply(this,arguments)||this}e._inheritsLoose(o,n);var l=o.prototype;return l.dispose=function(){},l.getGeometryType=function(){return a.WGLGeometryType.LABEL},l.supportsSymbology=function(e){return!0},l.drawGeometry=function(e,a,n,o){const{context:l,painter:m,state:p,rendererInfo:u,passOptions:y,requestRender:c}=e,f=i.LabelMaterialKey.load(n.materialKey),d=t.isSome(y)&&"hittest"===y.type,T=f.mapAligned?1:0;if(!T&&Math.abs(a.key.level-Math.round(100*e.displayLevel)/100)>=1)return;const{bufferLayouts:_,attributes:E}=s(f),S=m.materialManager.getMaterialProgram(e,f,"materials/label",E,o);if(t.isSome(c)&&!d&&!S.isCompiled)return void c();e.context.setStencilFunction(r.CompareFunction.EQUAL,0,255),l.useProgram(S),this._setSharedUniforms(S,e,a),m.textureManager.bindTextures(l,S,f);const N=1===T?p.displayViewMat3:p.displayMat3;this._setSizeVVUniforms(f,S,u,a),S.setUniform1f("u_mapRotation",Math.floor(p.rotation/360*254)),S.setUniform1f("u_mapAligned",T),S.setUniformMatrix3fv("u_displayMat3",N),S.setUniform1f("u_opacity",1),S.setUniform2fv("u_screenSize",e.state.size),S.setUniform1f("u_isHalo",1);const D=n.target.getVAO(l,_,E),U=n.indexFrom*Uint32Array.BYTES_PER_ELEMENT;l.bindVAO(D),l.drawElements(r.PrimitiveType.TRIANGLES,n.indexCount,r.DataType.UNSIGNED_INT,U),S.setUniform1f("u_isHalo",0),l.drawElements(r.PrimitiveType.TRIANGLES,n.indexCount,r.DataType.UNSIGNED_INT,U),l.setStencilTestEnabled(!0),l.setBlendingEnabled(!0)},o}(o);return l}));
