/*
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","../../../../core/maybe","../../../../chunks/vec2","../../../../chunks/vec2f64","../../../../core/libs/gl-matrix-2/types/vec2","../../support/buffer/InterleavedLayout","../lib/GLMaterial","../lib/Material","../lib/RenderPass","../lib/RenderSlot","../lib/VertexAttribute","./internal/bufferWriterUtils","../shaders/HeatmapDensityTechnique"],(function(e,t,r,i,n,s,u,a,o,c,l,f,b,h){"use strict";const A=2;let p=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).isAttributeDriven=!1,t}return t._inheritsLoose(r,e),r}(h.HeatmapDensityPassParameters),d=function(e){function n(t){var r;return(r=e.call(this,t,new p)||this)._techniqueConfig=new h.HeatmapDensityTechniqueConfiguration,r}t._inheritsLoose(n,e);var u=n.prototype;return u.requiresSlot=function(e,t){return e===l.RenderSlot.DRAPED_MATERIAL&&t===c.RenderPass.MATERIAL},u.getConfiguration=function(){return this._techniqueConfig.isAttributeDriven=this.parameters.isAttributeDriven,this._techniqueConfig},u.createGLMaterial=function(e){return new T(e)},u.intersect=function(e,t,n,u,a,o,c,l,b){if(r.isNone(b)||!s.isVec2(o))return;const h=e.vertexAttributes.get(f.VertexAttribute.POSITION),{parameters:p}=this,{searchRadius:d}=p,{screenToWorldRatio:T}=e,g=d*T+A*T,v=g*g,y=h.data.length/h.size;for(let r=0;r<y;r++){const e=r*h.size,t=i.set(x,h.data[e],h.data[e+1]);i.squaredDistance(t,o)<v&&c(b.dist,b.normal,-1,!1)}},u.createBufferWriter=function(){return new g(this.parameters.isAttributeDriven?y:v)},n}(o.Material),T=function(e){function r(){return e.apply(this,arguments)||this}return t._inheritsLoose(r,e),r.prototype.beginSlot=function(e){return this.ensureTechnique(h.HeatmapDensityTechnique,e)},r}(a),g=function(){function e(e){this.vertexBufferLayout=e}var t=e.prototype;return t.allocate=function(e){return this.vertexBufferLayout.createBuffer(e)},t.elementCount=function(e){return e.indices.get(f.VertexAttribute.POSITION).length*V},t.write=function(e,t,r,i){b.writePosition(t.indices.get(f.VertexAttribute.POSITION),t.vertexAttributes.get(f.VertexAttribute.POSITION).data,e.transformation,r.position,i,V);const n=t.indices.get(f.VertexAttribute.POSITION).length,s=r.uv0;let u=i;for(let o=0;o<n;++o)s.setValues(u++,-1,-1),s.setValues(u++,1,-1),s.setValues(u++,1,1),s.setValues(u++,1,1),s.setValues(u++,-1,1),s.setValues(u++,-1,-1);const a="featureAttribute"in r?r.featureAttribute:null;a&&b.writeBufferFloat(t.indices.get(f.VertexAttribute.FEATUREATTRIBUTE),t.vertexAttributes.get(f.VertexAttribute.FEATUREATTRIBUTE).data,a,i,V)},e}();const v=u.newLayout().vec3f(f.VertexAttribute.POSITION).vec2f(f.VertexAttribute.UV0),y=v.clone().f32(f.VertexAttribute.FEATUREATTRIBUTE),V=6;function m(e){return e instanceof d}const x=n.create();Object.defineProperty(e,"RadiusMode",{enumerable:!0,get:()=>h.RadiusMode}),e.HeatmapDensityMaterial=d,e.HeatmapDensityMaterialParameters=p,e.isHeatMapDensityMaterial=m,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
