/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.24/esri/copyright.txt for details. */ import"../../core/has.js";import{isSome as e}from"../../core/maybe.js";import{ShaderType as t}from"./enums.js";import r from"./reservedWordsGLSL3.js";import{shaderTranspiler as a}from"./testUtils.js";var o,n={exports:{}};void 0!==(o=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"])&&(n.exports=o);const i=n.exports;var l,s={exports:{}};l=s,function(e){var t=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"];void 0!==t&&(l.exports=t)}();const c=s.exports;var d={exports:{}};!function(e){!function(t){var r=function(){return["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]}();void 0!==r&&(e.exports=r)}()}(d);const u=d.exports;var g=999,p=9999,f=0,_=1,h=2,x=3,m=4,y=5,w=6,M=7,v=8,T=9,b=10,P=11,E=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function C(){var e,t,r,a=0,o=0,n=g,l=[],s=[],d=1,C=0,k=0,j=!1,D=!1,F="";return function(e){return s=[],null!==e?S(e.replace?e.replace(/\r\n/g,"\n"):e):R()};function L(e){e.length&&s.push({type:E[n],data:e,position:k,line:d,column:C})}function S(t){var i;for(a=0,r=(F+=t).length;e=F[a],a0)continue;r=e.slice(0,1).join("")}return L(r),k+=r.length,(l=l.slice(r.length)).length}}function q(){return/[^a-fA-F0-9]/.test(e)?(L(l.join("")),n=g,a):(l.push(e),t=e,a+1)}function B(){return"."===e||/[eE]/.test(e)?(l.push(e),n=y,t=e,a+1):"x"===e&&1===l.length&&"0"===l[0]?(n=P,l.push(e),t=e,a+1):/[^\d]/.test(e)?(L(l.join("")),n=g,a):(l.push(e),t=e,a+1)}function H(){return"f"===e&&(l.push(e),t=e,a+=1),/[eE]/.test(e)||"-"===e&&/[eE]/.test(t)?(l.push(e),t=e,a+1):/[^\d]/.test(e)?(L(l.join("")),n=g,a):(l.push(e),t=e,a+1)}function N(){if(/[^\d\w_]/.test(e)){var r=l.join("");return n=i.indexOf(r)>-1?v:u.indexOf(r)>-1?M:w,L(l.join("")),n=g,a}return l.push(e),t=e,a+1}}function k(e){var t=C(),r=[];return r=(r=r.concat(t(e))).concat(t(null))}function j(e){return k(e)}function D(e){return e.map((e=>"eof"!==e.type?e.data:"")).join("")}const F=["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"];function L(e,t="100",r="300 es"){const a=/^\s*\#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const o of e)if("preprocessor"===o.type){const e=a.exec(o.data);if(e){const a=e[1].replace(/\s\s+/g," ");if(a===r)return a;if(a===t)return o.data="#version "+r,t;throw new Error("unknown glsl version: "+a)}}return e.splice(0,0,{type:"preprocessor",data:"#version "+r},{type:"whitespace",data:"\n"}),null}function S(e,t){for(let r=t-1;r>=0;r--){const t=e[r];if("whitespace"!==t.type&&"block-comment"!==t.type){if("keyword"!==t.type)break;if("attribute"===t.data||"in"===t.data)return!0}}return!1}function R(e,t,r,a){a=a||r;for(const o of e)if("ident"===o.type&&o.data===r){a in t?t[a]++:t[a]=0;return R(e,t,a+"_"+t[a],a)}return r}function V(e,t,r="afterVersion"){function a(e,t){for(let r=t;rt=0;--e){const t=i[e];if("preprocessor"===t.type){const r=t.data.match(/\#extension\s+(.*)\:/);if(r&&r[1]&&F.includes(r[1].trim())){const t=i[e+1];i.splice(e,t&&"whitespace"===t.type?2:1)}const a=t.data.match(/\#ifdef\s+(.*)/);a&&a[1]&&F.includes(a[1].trim())&&(t.data="#if 1");const o=t.data.match(/\#ifndef\s+(.*)/);o&&o[1]&&F.includes(o[1].trim())&&(t.data="#if 0")}}return q(a,D(i))}const O=new Map;function U(e){return a.enableCache?O.get(e):null}function q(e,t){return a.enableCache&&O.set(e,t),t}export{I as transpileShader};