"use strict";(globalThis.webpackChunk_tsparticles_wordpress=globalThis.webpackChunk_tsparticles_wordpress||[]).push([[2759],{2759:(t,e,i)=>{i.d(e,{loadInfectionPlugin:()=>d});var n=i(9201);class s{constructor(){this.color=new n.Oz,this.color.value="#ff0000",this.radius=0,this.rate=1}load(t){void 0!==t&&(void 0!==t.color&&(this.color=n.Oz.create(this.color,t.color)),this.duration=t.duration,this.infectedStage=t.infectedStage,void 0!==t.radius&&(this.radius=t.radius),void 0!==t.rate&&(this.rate=t.rate))}}class o{constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(t){void 0!==t&&(void 0!==t.cure&&(this.cure=t.cure),void 0!==t.delay&&(this.delay=t.delay),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.infections&&(this.infections=t.infections),void 0!==t.stages&&(this.stages=t.stages.map((t=>{const e=new s;return e.load(t),e}))))}}class a{constructor(t){this._nextInfectionStage=t=>{const e=this._container.actualOptions.infection,{infection:i}=t;if(!e||!i)return;const n=e.stages.length;if(!(n<=0||void 0===i.stage)&&(i.time=0,n<=++i.stage)){if(e.cure)return delete i.stage,void delete i.time;i.stage=0,i.time=0}},this._container=t}startInfection(t,e){const i=this._container.actualOptions.infection,{infection:n}=t;i&&n&&(e>i.stages.length||e<0||(n.delay=0,n.delayStage=e))}updateInfection(t,e){const i=this._container.actualOptions.infection,{infection:n}=t;if(!i||!n)return;const s=i.stages,o=s.length;if(void 0!==n.delay&&void 0!==n.delayStage){const t=n.delayStage;if(t>o||t<0)return;n.delay>=1e3*i.delay?(n.stage=t,n.time=0,delete n.delay,delete n.delayStage):n.delay+=e}else delete n.delay,delete n.delayStage;if(void 0!==n.stage&&void 0!==n.time){const i=s[n.stage];void 0!==i.duration&&i.duration>=0&&n.time>1e3*i.duration?this._nextInfectionStage(t):n.time+=e}else delete n.stage,delete n.time}updateInfectionStage(t,e){const i=this._container.actualOptions,{infection:n}=t;i.infection&&n&&(e>i.infection.stages.length||e<0||void 0!==n.stage&&n.stage>e||(n.stage=e,n.time=0))}}class c{constructor(t){this._container=t,this._container.infecter=new a(this._container)}particleFillColor(t){const e=this._container.actualOptions;if(!t.infection||!e.infection)return;const i=t.infection.stage,n=e.infection.stages;return void 0!==i?n[i].color:void 0}particleStrokeColor(t){return this.particleFillColor(t)}particlesSetup(){const t=this._container.actualOptions;if(t.infection)for(let e=0;e<t.infection.infections;e++){const t=this._container.particles.filter((t=>{const e=t;return e.infection||(e.infection={}),void 0===e.infection.stage})),e=(0,n.c8)(t);this._container.infecter?.startInfection(e,0)}}}class r extends n.$S{constructor(t){super(t)}clear(){}init(){}async interact(t,e){const i=this.container.infecter;if(!i)return;if(i.updateInfection(t,e.value),void 0===t.infection?.stage)return;const s=this.container,o=s.actualOptions.infection;if(!o?.enable||o.stages.length<1)return;const a=o.stages[t.infection.stage],c=s.retina.pixelRatio,r=2*t.getRadius()+a.radius*c,l=t.getPosition(),d=a.infectedStage??t.infection.stage,f=s.particles.quadTree.queryCircle(l,r),g=a.rate,u=f.length;for(const e of f){const s=e;if(!(s===t||s.destroyed||s.spawning||void 0!==s.infection?.stage&&s.infection.stage===t.infection.stage||(0,n.sZ)()>=g/u))if(void 0===s.infection?.stage)i.startInfection(s,d);else if(s.infection.stage<t.infection.stage)i.updateInfectionStage(s,d);else if(s.infection.stage>t.infection.stage){const e=o.stages[s.infection.stage],n=e?.infectedStage??s.infection.stage;i.updateInfectionStage(t,n)}}}isEnabled(){return this.container.actualOptions?.infection?.enable??!1}reset(){}}class l{constructor(){this.id="infection"}getPlugin(t){return new c(t)}loadOptions(t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let i=t.infection;void 0===i?.load&&(t.infection=i=new o),i.load(e?.infection)}needsPlugin(t){return t?.infection?.enable??!1}}async function d(t,e=!0){const i=new l;await t.addPlugin(i,e),await t.addInteractor("particlesInfection",(t=>new r(t)),e)}}}]);