/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../chunks/vec4f64","../../../../geometry/support/buffer/BufferView","../../support/buffer/InterleavedLayout","../core/shaderLibrary/ShaderOutputOptions","../lib/basicInterfaces","../lib/GLMaterial","../lib/GLMaterials","../lib/Material","../lib/OrderIndependentTransparency","../lib/RenderSlot","../lib/Util","../lib/VertexAttribute","./PatternStyle","./internal/bufferWriterUtils","./internal/DefaultBufferWriter","./internal/MaterialUtil","../shaders/PatternTechnique"],(function(e,t,r,i,n,a,s,u,o,l,c,h,f,p,d,g,b,O,A){"use strict";let S=function(e){function r(t){var r;return(r=e.call(this,t,new P)||this).supportsEdges=!0,r._vertexAttributeLocations=A.patternVertexAttributeLocations,r.techniqueConfig=new A.PatternTechniqueConfiguration,r}t._inheritsLoose(r,e);var i=r.prototype;return i.getConfiguration=function(e,t){return this.techniqueConfig.output=e,this.techniqueConfig.cullFace=this.parameters.cullFace,this.techniqueConfig.hasVertexColors=this.parameters.hasVertexColors,this.techniqueConfig.hasSlicePlane=this.parameters.hasSlicePlane,this.techniqueConfig.polygonOffset=this.parameters.polygonOffset,this.techniqueConfig.writeDepth=this.parameters.writeDepth,this.techniqueConfig.style=this.parameters.style,this.techniqueConfig.patternSpacing=this.parameters.patternSpacing,this.techniqueConfig.lineWidth=this.parameters.lineWidth,this.techniqueConfig.draped=this.parameters.draped,this.techniqueConfig.transparencyPassType=t.transparencyPassType,this.techniqueConfig.enableOffset=t.camera.relativeElevation<c.OITPolygonOffsetLimit,this.techniqueConfig.hasMultipassTerrain=t.multipassTerrain.enabled,this.techniqueConfig.cullAboveGround=t.multipassTerrain.cullAboveGround,this.techniqueConfig},i.intersect=function(e,t,r,i,n,a,s){O.intersectTriangleGeometry(e,t,i,n,a,void 0,s)},i.requiresSlot=function(e,t){if(e===h.RenderSlot.DRAPED_MATERIAL)return!0;if(o.outputFromPass(t)===a.ShaderOutput.Highlight)return e===h.RenderSlot.OPAQUE_MATERIAL;return e===(this.parameters.writeDepth?h.RenderSlot.TRANSPARENT_MATERIAL:h.RenderSlot.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL)},i.createGLMaterial=function(e){return e.output===a.ShaderOutput.Color||e.output===a.ShaderOutput.Alpha||e.output===a.ShaderOutput.Highlight||e.output===a.ShaderOutput.Depth&&this.parameters.writeLinearDepth?new m(e):null},i.createBufferWriter=function(){const e=n.newLayout().vec3f(p.VertexAttribute.POSITION).vec4u8(p.VertexAttribute.COLOR).vec4f(p.VertexAttribute.UVMAPSPACE);return this.parameters.draped||e.mat3f(p.VertexAttribute.BOUNDINGRECT),new C(e)},r}(l.Material),m=function(e){function r(){return e.apply(this,arguments)||this}t._inheritsLoose(r,e);var i=r.prototype;return i._updateParameters=function(e){return this.ensureTechnique(A.PatternTechnique,e)},i._updateOccludeeState=function(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})},i.beginSlot=function(e){return this._output!==a.ShaderOutput.Color&&this._output!==a.ShaderOutput.Alpha||this._updateOccludeeState(e),this._updateParameters(e)},r}(u),C=function(e){function r(){return e.apply(this,arguments)||this}t._inheritsLoose(r,e);var n=r.prototype;return n.write=function(e,t,r,n){for(const a of this.vertexBufferLayout.fieldNames){const s=t.vertexAttributes.get(a),u=t.indices.get(a);if(s&&u)switch(a){case p.VertexAttribute.POSITION:{f.assert(3===s.size);const t=r.getField(a,i.BufferViewVec3f);t&&g.writePosition(u,s.data,e.transformation,t,n);break}case p.VertexAttribute.COLOR:{f.assert(3===s.size||4===s.size);const e=r.getField(a,i.BufferViewVec4u8);e&&g.writeColor(u,s.data,s.size,e,n);break}case p.VertexAttribute.UVMAPSPACE:{f.assert(4===s.size);const e=r.getField(a,i.BufferViewVec4f);e&&g.writeBufferVec4(u,s.data,e,n);break}case p.VertexAttribute.BOUNDINGRECT:{f.assert(9===s.size);const t=r.getField(a,i.BufferViewMat3f);t&&this.writeBoundingRect(u,s.data,e.transformation,t,n);break}}}},n.writeBoundingRect=function(e,t,r,i,n){const a=r,s=i.typedBuffer,u=i.typedBufferStride,o=e.length;n*=u;for(let l=0;l<o;++l){const r=9*e[l],i=t[r],o=t[r+1],c=t[r+2];s[n]=a[0]*i+a[4]*o+a[8]*c+a[12],s[n+1]=a[1]*i+a[5]*o+a[9]*c+a[13],s[n+2]=a[2]*i+a[6]*o+a[10]*c+a[14];for(let e=3;e<9;++e)s[n+e]=t[r+e];n+=u}},r}(b.DefaultBufferWriter),P=function(e){function i(){var t;return(t=e.apply(this,arguments)||this).color=r.fromValues(1,1,1,1),t.writeDepth=!0,t.writeLinearDepth=!1,t.hasVertexColors=!1,t.polygonOffset=!1,t.hasSlicePlane=!1,t.cullFace=s.CullFaceOptions.None,t.hasOccludees=!1,t.style=d.Style.Cross,t.patternSpacing=10,t.lineWidth=1,t.draped=!0,t}return t._inheritsLoose(i,e),i}(l.MaterialParameters);e.Parameters=P,e.PatternMaterial=S,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
