/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{clamp as t}from"../../core/mathUtils.js";import{pt2px as r,px2pt as o}from"../../core/screenUtils.js";import{l as n}from"../../chunks/vec42.js";import{create as i}from"../../core/libs/gl-matrix-2/factories/vec4f64.js";const c=2.4;function e(t){return o(t*c)}function a(t){return r(t)/c}function s(r,o,i,c){let{color:e,ratio:a}=o,{color:s,ratio:f}=i;if(f===a){const t=1e-6;1===f?a-=t:f+=t}const l=t((c-a)/(f-a),0,1);n(r,e.toArray(),s.toArray(),l)}function f(t){const r=512,o=new Uint8ClampedArray(4*r);if(t=t.filter(({ratio:t})=>t>=0&&t<=1).sort((t,r)=>t.ratio-r.ratio).map(({color:t,ratio:r})=>({color:t,ratio:Math.max(r,.001)})),t.length<1)return o;let n=t[0],c=t[0],e=1;const a=i();for(let i=0;i<r;i++){const f=(i+.5)/r;for(;f>c.ratio&&e<t.length;)n=c,c=t[e++];s(a,n,c,f),o.set(a,4*i)}return o}function l(t,r,o){const n=Math.sqrt(t**2+r**2)/o;return n>1?0:3/(Math.PI*o**2)*(1-n**2)**2}function u(t){return"function"==typeof t?t:t?r=>+r[t]:()=>1}export{u as createValueFunction,l as evaluateDensityKernel,e as gaussianBlurRadiusPxToKernelDensityRadiusPt,f as generateGradient,a as kernelDensityRadiusPtToGaussianBlurRadiusPx,c as magicKernelDensityRadiusInflationFactor};
