/*
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","../techniques/utils","../../../../webgl/enums"],(function(e,t,a,o,r,i,n,s){"use strict";function y(e){const t={geometry:[{location:0,name:"a_pos",count:2,type:s.DataType.SHORT},{location:1,name:"a_id",count:3,type:s.DataType.UNSIGNED_BYTE},{location:2,name:"a_bitset",count:1,type:s.DataType.UNSIGNED_BYTE},{location:3,name:"a_color",count:4,type:s.DataType.UNSIGNED_BYTE,normalized:!0},{location:4,name:"a_aux1",count:4,type:s.DataType.UNSIGNED_SHORT},{location:5,name:"a_aux2",count:4,type:s.DataType.SHORT},{location:6,name:"a_aux3",count:4,type:s.DataType.UNSIGNED_BYTE},{location:7,name:"a_zoomRange",count:2,type:s.DataType.UNSIGNED_SHORT}]};switch(e.symbologyType){case a.WGLSymbologyType.SIMPLE:case a.WGLSymbologyType.OUTLINE_FILL_SIMPLE:t.geometry.splice(7,1),t.geometry.splice(4,1)}return{shader:"materials/fill",vertexLayout:t}}let l=function(r){function l(){return r.apply(this,arguments)||this}e._inheritsLoose(l,r);var u=l.prototype;return u.dispose=function(){},u.getGeometryType=function(){return a.WGLGeometryType.FILL},u.supportsSymbology=function(e){return e!==a.WGLSymbologyType.DOT_DENSITY},u.drawGeometry=function(e,a,r,l){const{context:u,painter:c,rendererInfo:m,requiredLevel:p,passOptions:T,requestRender:_}=e,f=i.FillMaterialKey.load(r.materialKey),g=n.getTechniqueFromMaterialKey(f.data),S=t.isSome(T)&&"hittest"===T.type,d=c.materialManager,{shader:E,vertexLayout:D,hittestAttributes:N}=t.unwrapOr(g.programSpec,y(f));let L=s.PrimitiveType.TRIANGLES,h=o.createProgramDescriptor(f.data,D);S&&(h=this._getTriangleDesc(r.materialKey,h,N),L=s.PrimitiveType.POINTS);const{attributes:G,bufferLayouts:I}=h,U=d.getMaterialProgram(e,f,E,G,l);if(t.isSome(_)&&!S&&!U.isCompiled)return void _();if(u.useProgram(U),this._setSharedUniforms(U,e,a),U.setUniform2f("u_tileOffset",512*a.key.col,512*a.key.row),f.textureBinding){c.textureManager.bindTextures(u,U,f);const e=1/2**(p-a.key.level);U.setUniform1f("u_zoomFactor",e)}const b=1/e.pixelRatio;U.setUniform1f("u_blur",b),U.setUniform1f("u_antialiasing",b),this._setSizeVVUniforms(f,U,m,a),this._setColorAndOpacityVVUniforms(f,U,m);const x=r.target.getVAO(u,I,G,S);let O=r.indexCount,P=r.indexFrom*Uint32Array.BYTES_PER_ELEMENT;S&&(O/=3,P/=3),u.bindVAO(x),this._drawFills(e,a,U,L,O,P)},u._drawFills=function(e,t,a,o,r,i){e.context.drawElements(o,r,s.DataType.UNSIGNED_INT,i)},l}(r);return l}));
