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/has","./ShaderTranspiler"],function(h,k,l,g){return function(){function c(a,b,d,e,f){void 0===f&&(f={});this._glName=this._context=null;this._locations={};this._id=void 0;this._initialized=!1;this._fShader=this._vShader=null;this._defines={};this._nameToUniformLocation={};this._nameToAttribLocation={};this._nameToUniform1={};this._nameToUniform1v={};this._nameToUniform2={};this._nameToUniform3={};this._nameToUniform4={};this._nameToUniformMatrix3={};this._nameToUniformMatrix4=
  {};a||console.error("RenderingContext isn't initialized!");0===b.length&&console.error("Shaders source should not be empty!");this._context=a;this._vertexShaderSource=b;this._fragmentShaderSource=d;if(Array.isArray(f))for(a=0;a<f.length;a++)this._defines[f[a]]="1";else this._defines=f;this._id=c._nextId++;this._locations=e}Object.defineProperty(c.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0});Object.defineProperty(c.prototype,"glName",{get:function(){return this._glName},
  enumerable:!0,configurable:!0});Object.defineProperty(c.prototype,"locations",{get:function(){return this._locations},enumerable:!0,configurable:!0});c.prototype.getDefine=function(a){return this._defines[a]};c.prototype.dispose=function(){if(this._context){var a=this._context.gl;this._vShader&&(a.deleteShader(this._vShader),this._vShader=null);this._fShader&&(a.deleteShader(this._fShader),this._fShader=null);this._glName&&(a.deleteProgram(this._glName),this._glName=null);this._context=null}};c.prototype.initialize=
  function(){if(!this._initialized){this._vShader=this._loadShader(35633);this._fShader=this._loadShader(35632);this._vShader&&this._fShader||console.error("Error loading shaders!");var a=this._context.gl,b=a.createProgram();a.attachShader(b,this._vShader);a.attachShader(b,this._fShader);for(var d in this._locations)a.bindAttribLocation(b,this._locations[d],d);a.linkProgram(b);a.getProgramParameter(b,a.LINK_STATUS)||console.error("Could not initialize shader\nVALIDATE_STATUS: "+a.getProgramParameter(b,
  a.VALIDATE_STATUS)+", gl error ["+a.getError()+"]infoLog: "+a.getProgramInfoLog(b));this._glName=b;this._initialized=!0}};c.prototype.getUniformLocation=function(a){this.initialize();void 0===this._nameToUniformLocation[a]&&(this._nameToUniformLocation[a]=this._context.gl.getUniformLocation(this._glName,a));return this._nameToUniformLocation[a]};c.prototype.hasUniform=function(a){return null!==this.getUniformLocation(a)};c.prototype.getAttribLocation=function(a){this.initialize();void 0===this._nameToAttribLocation[a]&&
  (this._nameToAttribLocation[a]=this._context.gl.getAttribLocation(this._glName,a));return this._nameToAttribLocation[a]};c.prototype.setUniform1i=function(a,b){var d=this._nameToUniform1[a];if(void 0===d||b!==d)this._context.bindProgram(this),this._context.gl.uniform1i(this.getUniformLocation(a),b),this._nameToUniform1[a]=b};c.prototype.setUniform1iv=function(a,b){var d=this._nameToUniform1v[a];void 0!==d&&c._arraysEqual(b,d)||(this._context.bindProgram(this),this._context.gl.uniform1iv(this.getUniformLocation(a),
  b),void 0===d?this._nameToUniform1v[a]=c._arrayCopy(b):c._arrayAssign(b,d))};c.prototype.setUniform1f=function(a,b){var d=this._nameToUniform1[a];if(void 0===d||b!==d)this._context.bindProgram(this),this._context.gl.uniform1f(this.getUniformLocation(a),b),this._nameToUniform1[a]=b};c.prototype.setUniform1fv=function(a,b){var d=this._nameToUniform1v[a];void 0!==d&&c._arraysEqual(b,d)||(this._context.bindProgram(this),this._context.gl.uniform1fv(this.getUniformLocation(a),b),void 0===d?this._nameToUniform1v[a]=
  c._arrayCopy(b):c._arrayAssign(b,d))};c.prototype.setUniform2f=function(a,b,d){var c=this._nameToUniform2[a];if(void 0===c||b!==c[0]||d!==c[1])this._context.bindProgram(this),this._context.gl.uniform2f(this.getUniformLocation(a),b,d),void 0===c?this._nameToUniform2[a]=[b,d]:(c[0]=b,c[1]=d)};c.prototype.setUniform2fv=function(a,b){var d=this._nameToUniform2[a];void 0!==d&&c._arraysEqual(b,d)||(this._context.bindProgram(this),this._context.gl.uniform2fv(this.getUniformLocation(a),b),void 0===d?this._nameToUniform2[a]=
  c._arrayCopy(b):c._arrayAssign(b,d))};c.prototype.setUniform3f=function(a,b,d,c){var e=this._nameToUniform3[a];if(void 0===e||b!==e[0]||d!==e[1]||c!==e[2])this._context.bindProgram(this),this._context.gl.uniform3f(this.getUniformLocation(a),b,d,c),void 0===e?this._nameToUniform3[a]=[b,d,c]:(e[0]=b,e[1]=d,e[2]=c)};c.prototype.setUniform3fv=function(a,b){var d=this._nameToUniform3[a];void 0!==d&&c._arraysEqual(b,d)||(this._context.bindProgram(this),this._context.gl.uniform3fv(this.getUniformLocation(a),
  b),void 0===d?this._nameToUniform3[a]=c._arrayCopy(b):c._arrayAssign(b,d))};c.prototype.setUniform4f=function(a,b,d,c,f){var e=this._nameToUniform4[a];if(void 0===e||b!==e[0]||d!==e[1]||c!==e[2]||f!==e[3])this._context.bindProgram(this),this._context.gl.uniform4f(this.getUniformLocation(a),b,d,c,f),void 0===e?this._nameToUniform4[a]=[b,d,c,f]:(e[0]=b,e[1]=d,e[2]=c,e[3]=f)};c.prototype.setUniform4fv=function(a,b){var d=this._nameToUniform4[a];void 0!==d&&c._arraysEqual(b,d)||(this._context.bindProgram(this),
  this._context.gl.uniform4fv(this.getUniformLocation(a),b),void 0===d?this._nameToUniform4[a]=c._arrayCopy(b):c._arrayAssign(b,d))};c.prototype.setUniformMatrix3fv=function(a,b,d){void 0===d&&(d=!1);var e=this._nameToUniformMatrix3[a];void 0!==e&&(9===e.length?c._matrix3Equal(e,b):c._arraysEqual(b,e))||(this._context.bindProgram(this),this._context.gl.uniformMatrix3fv(this.getUniformLocation(a),d,b),void 0===e?this._nameToUniformMatrix3[a]=c._arrayCopy(b):c._arrayAssign(b,e))};c.prototype.setUniformMatrix4fv=
  function(a,b,d){void 0===d&&(d=!1);var e=this._nameToUniformMatrix4[a];void 0!==e&&(16===e.length?c._matrix4Equal(e,b):c._arraysEqual(b,e))||(this._context.bindProgram(this),this._context.gl.uniformMatrix4fv(this.getUniformLocation(a),d,b),void 0===e?this._nameToUniformMatrix4[a]=c._arrayCopy(b):c._arrayAssign(b,e))};c._padToThree=function(a){var b=a.toString();1E3>a&&(b=("  "+a).slice(-3));return b};c.prototype._addLineNumbers=function(a){var b=2;return a.replace(/\n/g,function(){return"\n"+c._padToThree(b++)+
  ":"})};c.prototype._loadShader=function(a){var b=35633===a,d=b?this._vertexShaderSource:this._fragmentShaderSource,c;c="";for(var f in this._defines)c+="#define "+f+" "+this._defines[f]+"\n";c+=d;"webgl2"===this._context.contextVersion&&(c=g.transpileShader(c,b?"vertex":"fragment"));b=this._context.gl;a=b.createShader(a);b.shaderSource(a,c);b.compileShader(a);b.getShaderParameter(a,b.COMPILE_STATUS)||(console.error(b.getShaderInfoLog(a)),console.error(this._addLineNumbers(c)),"webgl2"===this._context.contextVersion&&
  (console.log("Shader source before transpilation:"),console.log(d)));return a};c._matrix4Equal=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&&a[4]===b[4]&&a[5]===b[5]&&a[6]===b[6]&&a[7]===b[7]&&a[8]===b[8]&&a[9]===b[9]&&a[10]===b[10]&&a[11]===b[11]&&a[12]===b[12]&&a[13]===b[13]&&a[14]===b[14]&&a[15]===b[15]};c._matrix3Equal=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&&a[4]===b[4]&&a[5]===b[5]&&a[6]===b[6]&&a[7]===b[7]&&a[8]===b[8]};c._arraysEqual=
  function(a,b){if(a.length!==b.length)return!1;for(var c=0;c<a.length;++c)if(a[c]!==b[c])return!1;return!0};c._arrayCopy=function(a){for(var b=[],c=0;c<a.length;++c)b.push(a[c]);return b};c._arrayAssign=function(a,b){for(var c=0;c<a.length;++c)b[c]=a[c]};c._nextId=0;return c}()});