/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../definitions","./parameters","../../shaders/HighlightPrograms","../../../../../webgl/BufferObject","../../../../../webgl/enums","../../../../../webgl/ProgramTemplate","../../../../../webgl/VertexArrayObject","../../../../../webgl/VertexElementDescriptor"],(function(e,r,i,t,s,o,_,u){"use strict";return function(){function n(){this._width=void 0,this._height=void 0,this._resources=null}var a=n.prototype;return a.dispose=function(){this._resources&&(this._resources.quadGeometry.dispose(),this._resources.quadVAO.dispose(),this._resources.highlightProgram.dispose(),this._resources.blurProgram.dispose(),this._resources=null)},a.preBlur=function(i,t){i.bindTexture(t,e.TEXTURE_BINDING_HIGHLIGHT_0),i.useProgram(this._resources.blurProgram),this._resources.blurProgram.setUniform4fv("u_direction",[1,0,1/this._width,0]),this._resources.blurProgram.setUniformMatrix4fv("u_channelSelector",r.ALPHA_TO_RGBA_CHANNEL_SELECTOR_MATRIX),i.bindVAO(this._resources.quadVAO),i.drawArrays(s.PrimitiveType.TRIANGLE_STRIP,0,4),i.bindVAO()},a.finalBlur=function(i,t){i.bindTexture(t,e.TEXTURE_BINDING_HIGHLIGHT_0),i.useProgram(this._resources.blurProgram),this._resources.blurProgram.setUniform4fv("u_direction",[0,1,0,1/this._height]),this._resources.blurProgram.setUniformMatrix4fv("u_channelSelector",r.RGBA_TO_RGBA_CHANNEL_SELECTOR_MATRIX),i.bindVAO(this._resources.quadVAO),i.drawArrays(s.PrimitiveType.TRIANGLE_STRIP,0,4),i.bindVAO()},a.renderHighlight=function(r,i,t){r.bindTexture(i,e.TEXTURE_BINDING_HIGHLIGHT_0),r.useProgram(this._resources.highlightProgram),t.applyHighlightOptions(r,this._resources.highlightProgram),r.bindVAO(this._resources.quadVAO),r.setBlendingEnabled(!0),r.setBlendFunction(s.BlendFactor.ONE,s.BlendFactor.ONE_MINUS_SRC_ALPHA),r.drawArrays(s.PrimitiveType.TRIANGLE_STRIP,0,4),r.bindVAO()},a._initialize=function(n,a,h){this._width=a,this._height=h;const c=t.BufferObject.createVertex(n,s.Usage.STATIC_DRAW,new Int8Array([-1,-1,0,0,1,-1,1,0,-1,1,0,1,1,1,1,1]).buffer),g=new _.VertexArrayObject(n,new Map([["a_position",0],["a_texcoord",1]]),{geometry:[new u.VertexElementDescriptor("a_position",2,s.DataType.BYTE,0,4),new u.VertexElementDescriptor("a_texcoord",2,s.DataType.UNSIGNED_BYTE,2,4)]},{geometry:c}),l=o.createProgram(n,i.highlight),m=o.createProgram(n,i.blur);n.useProgram(l),l.setUniform1i("u_texture",e.TEXTURE_BINDING_HIGHLIGHT_0),l.setUniform1i("u_shade",e.TEXTURE_BINDING_HIGHLIGHT_1),l.setUniform1f("u_sigma",r.SIGMA),n.useProgram(m),m.setUniform1i("u_texture",e.TEXTURE_BINDING_HIGHLIGHT_0),m.setUniform1f("u_sigma",r.SIGMA),this._resources={quadGeometry:c,quadVAO:g,highlightProgram:l,blurProgram:m}},a.setup=function(e,r,i){this._resources?(this._width=r,this._height=i):this._initialize(e,r,i)},n}()}));
