"use strict";(globalThis.webpackChunk_tsparticles_wordpress=globalThis.webpackChunk_tsparticles_wordpress||[]).push([[6487],{6487(i,t,s){s.d(t,{PoissonDisc:()=>e});var o=s(3199);class e{active;cellSize;cols;dimensions;firstPoint;grid;points;radius;retries;rows;size;constructor(i,t,s,o,e){this.size={...i},this.radius=t,this.retries=s,this.dimensions=o,this.cellSize=Math.floor(this.radius/Math.sqrt(this.dimensions)),this.cols=Math.floor(this.size.width/this.cellSize),this.rows=Math.floor(this.size.height/this.cellSize),this.points=[],this.active=[],this.grid=[],this.firstPoint=e?{...e}:void 0,this.reset()}addPoint(i){const t={position:{...i},gridPosition:{x:Math.floor(i.x/this.cellSize),y:Math.floor(i.y/this.cellSize)}},s=this.points.length,o=this.grid[t.gridPosition.y];o&&(this.points.push(t),o[t.gridPosition.x]=s,this.active.push(s))}getRandom(i,t){return Math.floor((0,o.G0i)()*(t-i))+i}initialiseGrid(){for(let i=0;i<=this.rows;i++){this.grid[i]=[];const t=this.grid[i];if(t)for(let i=0;i<=this.cols;i++)t[i]=-1}}reset(){if(this.points=[],this.active=[],this.grid=[],this.initialiseGrid(),this.firstPoint)this.addPoint(this.firstPoint);else{const i=0;this.addPoint({x:this.getRandom(i,this.size.width),y:this.getRandom(i,this.size.height)})}}async run(){this.reset();let i=0;for(;this.active.length>0;)this.steps(1),++i%100==0&&await new Promise(i=>setTimeout(i))}steps(i){for(let t=0;t<i;t++)this.active.length<=0||this.#i()}#t(i,t){const s=t*(o.R1e/this.retries),e=this.getRandom(this.radius,this.radius*o.gdl),h=Math.cos(s)*e,r=Math.sin(s)*e,n={x:Math.floor(i.position.x+h),y:Math.floor(i.position.y+r)},l=Math.floor(n.x/this.cellSize),c=Math.floor(n.y/this.cellSize);if(n.x<=0||n.x>=this.size.width||n.y<=0||n.y>=this.size.height)return;const a=this.grid[c];if(!a)return;const d=a[l];if(void 0!==d&&!(d>=0)){for(let i=-1;i<=1;i++)for(let t=-1;t<=1;t++){if(!i&&!t)continue;const s={x:l+t,y:c+i};if(s.x<0||s.y<0||s.x>=this.cols||s.y>=this.rows)continue;const e=this.grid[s.y]?.[s.x];if(void 0===e||e<0)continue;const h=this.points[e];if(h&&(0,o.YfF)(n,h.position)<this.radius)return}return n}}#i(){const i=this.getRandom(0,this.active.length);let t=!1;for(let s=0;s<this.retries;s++){const o=this.active[i];if(void 0===o)continue;const e=this.points[o];if(!e)continue;const h=this.#t(e,s);if(h){t=!0,this.addPoint(h);break}}if(!t){const t=1;this.active.splice(i,t)}}}}}]);