/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../core/maybe","../core/shaderLibrary/ShaderOutputOptions","../core/shaderTechnique/ReloadableShaderModule","../core/shaderTechnique/ShaderTechnique","../lib/basicInterfaces","../lib/OrderIndependentTransparency","../lib/Program","../lib/RenderSlot","../lib/StencilUtils","../lib/VertexAttribute","../../../../chunks/RibbonLine.glsl","../../../webgl/enums","../../../webgl/renderState"],(function(e,t,i,r,n,s,l,a,o,p,u,c,h,d,P,T){"use strict";const f=new Map([[h.VertexAttribute.POSITION,0],[h.VertexAttribute.SUBDIVISIONFACTOR,1],[h.VertexAttribute.UV0,2],[h.VertexAttribute.AUXPOS1,3],[h.VertexAttribute.AUXPOS2,4],[h.VertexAttribute.COLOR,5],[h.VertexAttribute.COLORFEATUREATTRIBUTE,5],[h.VertexAttribute.SIZE,6],[h.VertexAttribute.SIZEFEATUREATTRIBUTE,6],[h.VertexAttribute.OPACITYFEATUREATTRIBUTE,7]]);let b=function(e){function t(t,i,r){var n;return(n=e.call(this,t,i,r)||this).stippleTextureRepository=t.stippleTextureRepository,n}i._inheritsLoose(t,e);var s=t.prototype;return s.initializeProgram=function(e){const i=t.shader.get().build(this.configuration);return new p.Program(e.rctx,i,f)},s.destroy=function(){e.prototype.destroy.call(this),this.stippleTextureRepository.release(this.stipplePattern),this.stipplePattern=null,this.stippleTextureBind=null},s.bindPass=function(e,t){if(this.program.bindPass(e,t),this.stipplePattern!==e.stipplePattern){const t=e.stipplePattern;this.stippleTextureBind=this.stippleTextureRepository.swap(this.stipplePattern,t),this.stipplePattern=t}if(this.configuration.stippleEnabled){const{pixelSize:e,sdfNormalizer:t,pixels:i}=r.isSome(this.stippleTextureBind)?this.stippleTextureBind(this.program):{pixelSize:1,sdfNormalizer:1,pixels:1};this.program.setUniform1f("stipplePatternSDFNormalizer",t),this.program.setUniform1f("stipplePatternTextureSize",i),this.program.setUniform1f("stipplePatternPixelSize",e),this.program.setUniform1f("stipplePatternPixelSizeInv",1/e)}},s._makePipelineState=function(e,t){const i=this.configuration,r=e===a.TransparencyPassType.NONE,s=e===a.TransparencyPassType.FrontFace;return T.makePipelineState({blending:i.output===n.ShaderOutput.Color||i.output===n.ShaderOutput.Alpha?r?o.blendingDefault:o.oitBlending(e):null,depthTest:{func:o.oitDepthTest(e)},depthWrite:r?i.writeDepth&&T.defaultDepthWriteParams:o.oitDepthWrite(e),colorWrite:T.defaultColorWriteParams,stencilWrite:i.hasOccludees?c.stencilWriteMaskOn:null,stencilTest:i.hasOccludees?t?c.stencilToolMaskBaseParams:c.stencilBaseAllZerosParams:null,polygonOffset:r||s?i.hasPolygonOffset&&m:o.OITPolygonOffset})},s.initializePipeline=function(){const e=this.configuration;if(e.occluder){const t=e.hasPolygonOffset&&m;this._occluderPipelineTransparent=T.makePipelineState({blending:o.blendingDefault,polygonOffset:t,depthTest:c.depthCompareAlways,depthWrite:null,colorWrite:T.defaultColorWriteParams,stencilWrite:null,stencilTest:c.stencilToolTransparentOccluderParams}),this._occluderPipelineOpaque=T.makePipelineState({blending:o.blendingDefault,polygonOffset:t,depthTest:c.depthCompareAlways,depthWrite:null,colorWrite:T.defaultColorWriteParams,stencilWrite:c.stencilWriteMaskOff,stencilTest:c.stencilToolMaskOccluderParams}),this._occluderPipelineMaskWrite=T.makePipelineState({blending:null,polygonOffset:t,depthTest:c.depthCompareLess,depthWrite:null,colorWrite:null,stencilWrite:c.stencilWriteMaskOn,stencilTest:c.stencilToolMaskBaseParams})}return this._occludeePipelineState=this._makePipelineState(this.configuration.transparencyPassType,!0),this._makePipelineState(this.configuration.transparencyPassType,!1)},s.getPipelineState=function(t,i){return i?this._occludeePipelineState:this.configuration.occluder?t===u.RenderSlot.TRANSPARENT_OCCLUDER_MATERIAL?this._occluderPipelineTransparent:t===u.RenderSlot.OCCLUDER_MATERIAL?this._occluderPipelineOpaque:this._occluderPipelineMaskWrite:e.prototype.getPipelineState.call(this,t,i)},i._createClass(t,[{key:"primitiveType",get:function(){return this.configuration.wireframe?P.PrimitiveType.LINES:P.PrimitiveType.TRIANGLE_STRIP}}]),t}(l.ShaderTechnique);b.shader=new s.ReloadableShaderModule(d.RibbonLine,(()=>new Promise(((t,i)=>e(["./RibbonLine.glsl"],t,i)))));const m={factor:0,units:-4};t.RibbonLineTechnique=b,t.ribbonVertexAttributeLocations=f,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
