@tsparticles/engine 4.0.0-alpha.3 → 4.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/794.min.js +2 -0
  2. package/794.min.js.LICENSE.txt +1 -0
  3. package/README.md +2 -5
  4. package/browser/Core/Canvas.js +3 -3
  5. package/browser/Core/Container.js +35 -155
  6. package/browser/Core/Engine.js +10 -51
  7. package/browser/Core/Particle.js +5 -10
  8. package/browser/Core/Particles.js +36 -25
  9. package/browser/Core/Utils/Constants.js +2 -2
  10. package/browser/Core/Utils/EventListeners.js +5 -250
  11. package/browser/Options/Classes/Options.js +7 -75
  12. package/browser/Options/Classes/Particles/ParticlesOptions.js +5 -11
  13. package/{esm/Options/Classes/Interactivity/Events → browser/Options/Classes}/ResizeEvent.js +1 -1
  14. package/browser/Utils/ColorUtils.js +7 -5
  15. package/browser/Utils/Utils.js +25 -32
  16. package/browser/exports.js +1 -21
  17. package/cjs/Core/Canvas.js +3 -3
  18. package/cjs/Core/Container.js +35 -155
  19. package/cjs/Core/Engine.js +10 -51
  20. package/cjs/Core/Particle.js +5 -10
  21. package/cjs/Core/Particles.js +36 -25
  22. package/cjs/Core/Utils/Constants.js +2 -2
  23. package/cjs/Core/Utils/EventListeners.js +5 -250
  24. package/cjs/Options/Classes/Options.js +7 -75
  25. package/cjs/Options/Classes/Particles/ParticlesOptions.js +5 -11
  26. package/cjs/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +1 -1
  27. package/cjs/Utils/ColorUtils.js +7 -5
  28. package/cjs/Utils/Utils.js +25 -32
  29. package/cjs/exports.js +1 -21
  30. package/dist_browser_Core_Container_js.js +6 -16
  31. package/esm/Core/Canvas.js +3 -3
  32. package/esm/Core/Container.js +35 -155
  33. package/esm/Core/Engine.js +10 -51
  34. package/esm/Core/Particle.js +5 -10
  35. package/esm/Core/Particles.js +36 -25
  36. package/esm/Core/Utils/Constants.js +2 -2
  37. package/esm/Core/Utils/EventListeners.js +5 -250
  38. package/esm/Options/Classes/Options.js +7 -75
  39. package/esm/Options/Classes/Particles/ParticlesOptions.js +5 -11
  40. package/{browser/Options/Classes/Interactivity/Events → esm/Options/Classes}/ResizeEvent.js +1 -1
  41. package/esm/Utils/ColorUtils.js +7 -5
  42. package/esm/Utils/Utils.js +25 -32
  43. package/esm/exports.js +1 -21
  44. package/package.json +1 -1
  45. package/report.html +1 -1
  46. package/tsparticles.engine.js +14 -206
  47. package/tsparticles.engine.min.js +1 -1
  48. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  49. package/types/Core/Container.d.ts +3 -15
  50. package/types/Core/Engine.d.ts +3 -18
  51. package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -1
  52. package/types/Core/Interfaces/IPlugin.d.ts +5 -1
  53. package/types/Core/Particle.d.ts +0 -2
  54. package/types/Core/Particles.d.ts +1 -5
  55. package/types/Core/Utils/Constants.d.ts +2 -2
  56. package/types/Core/Utils/EventListeners.d.ts +0 -14
  57. package/types/Options/Classes/Options.d.ts +2 -11
  58. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +0 -2
  59. package/types/Options/Classes/ResizeEvent.d.ts +9 -0
  60. package/types/Options/Interfaces/IOptions.d.ts +2 -8
  61. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -3
  62. package/types/Types/EngineInitializers.d.ts +10 -0
  63. package/types/Utils/Utils.d.ts +4 -6
  64. package/types/export-types.d.ts +3 -19
  65. package/types/exports.d.ts +1 -21
  66. package/umd/Core/Canvas.js +3 -3
  67. package/umd/Core/Container.js +35 -155
  68. package/umd/Core/Engine.js +11 -52
  69. package/umd/Core/Particle.js +6 -11
  70. package/umd/Core/Particles.js +37 -26
  71. package/umd/Core/Utils/Constants.js +3 -3
  72. package/umd/Core/Utils/EventListeners.js +7 -252
  73. package/umd/Options/Classes/Options.js +7 -75
  74. package/umd/Options/Classes/Particles/ParticlesOptions.js +5 -11
  75. package/umd/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +2 -2
  76. package/umd/Utils/ColorUtils.js +7 -5
  77. package/umd/Utils/Utils.js +26 -35
  78. package/umd/exports.js +2 -22
  79. package/638.min.js +0 -2
  80. package/638.min.js.LICENSE.txt +0 -1
  81. package/browser/Core/Interfaces/IMouseData.js +0 -1
  82. package/browser/Core/Interfaces/IParticlesInteractor.js +0 -1
  83. package/browser/Core/Utils/ExternalInteractorBase.js +0 -7
  84. package/browser/Core/Utils/InteractionManager.js +0 -60
  85. package/browser/Core/Utils/ParticlesInteractorBase.js +0 -7
  86. package/browser/Enums/InteractivityDetect.js +0 -6
  87. package/browser/Enums/Modes/ResponsiveMode.js +0 -5
  88. package/browser/Enums/Modes/ThemeMode.js +0 -6
  89. package/browser/Enums/Types/DivType.js +0 -5
  90. package/browser/Enums/Types/InteractorType.js +0 -5
  91. package/browser/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
  92. package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
  93. package/browser/Options/Classes/Interactivity/Events/Events.js +0 -30
  94. package/browser/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
  95. package/browser/Options/Classes/Interactivity/Events/Parallax.js +0 -22
  96. package/browser/Options/Classes/Interactivity/Interactivity.js +0 -22
  97. package/browser/Options/Classes/Interactivity/Modes/Modes.js +0 -25
  98. package/browser/Options/Classes/ManualParticle.js +0 -21
  99. package/browser/Options/Classes/Responsive.js +0 -29
  100. package/browser/Options/Classes/Theme/Theme.js +0 -21
  101. package/browser/Options/Classes/Theme/ThemeDefault.js +0 -23
  102. package/browser/Options/Interfaces/IManualParticle.js +0 -1
  103. package/browser/Options/Interfaces/IResponsive.js +0 -1
  104. package/browser/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
  105. package/browser/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
  106. package/browser/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
  107. package/browser/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
  108. package/browser/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
  109. package/browser/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
  110. package/browser/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
  111. package/browser/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
  112. package/browser/Options/Interfaces/Theme/ITheme.js +0 -1
  113. package/browser/Options/Interfaces/Theme/IThemeDefault.js +0 -1
  114. package/cjs/Core/Interfaces/IContainerInteractivity.js +0 -1
  115. package/cjs/Core/Interfaces/IExternalInteractor.js +0 -1
  116. package/cjs/Core/Interfaces/IInteractor.js +0 -1
  117. package/cjs/Core/Interfaces/IMouseData.js +0 -1
  118. package/cjs/Core/Interfaces/IParticlesInteractor.js +0 -1
  119. package/cjs/Core/Utils/ExternalInteractorBase.js +0 -7
  120. package/cjs/Core/Utils/InteractionManager.js +0 -60
  121. package/cjs/Core/Utils/ParticlesInteractorBase.js +0 -7
  122. package/cjs/Enums/InteractivityDetect.js +0 -6
  123. package/cjs/Enums/Modes/ResponsiveMode.js +0 -5
  124. package/cjs/Enums/Modes/ThemeMode.js +0 -6
  125. package/cjs/Enums/Types/DivType.js +0 -5
  126. package/cjs/Enums/Types/InteractorType.js +0 -5
  127. package/cjs/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
  128. package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
  129. package/cjs/Options/Classes/Interactivity/Events/Events.js +0 -30
  130. package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
  131. package/cjs/Options/Classes/Interactivity/Events/Parallax.js +0 -22
  132. package/cjs/Options/Classes/Interactivity/Interactivity.js +0 -22
  133. package/cjs/Options/Classes/Interactivity/Modes/Modes.js +0 -25
  134. package/cjs/Options/Classes/ManualParticle.js +0 -21
  135. package/cjs/Options/Classes/Responsive.js +0 -29
  136. package/cjs/Options/Classes/Theme/Theme.js +0 -21
  137. package/cjs/Options/Classes/Theme/ThemeDefault.js +0 -23
  138. package/cjs/Options/Interfaces/IManualParticle.js +0 -1
  139. package/cjs/Options/Interfaces/IResponsive.js +0 -1
  140. package/cjs/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
  141. package/cjs/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
  142. package/cjs/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
  143. package/cjs/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
  144. package/cjs/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
  145. package/cjs/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
  146. package/cjs/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
  147. package/cjs/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
  148. package/cjs/Options/Interfaces/Theme/ITheme.js +0 -1
  149. package/cjs/Options/Interfaces/Theme/IThemeDefault.js +0 -1
  150. package/esm/Core/Interfaces/IContainerInteractivity.js +0 -1
  151. package/esm/Core/Interfaces/IExternalInteractor.js +0 -1
  152. package/esm/Core/Interfaces/IInteractor.js +0 -1
  153. package/esm/Core/Interfaces/IMouseData.js +0 -1
  154. package/esm/Core/Interfaces/IParticlesInteractor.js +0 -1
  155. package/esm/Core/Utils/ExternalInteractorBase.js +0 -7
  156. package/esm/Core/Utils/InteractionManager.js +0 -60
  157. package/esm/Core/Utils/ParticlesInteractorBase.js +0 -7
  158. package/esm/Enums/InteractivityDetect.js +0 -6
  159. package/esm/Enums/Modes/ResponsiveMode.js +0 -5
  160. package/esm/Enums/Modes/ThemeMode.js +0 -6
  161. package/esm/Enums/Types/DivType.js +0 -5
  162. package/esm/Enums/Types/InteractorType.js +0 -5
  163. package/esm/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
  164. package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
  165. package/esm/Options/Classes/Interactivity/Events/Events.js +0 -30
  166. package/esm/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
  167. package/esm/Options/Classes/Interactivity/Events/Parallax.js +0 -22
  168. package/esm/Options/Classes/Interactivity/Interactivity.js +0 -22
  169. package/esm/Options/Classes/Interactivity/Modes/Modes.js +0 -25
  170. package/esm/Options/Classes/ManualParticle.js +0 -21
  171. package/esm/Options/Classes/Responsive.js +0 -29
  172. package/esm/Options/Classes/Theme/Theme.js +0 -21
  173. package/esm/Options/Classes/Theme/ThemeDefault.js +0 -23
  174. package/esm/Options/Interfaces/IManualParticle.js +0 -1
  175. package/esm/Options/Interfaces/IResponsive.js +0 -1
  176. package/esm/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
  177. package/esm/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
  178. package/esm/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
  179. package/esm/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
  180. package/esm/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
  181. package/esm/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
  182. package/esm/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
  183. package/esm/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
  184. package/esm/Options/Interfaces/Theme/ITheme.js +0 -1
  185. package/esm/Options/Interfaces/Theme/IThemeDefault.js +0 -1
  186. package/types/Core/Interfaces/IContainerInteractivity.d.ts +0 -6
  187. package/types/Core/Interfaces/IExternalInteractor.d.ts +0 -12
  188. package/types/Core/Interfaces/IInteractor.d.ts +0 -16
  189. package/types/Core/Interfaces/IMouseData.d.ts +0 -9
  190. package/types/Core/Interfaces/IParticlesInteractor.d.ts +0 -7
  191. package/types/Core/Utils/ExternalInteractorBase.d.ts +0 -15
  192. package/types/Core/Utils/InteractionManager.d.ts +0 -17
  193. package/types/Core/Utils/ParticlesInteractorBase.d.ts +0 -15
  194. package/types/Enums/InteractivityDetect.d.ts +0 -5
  195. package/types/Enums/Modes/ResponsiveMode.d.ts +0 -4
  196. package/types/Enums/Modes/ThemeMode.d.ts +0 -5
  197. package/types/Enums/Types/DivType.d.ts +0 -4
  198. package/types/Enums/Types/InteractorType.d.ts +0 -4
  199. package/types/Options/Classes/Interactivity/Events/ClickEvent.d.ts +0 -10
  200. package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +0 -13
  201. package/types/Options/Classes/Interactivity/Events/Events.d.ts +0 -16
  202. package/types/Options/Classes/Interactivity/Events/HoverEvent.d.ts +0 -12
  203. package/types/Options/Classes/Interactivity/Events/Parallax.d.ts +0 -10
  204. package/types/Options/Classes/Interactivity/Events/ResizeEvent.d.ts +0 -9
  205. package/types/Options/Classes/Interactivity/Interactivity.d.ts +0 -16
  206. package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +0 -12
  207. package/types/Options/Classes/ManualParticle.d.ts +0 -10
  208. package/types/Options/Classes/Responsive.d.ts +0 -12
  209. package/types/Options/Classes/Theme/Theme.d.ts +0 -12
  210. package/types/Options/Classes/Theme/ThemeDefault.d.ts +0 -11
  211. package/types/Options/Interfaces/IManualParticle.d.ts +0 -7
  212. package/types/Options/Interfaces/IResponsive.d.ts +0 -7
  213. package/types/Options/Interfaces/Interactivity/Events/IClickEvent.d.ts +0 -5
  214. package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +0 -8
  215. package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +0 -11
  216. package/types/Options/Interfaces/Interactivity/Events/IHoverEvent.d.ts +0 -7
  217. package/types/Options/Interfaces/Interactivity/Events/IParallax.d.ts +0 -5
  218. package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +0 -9
  219. package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +0 -4
  220. package/types/Options/Interfaces/Interactivity/Modes/IModes.d.ts +0 -1
  221. package/types/Options/Interfaces/Theme/ITheme.d.ts +0 -7
  222. package/types/Options/Interfaces/Theme/IThemeDefault.d.ts +0 -6
  223. package/umd/Core/Interfaces/IExternalInteractor.js +0 -12
  224. package/umd/Core/Interfaces/IInteractor.js +0 -12
  225. package/umd/Core/Interfaces/IMouseData.js +0 -12
  226. package/umd/Core/Interfaces/IParticlesInteractor.js +0 -12
  227. package/umd/Core/Utils/ExternalInteractorBase.js +0 -21
  228. package/umd/Core/Utils/InteractionManager.js +0 -74
  229. package/umd/Core/Utils/ParticlesInteractorBase.js +0 -21
  230. package/umd/Enums/InteractivityDetect.js +0 -19
  231. package/umd/Enums/Modes/ResponsiveMode.js +0 -18
  232. package/umd/Enums/Modes/ThemeMode.js +0 -19
  233. package/umd/Enums/Types/DivType.js +0 -18
  234. package/umd/Enums/Types/InteractorType.js +0 -18
  235. package/umd/Options/Classes/Interactivity/Events/ClickEvent.js +0 -32
  236. package/umd/Options/Classes/Interactivity/Events/DivEvent.js +0 -41
  237. package/umd/Options/Classes/Interactivity/Events/Events.js +0 -44
  238. package/umd/Options/Classes/Interactivity/Events/HoverEvent.js +0 -35
  239. package/umd/Options/Classes/Interactivity/Events/Parallax.js +0 -36
  240. package/umd/Options/Classes/Interactivity/Interactivity.js +0 -36
  241. package/umd/Options/Classes/Interactivity/Modes/Modes.js +0 -39
  242. package/umd/Options/Classes/ManualParticle.js +0 -35
  243. package/umd/Options/Classes/Responsive.js +0 -43
  244. package/umd/Options/Classes/Theme/Theme.js +0 -35
  245. package/umd/Options/Classes/Theme/ThemeDefault.js +0 -37
  246. package/umd/Options/Interfaces/IManualParticle.js +0 -12
  247. package/umd/Options/Interfaces/IResponsive.js +0 -12
  248. package/umd/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -12
  249. package/umd/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -12
  250. package/umd/Options/Interfaces/Interactivity/Events/IEvents.js +0 -12
  251. package/umd/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -12
  252. package/umd/Options/Interfaces/Interactivity/Events/IParallax.js +0 -12
  253. package/umd/Options/Interfaces/Interactivity/IInteractivity.js +0 -12
  254. package/umd/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -12
  255. package/umd/Options/Interfaces/Interactivity/Modes/IModes.js +0 -12
  256. package/umd/Options/Interfaces/Theme/ITheme.js +0 -12
  257. package/umd/Options/Interfaces/Theme/IThemeDefault.js +0 -12
  258. /package/browser/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
  259. /package/browser/{Core/Interfaces/IContainerInteractivity.js → Types/EngineInitializers.js} +0 -0
  260. /package/cjs/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
  261. /package/{browser/Core/Interfaces/IExternalInteractor.js → cjs/Types/EngineInitializers.js} +0 -0
  262. /package/esm/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
  263. /package/{browser/Core/Interfaces/IInteractor.js → esm/Types/EngineInitializers.js} +0 -0
  264. /package/types/Options/Interfaces/{Interactivity/Events/IResizeEvent.d.ts → IResizeEvent.d.ts} +0 -0
  265. /package/umd/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
  266. /package/umd/{Core/Interfaces/IContainerInteractivity.js → Types/EngineInitializers.js} +0 -0
package/794.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 794.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[794],{8794(t,i,e){e.d(i,{Container:()=>M});var s=e(1680),n=e(7642),a=e(6754),r=e(302),o=e(9599);function h(t,i,e){const s=i[e];void 0!==s&&(t[e]=(t[e]??n.zs)*s)}function c(t,i,e=!1){if(!i)return;const s=t.style,n=new Set;for(let t=0;t<s.length;t++){const i=s.item(t);i&&n.add(i)}for(let t=0;t<i.length;t++){const e=i.item(t);e&&n.add(e)}for(const t of n){const n=i.getPropertyValue(t);n?s.setProperty(t,n,e?"important":""):s.removeProperty(t)}}class l{constructor(t,i){this.container=t,this._reusableColorStyles={},this._reusablePluginColors=[void 0,void 0],this._reusableTransform={},this._applyPostDrawUpdaters=t=>{for(const i of this._postDrawUpdaters)i.afterDraw?.(t)},this._applyPreDrawUpdaters=(t,i,e,s,n,a)=>{for(const r of this._preDrawUpdaters){if(r.getColorStyles){const{fill:a,stroke:o}=r.getColorStyles(i,t,e,s);a&&(n.fill=a),o&&(n.stroke=o)}if(r.getTransformValues){const t=r.getTransformValues(i);for(const i in t)h(a,t,i)}r.beforeDraw?.(i)}},this._applyResizePlugins=()=>{for(const t of this._resizePlugins)t.resize?.()},this._getPluginParticleColors=t=>{let i,e;for(const s of this._colorPlugins)if(!i&&s.particleFillColor&&(i=(0,o.R5)(this._engine,s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,o.R5)(this._engine,s.particleStrokeColor(t))),i&&e)break;return this._reusablePluginColors[0]=i,this._reusablePluginColors[1]=e,this._reusablePluginColors},this._initStyle=()=>{const t=this.element,i=this.container.actualOptions;if(t){this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle();for(const e in i.style){if(!e||!Object.hasOwn(i.style,e))continue;const s=i.style[e];s&&t.style.setProperty(e,s,"important")}}},this._repairStyle=()=>{const t=this.element;if(!t)return;this._safeMutationObserver((t=>{t.disconnect()})),this._initStyle(),this.initBackground();const i=this._pointerEvents;t.style.pointerEvents=i,t.setAttribute("pointer-events",i),this._safeMutationObserver((i=>{t instanceof Node&&i.observe(t,{attributes:!0})}))},this._resetOriginalStyle=()=>{const t=this.element,i=this._originalStyle;t&&i&&c(t,i,!0)},this._safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)},this._setFullScreenStyle=()=>{const t=this.element;t&&c(t,(0,r.hJ)(this.container.actualOptions.fullScreen.zIndex),!0)},this._engine=i,this._standardSize={height:0,width:0};const e=t.retina.pixelRatio,s=this._standardSize;this.size={height:s.height*e,width:s.width*e},this._context=null,this._generated=!1,this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._pointerEvents="none"}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}canvasClear(){this.container.actualOptions.clear&&this.draw((t=>{(0,a.IU)(t,this.size)}))}clear(){let t=!1;for(const i of this.container.plugins)!t&&i.canvasClear&&(t=i.canvasClear());t||this.canvasClear()}clearDrawPlugin(t,i){this.draw((e=>{(0,a.l7)(e,t,i)}))}destroy(){if(this.stop(),this._generated){const t=this.element;t?.remove(),this.element=void 0}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[]}draw(t){const i=this._context;if(i)return t(i)}drawParticle(t,i){if(t.spawning||t.destroyed)return;const e=t.getRadius();if(e<=n.w2)return;const s=t.getFillColor(),r=t.getStrokeColor()??s;let[h,c]=this._getPluginParticleColors(t);if(h??=s,c??=r,!h&&!c)return;const l=this.container,d=t.options.zIndex,p=n.RV-t.zIndexFactor,{opacity:u,strokeOpacity:f}=t.getOpacity(),_=this._reusableTransform,g=this._reusableColorStyles,y=h?(0,o.LC)(h,l.hdr,u):void 0,m=c?(0,o.LC)(c,l.hdr,f):y;_.a=_.b=_.c=_.d=void 0,g.fill=y,g.stroke=m,this.draw((s=>{this._applyPreDrawUpdaters(s,t,e,u,g,_),(0,a.p0)({container:l,context:s,particle:t,delta:i,colorStyles:g,radius:e*p**d.sizeRate,opacity:u,transform:_})})),this._applyPostDrawUpdaters(t)}drawParticlePlugin(t,i,e){this.draw((s=>{(0,a.Wb)(s,t,i,e)}))}drawParticles(t){const{particles:i,plugins:e}=this.container;this.clear(),i.update(t);for(const i of e.values())this.drawPlugin(i,t);this.draw((()=>{i.drawParticles(t)}));for(const i of e.values())this.clearDrawPlugin(i,t)}drawPlugin(t,i){this.draw((e=>{(0,a.e_)(e,t,i)}))}init(){this._safeMutationObserver((t=>{t.disconnect()})),this._mutationObserver=(0,r.tG)((t=>{for(const i of t)"attributes"===i.type&&"style"===i.attributeName&&this._repairStyle()})),this.resize(),this._initStyle(),this.initBackground(),this._safeMutationObserver((t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})})),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){const{container:t}=this,i=t.actualOptions.background,e=this.element;if(!e)return;const s=e.style,n=(0,o.BN)(this._engine,i.color);s.backgroundColor=n?(0,o.xx)(n,t.hdr,i.opacity):"",s.backgroundImage=i.image||"",s.backgroundPosition=i.position||"",s.backgroundRepeat=i.repeat||"",s.backgroundSize=i.size||""}initPlugins(){this._resizePlugins=[];for(const t of this.container.plugins)t.resize&&this._resizePlugins.push(t),(t.particleFillColor??t.particleStrokeColor)&&this._colorPlugins.push(t)}initUpdaters(){this._preDrawUpdaters=[],this._postDrawUpdaters=[];for(const t of this.container.particles.updaters)t.afterDraw&&this._postDrawUpdaters.push(t),(t.getColorStyles??t.getTransformValues??t.beforeDraw)&&this._preDrawUpdaters.push(t)}loadCanvas(t){this._generated&&this.element&&this.element.remove();const i=this.container;this._generated=n.eb in t.dataset?"true"===t.dataset[n.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,r.td)(this.element.style);const e=this._standardSize;e.height=t.offsetHeight,e.width=t.offsetWidth;const s=this.container.retina.pixelRatio,a=this.size;t.height=a.height=e.height*s,t.width=a.width=e.width*s;const o=(0,r.lV)("(color-gamut: p3)");this._context=this.element.getContext("2d",{alpha:!0,colorSpace:o?.matches&&i.hdr?"display-p3":"srgb",desynchronized:!0,willReadFrequently:!1}),this._safeMutationObserver((t=>{t.disconnect()})),i.retina.init(),this.initBackground(),this._safeMutationObserver((t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})}))}paint(){let t=!1;for(const i of this.container.plugins){if(t)break;t=i.canvasPaint?.()??!1}t||this.paintBase()}paintBase(t){this.draw((i=>{(0,a.Sn)(i,this.size,t)}))}paintImage(t,i){this.draw((e=>{(0,a.Md)(e,this.size,t,i)}))}resize(){if(!this.element)return!1;const t=this.container,i=t.canvas._standardSize,e={width:this.element.offsetWidth,height:this.element.offsetHeight},s=t.retina.pixelRatio,n={width:e.width*s,height:e.height*s};if(e.height===i.height&&e.width===i.width&&n.height===this.element.height&&n.width===this.element.width)return!1;const a={...i};i.height=e.height,i.width=e.width;const r=this.size;return this.element.width=r.width=n.width,this.element.height=r.height=n.height,this.container.started&&t.particles.setResizeFactor({width:i.width/a.width,height:i.height/a.height}),!0}setPointerEvents(t){this.element&&(this._pointerEvents=t,this._repairStyle())}stop(){this._safeMutationObserver((t=>{t.disconnect()})),this._mutationObserver=void 0,this.draw((t=>{(0,a.IU)(t,this.size)}))}async windowResize(){if(!this.element||!this.resize())return;const t=this.container,i=t.updateActualOptions();t.particles.setDensity(),this._applyResizePlugins(),i&&await t.refresh()}}class d{constructor(t){this.container=t,this._handleVisibilityChange=()=>{const t=this.container;t.actualOptions.pauseOnBlur&&((0,r.T5)().hidden?(t.pageHidden=!0,t.pause()):(t.pageHidden=!1,t.animationStatus?t.play(!0):t.draw(!0)))},this._handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);const t=async()=>{const t=this.container.canvas;await t.windowResize()};this._resizeTimeout=setTimeout((()=>{t()}),this.container.actualOptions.resize.delay*n.Xu)},this._manageListeners=t=>{const i=this._handlers;this._manageResize(t),(0,r.Kp)(document,n.nK,i.visibilityChange,t,!1)},this._manageResize=t=>{const i=this._handlers,e=this.container;if(!e.actualOptions.resize.enable)return;if("undefined"==typeof ResizeObserver)return void(0,r.Kp)(globalThis,n.NF,i.resize,t);const s=e.canvas.element;this._resizeObserver&&!t?(s&&this._resizeObserver.unobserve(s),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&t&&s&&(this._resizeObserver=new ResizeObserver((t=>{t.find((t=>t.target===s))&&this._handleWindowResize()})),this._resizeObserver.observe(s))},this._handlers={visibilityChange:()=>{this._handleVisibilityChange()},resize:()=>{this._handleWindowResize()}}}addListeners(){this._manageListeners(!0)}removeListeners(){this._manageListeners(!1)}}var p=e(3838),u=e(2037),f=e(6423),_=e(8095),g=e(1953),y=e(1640),m=e(6312),v=e(9176);function w(t){if(!(0,r.hn)(t.outMode,t.checkModes))return;const i=t.radius*n.gd;t.coord>t.maxCoord-i?t.setCb(-t.radius):t.coord<i&&t.setCb(t.radius)}class b{constructor(t,i){this.container=i,this._cachedOpacityData={opacity:n.hv,strokeOpacity:n.hv},this._cachedPosition=_.p.origin,this._cachedRotateData={sin:0,cos:0},this._cachedTransform={a:1,b:0,c:0,d:1},this._calcPosition=(t,i)=>{let e=n.rq,a=t?_.p.create(t.x,t.y,i):void 0;const r=this.container,o=Array.from(r.plugins),h=this.options.move.outModes,c=this.getRadius(),l=r.canvas.size,d=new AbortController,{signal:p}=d;for(;!p.aborted;){for(const t of o){const e=t.particlePosition?.(a,this);if(e)return _.p.create(e.x,e.y,i)}const t=(0,s.Nx)({size:l,position:a}),r=_.p.create(t.x,t.y,i);this._fixHorizontal(r,c,h.left??h.default),this._fixHorizontal(r,c,h.right??h.default),this._fixVertical(r,c,h.top??h.default),this._fixVertical(r,c,h.bottom??h.default);let d=!0;for(const t of o)if(d=t.checkParticlePosition?.(this,r,e)??!0,!d)break;if(d)return r;e+=n.Eo,a=void 0}return a},this._calculateVelocity=()=>{const t=(0,s.$m)(this.direction).copy(),i=this.options.move;if(i.direction===g.F.inside||i.direction===g.F.outside)return t;const e=(0,s.pu)((0,s.VG)(i.angle.value)),a=(0,s.pu)((0,s.VG)(i.angle.offset)),r={left:a-e*n.MX,right:a+e*n.MX};return i.straight||(t.angle+=(0,s.vE)((0,s.DT)(r.left,r.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,s.G0)()),t},this._fixHorizontal=(t,i,e)=>{w({outMode:e,checkModes:[y.Y.bounce],coord:t.x,maxCoord:this.container.canvas.size.width,setCb:i=>t.x+=i,radius:i})},this._fixVertical=(t,i,e)=>{w({outMode:e,checkModes:[y.Y.bounce],coord:t.y,maxCoord:this.container.canvas.size.height,setCb:i=>t.y+=i,radius:i})},this._getRollColor=t=>{if(!t||!this.roll||!this.backColor&&!this.roll.alter)return t;const i=this.roll.horizontal&&this.roll.vertical?n.gd*n.l:n.l,e=this.roll.horizontal?Math.PI*n.MX:n.dv;return Math.floor((this.roll.angle+e)/(Math.PI/i))%n.gd?this.backColor?this.backColor:this.roll.alter?(0,a.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t},this._initPosition=t=>{const i=this.container,e=(0,s.VG)(this.options.zIndex.value),a=this._calcPosition(t,(0,s.qE)(e,n.X_,i.zLayers));if(!a)throw new Error("a valid position cannot be found for particle");this.position=a,this.initialPosition=this.position.copy();const o=i.canvas.size;switch(this.moveCenter={...(0,r.E9)(this.options.move.center,o),radius:this.options.move.center.radius,mode:this.options.move.center.mode},this.direction=(0,s.JY)(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case g.F.inside:this.outType=m.x.inside;break;case g.F.outside:this.outType=m.x.outside}this.offset=_.M.origin},this._engine=t}destroy(t){if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;const i=this.container,e=this.pathGenerator,s=this.shape?i.shapeDrawers.get(this.shape):void 0;s?.particleDestroy?.(this);for(const e of i.plugins)e.particleDestroyed?.(this,t);for(const e of i.particles.updaters)e.particleDestroyed?.(this,t);e?.reset(this),this._engine.dispatchEvent(p.B.particleDestroyed,{container:this.container,data:{particle:this}})}draw(t){const i=this.container,e=i.canvas;for(const s of i.plugins)e.drawParticlePlugin(s,this,t);e.drawParticle(this,t)}getAngle(){return this.rotation+(this.pathRotation?this.velocity.angle:n.tA)}getFillColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.color))}getMass(){return this.getRadius()**n.dm*Math.PI*n.MX}getOpacity(){const t=this.options.zIndex,i=(n.RV-this.zIndexFactor)**t.opacityRate,e=this.bubble.opacity??(0,s.VG)(this.opacity?.value??n.hv),a=this.strokeOpacity??e;return this._cachedOpacityData.opacity=e*i,this._cachedOpacityData.strokeOpacity=a*i,this._cachedOpacityData}getPosition(){return this._cachedPosition.x=this.position.x+this.offset.x,this._cachedPosition.y=this.position.y+this.offset.y,this._cachedPosition.z=this.position.z,this._cachedPosition}getRadius(){return this.bubble.radius??this.size.value}getRotateData(){const t=this.getAngle();return this._cachedRotateData.sin=Math.sin(t),this._cachedRotateData.cos=Math.cos(t),this._cachedRotateData}getStrokeColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.strokeColor))}getTransformData(t){const i=this.getRotateData(),e=this.isRotating;return this._cachedTransform.a=i.cos*(t.a??n.Ug.a),this._cachedTransform.b=e?i.sin*(t.b??n.D_):t.b??n.Ug.b,this._cachedTransform.c=e?-i.sin*(t.c??n.D_):t.c??n.Ug.c,this._cachedTransform.d=i.cos*(t.d??n.Ug.d),this._cachedTransform}init(t,i,e,a){const o=this.container;this.id=t,this.group=a,this.effectClose=!0,this.effectFill=!0,this.shapeClose=!0,this.shapeFill=!0,this.pathRotation=!1,this.lastPathTime=0,this.destroyed=!1,this.unbreakable=!1,this.isRotating=!1,this.rotation=0,this.misplaced=!1,this.retina={maxDistance:{}},this.outType=m.x.normal,this.ignoresResizeRatio=!0;const h=o.retina.pixelRatio,c=o.actualOptions,l=(0,v.y)(this._engine,o,c.particles),d=l.reduceDuplicates,p=l.effect.type,u=l.shape.type;this.effect=(0,r.TA)(p,this.id,d),this.shape=(0,r.TA)(u,this.id,d);const f=l.effect,_=l.shape;if(e){if(e.effect?.type){const t=e.effect.type,i=(0,r.TA)(t,this.id,d);i&&(this.effect=i,f.load(e.effect))}if(e.shape?.type){const t=e.shape.type,i=(0,r.TA)(t,this.id,d);i&&(this.shape=i,_.load(e.shape))}}if(this.effect===n.mR){const t=[...this.container.effectDrawers.keys()];this.effect=t[Math.floor((0,s.G0)()*t.length)]}if(this.shape===n.mR){const t=[...this.container.shapeDrawers.keys()];this.shape=t[Math.floor((0,s.G0)()*t.length)]}this.effectData=this.effect?function(t,i,e,s){const n=i.options[t];return(0,r.zw)({close:i.close,fill:i.fill},(0,r.TA)(n,e,s))}(this.effect,f,this.id,d):void 0,this.shapeData=this.shape?function(t,i,e,s){const n=i.options[t];return(0,r.zw)({close:i.close,fill:i.fill},(0,r.TA)(n,e,s))}(this.shape,_,this.id,d):void 0,l.load(e);const g=this.effectData;g&&l.load(g.particles);const y=this.shapeData;y&&l.load(y.particles),this.effectFill=g?.fill??l.effect.fill,this.effectClose=g?.close??l.effect.close,this.shapeFill=y?.fill??l.shape.fill,this.shapeClose=y?.close??l.shape.close,this.options=l;const w=this.options.move.path;this.pathDelay=(0,s.VG)(w.delay.value)*n.Xu,w.generator&&(this.pathGenerator=this._engine.getPathGenerator(w.generator),this.pathGenerator&&o.addPath(w.generator,this.pathGenerator)&&this.pathGenerator.init(o)),o.retina.initParticle(this),this.size=(0,r.Xs)(this.options.size,h),this.bubble={inRange:!1},this.slow={inRange:!1,factor:1},this._initPosition(i),this.initialVelocity=this._calculateVelocity(),this.velocity=this.initialVelocity.copy(),this.moveDecay=n.WH-(0,s.VG)(this.options.move.decay);const b=o.particles;let z,P;b.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/o.zLayers,this.sides=24,this.effect&&(z=o.effectDrawers.get(this.effect),z||(z=this._engine.getEffectDrawer(this.effect),z&&o.effectDrawers.set(this.effect,z))),z?.loadEffect&&z.loadEffect(this),this.shape&&(P=o.shapeDrawers.get(this.shape),P||(P=this._engine.getShapeDrawer(this.shape),P&&o.shapeDrawers.set(this.shape,P))),P?.loadShape&&P.loadShape(this);const D=P?.getSidesCount;D&&(this.sides=D(this)),this.spawning=!1;for(const t of b.updaters)t.init(this);for(const t of b.movers)t.init(this);z?.particleInit?.(o,this),P?.particleInit?.(o,this);for(const t of o.plugins)t.particleCreated?.(this)}isInsideCanvas(){const t=this.getRadius(),i=this.container.canvas.size,e=this.position;return e.x>=-t&&e.y>=-t&&e.y<=i.height+t&&e.x<=i.width+t}isVisible(){return!this.destroyed&&!this.spawning&&this.isInsideCanvas()}reset(){for(const t of this.container.particles.updaters)t.reset?.(this)}}var z=e(8229),P=e(2984);class D{constructor(t,i){this.rectangle=t,this.capacity=i,this._subdivide=()=>{const{x:t,y:i}=this.rectangle.position,{width:e,height:s}=this.rectangle.size,{capacity:a}=this;for(let r=0;r<n.Pg;r++){const o=r%n.gd;this._subs.push(new D(new P.M_(t+e*n.MX*o,i+s*n.MX*(Math.round(r*n.MX)-o),e*n.MX,s*n.MX),a))}this._divided=!0},this._points=[],this._divided=!1,this._subs=[]}insert(t){return!!this.rectangle.contains(t.position)&&(this._points.length<this.capacity?(this._points.push(t),!0):(this._divided||this._subdivide(),this._subs.some((i=>i.insert(t)))))}query(t,i){const e=[];if(!t.intersects(this.rectangle))return[];for(const n of this._points)!t.contains(n.position)&&(0,s.Yf)(t.position,n.position)>n.particle.getRadius()&&(!i||i(n.particle))||e.push(n.particle);if(this._divided)for(const s of this._subs)e.push(...s.query(t,i));return e}queryCircle(t,i,e){return this.query(new P.jl(t.x,t.y,i),e)}queryRectangle(t,i,e){return this.query(new P.M_(t.x,t.y,i.width,i.height),e)}}var x=e(7932);const O=t=>{const{height:i,width:e}=t;return new P.M_(n.un*e,n.un*i,n.Rh*e,n.Rh*i)};class S{constructor(t,i){this._addToPool=(...t)=>{this._pool.push(...t)},this._applyDensity=(t,i,e,s)=>{const a=t.number;if(!a.density.enable)return void(void 0===e?this._limit=a.limit.value:(s?.number.limit.value??a.limit.value)&&this._groupLimits.set(e,s?.number.limit.value??a.limit.value));const r=this._initDensityFactor(a.density),o=a.value,h=a.limit.value>n.ou?a.limit.value:o,c=Math.min(o,h)*r+i,l=Math.min(this.count,this.filter((t=>t.group===e)).length);void 0===e?this._limit=a.limit.value*r:this._groupLimits.set(e,a.limit.value*r),l<c?this.push(Math.abs(c-l),void 0,t,e):l>c&&this.removeQuantity(l-c,e)},this._initDensityFactor=t=>{const i=this._container;if(!i.canvas.element||!t.enable)return n.lA;const e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**n.dm)},this._pushParticle=(t,i,e,s)=>{try{const n=this._pool.pop()??new b(this._engine,this._container);n.init(this._nextId,t,i,e);let a=!0;if(s&&(a=s(n)),!a)return;return this._array.push(n),this._zArray.push(n),this._nextId++,this._engine.dispatchEvent(p.B.particleAdded,{container:this._container,data:{particle:n}}),n}catch(t){(0,x.t)().warning(`error adding particle: ${t}`)}},this._removeParticle=(t,i,e)=>{const s=this._array[t];if(!s)return!1;if(s.group!==i)return!1;const a=this._zArray.indexOf(s);return this._array.splice(t,n.LD),this._zArray.splice(a,n.LD),s.destroy(e),this._engine.dispatchEvent(p.B.particleRemoved,{container:this._container,data:{particle:s}}),this._addToPool(s),!0},this._engine=t,this._container=i,this._nextId=0,this._array=[],this._zArray=[],this._pool=[],this._limit=0,this._groupLimits=new Map,this._needsSort=!1,this._lastZIndex=0,this._pluginsInitialized=!1;const e=i.canvas.size;this.quadTree=new D(O(e),n.Kw),this.movers=[],this.updaters=[]}get count(){return this._array.length}addParticle(t,i,e,s){const a=this._container.actualOptions.particles.number.limit.mode,r=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,o=this.count;if(r>n.ou)switch(a){case f.d.delete:{const t=o+n.nq-r;t>n.wM&&this.removeQuantity(t);break}case f.d.wait:if(o>=r)return}return this._pushParticle(t,i,e,s)}clear(){this._array=[],this._zArray=[],this._pluginsInitialized=!1}destroy(){this._array=[],this._zArray=[],this.movers=[],this.updaters=[]}drawParticles(t){for(const i of this._zArray)i.draw(t)}filter(t){return this._array.filter(t)}find(t){return this._array.find(t)}get(t){return this._array[t]}async init(){const t=this._container,i=t.actualOptions;this._lastZIndex=0,this._needsSort=!1;for(const i of t.plugins)i.redrawInit&&await i.redrawInit();await this.initPlugins();let e=!1;for(const i of t.plugins)if(e=i.particlesInitialization?.()??e,e)break;if(!e){const t=i.particles,e=t.groups;for(const i in e){const s=e[i];if(s)for(let e=this.count,n=0;n<s.number.value&&e<t.number.value;e++,n++)this.addParticle(void 0,s,i)}for(let i=this.count;i<t.number.value;i++)this.addParticle()}}async initPlugins(){if(this._pluginsInitialized)return;const t=this._container;this.movers=await this._engine.getMovers(t,!0),this.updaters=await this._engine.getUpdaters(t,!0);for(const i of t.pathGenerators.values())i.init(t)}push(t,i,e,s){for(let n=0;n<t;n++)this.addParticle(i,e,s)}async redraw(){this.clear(),await this.init(),this._container.canvas.drawParticles({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=n.xd,e,s){if(t<n.z9||t>this.count)return;let a=0;for(let n=t;a<i&&n<this.count;n++)this._removeParticle(n,e,s)&&(n--,a++)}removeQuantity(t,i){this.removeAt(n.z9,t,i)}setDensity(){const t=this._container.actualOptions,i=t.particles.groups;let e=0;for(const t of this._container.plugins)t.particlesDensityCount&&(e+=t.particlesDensityCount());for(const t in i){const s=i[t];if(!s)continue;const n=(0,v.y)(this._engine,this._container,s);this._applyDensity(n,e,t)}this._applyDensity(t.particles,e)}setLastZIndex(t){this._lastZIndex=t,this._needsSort=this._needsSort||this._lastZIndex<t}setResizeFactor(t){this._resizeFactor=t}update(t){const i=this._container,e=new Set;this.quadTree=new D(O(i.canvas.size),n.Kw);for(const t of i.pathGenerators.values())t.update();for(const e of i.plugins)e.update?.(t);const s=this._resizeFactor;for(const i of this._array){s&&!i.ignoresResizeRatio&&(i.position.x*=s.width,i.position.y*=s.height,i.initialPosition.x*=s.width,i.initialPosition.y*=s.height),i.ignoresResizeRatio=!1;for(const t of this._container.plugins)t.particleReset&&t.particleReset(i);for(const e of this._container.plugins){if(i.destroyed)break;e.particleUpdate?.(i,t)}for(const e of this.movers)e.isEnabled(i)&&e.move(i,t);i.destroyed?e.add(i):this.quadTree.insert(new z.b(i.getPosition(),i))}if(e.size){const t=t=>!e.has(t);this._array=this.filter(t),this._zArray=this._zArray.filter(t);for(const t of e)this._engine.dispatchEvent(p.B.particleRemoved,{container:this._container,data:{particle:t}});this._addToPool(...e)}for(const e of i.plugins)e.postUpdate&&e.postUpdate(t);for(const e of this._array){for(const i of this.updaters)i.update(e,t);if(!e.destroyed&&!e.spawning)for(const s of i.plugins)s.postParticleUpdate&&s.postParticleUpdate(e,t)}if(delete this._resizeFactor,this._needsSort){const t=this._zArray;t.sort(((t,i)=>i.position.z-t.position.z||t.id-i.id));const i=t[t.length-n.K3];if(!i)return;this._lastZIndex=i.position.z,this._needsSort=!1}}}class R{constructor(t){this.container=t,this.pixelRatio=n.$x,this.reduceFactor=n.Zp}init(){const t=this.container,i=t.actualOptions;this.pixelRatio=i.detectRetina?devicePixelRatio:n.$x,this.reduceFactor=n.Zp;const e=this.pixelRatio,a=t.canvas;if(a.element){const t=a.element;a.size.width=t.offsetWidth*e,a.size.height=t.offsetHeight*e}const r=i.particles,o=r.move;this.maxSpeed=(0,s.VG)(o.gravity.maxSpeed)*e,this.sizeAnimationSpeed=(0,s.VG)(r.size.animation.speed)*e}initParticle(t){const i=t.options,e=this.pixelRatio,n=i.move,a=n.distance,r=t.retina;r.moveDrift=(0,s.VG)(n.drift)*e,r.moveSpeed=(0,s.VG)(n.speed)*e,r.sizeAnimationSpeed=(0,s.VG)(i.size.animation.speed)*e;const o=r.maxDistance;o.horizontal=void 0!==a.horizontal?a.horizontal*e:void 0,o.vertical=void 0!==a.vertical?a.vertical*e:void 0,r.maxSpeed=(0,s.VG)(n.gravity.maxSpeed)*e}}function C(t){return!t.destroyed}function T(t,i,...e){const s=new u.J(t,i);return(0,v.Z)(s,...e),s}class M{constructor(t,i,e){this._delta={value:0,factor:0},this._nextFrame=t=>{try{if(!this._smooth&&void 0!==this._lastFrameTime&&t<this._lastFrameTime+n.Xu/this.fpsLimit)return void this.draw(!1);if(this._lastFrameTime??=t,function(t,i,e=n.z$,s=!1){t.value=i,t.factor=s?n.z$/e:n.z$*i/n.Xu}(this._delta,t-this._lastFrameTime,this.fpsLimit,this._smooth),this.addLifeTime(this._delta.value),this._lastFrameTime=t,this._delta.value>n.Xu)return void this.draw(!1);if(this.canvas.drawParticles(this._delta),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,x.t)().error("error in animation loop",t)}},this._engine=t,this.id=Symbol(i),this.fpsLimit=120,this.hdr=!1,this._smooth=!1,this._delay=0,this._duration=0,this._lifeTime=0,this._firstStart=!0,this.started=!1,this.destroyed=!1,this._paused=!0,this._lastFrameTime=0,this.zLayers=100,this.pageHidden=!1,this._sourceOptions=e,this._initialSourceOptions=e,this.retina=new R(this),this.canvas=new l(this,this._engine),this.particles=new S(this._engine,this),this.pathGenerators=new Map,this.plugins=[],this.effectDrawers=new Map,this.shapeDrawers=new Map,this._options=T(this._engine,this),this.actualOptions=T(this._engine,this),this._eventListeners=new d(this),this._engine.dispatchEvent(p.B.containerBuilt,{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&C(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addLifeTime(t){this._lifeTime+=t}addPath(t,i,e=!1){return!(!C(this)||!e&&this.pathGenerators.has(t))&&(this.pathGenerators.set(t,i),!0)}alive(){return!this._duration||this._lifeTime<=this._duration}destroy(t=!0){if(C(this)){this.stop(),this.particles.destroy(),this.canvas.destroy();for(const t of this.effectDrawers.values())t.destroy?.(this);this.effectDrawers.clear();for(const t of this.shapeDrawers.values())t.destroy?.(this);this.shapeDrawers.clear();for(const t of this.plugins)t.destroy?.();if(this.plugins.length=0,this._engine.clearPlugins(this),this.destroyed=!0,t){const t=this._engine.items,i=t.indexOf(this);i>=n.vF&&t.splice(i,n.JC)}this._engine.dispatchEvent(p.B.containerDestroyed,{container:this})}}draw(t){if(!C(this))return;let i=t;const e=t=>{i&&(this._lastFrameTime=void 0,i=!1),this._nextFrame(t)};this._drawAnimationFrame=(0,s.i0)((t=>{e(t)}))}async export(t,i={}){for(const e of this.plugins){if(!e.export)continue;const s=await e.export(t,i);if(s.supported)return s.blob}(0,x.t)().error(`Export plugin with type ${t} not found`)}async init(){if(!C(this))return;const t=this._engine.getSupportedEffects();for(const i of t){const t=this._engine.getEffectDrawer(i);t&&this.effectDrawers.set(i,t)}const i=this._engine.getSupportedShapes();for(const t of i){const i=this._engine.getShapeDrawer(t);i&&this.shapeDrawers.set(t,i)}const e=new Map;for(const t of this._engine.plugins){const i=await t.getPlugin(this);i.preInit&&await i.preInit(),e.set(t,i)}await this.particles.initPlugins(),this._options=T(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=T(this._engine,this,this._options);for(const[t,i]of e)t.needsPlugin(this.actualOptions)&&this.plugins.push(i);this.retina.init(),this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();const{delay:a,duration:r,fpsLimit:o,hdr:h,smooth:c,zLayers:l}=this.actualOptions;this.hdr=h,this.zLayers=l,this._duration=(0,s.VG)(r)*n.Xu,this._delay=(0,s.VG)(a)*n.Xu,this._lifeTime=0,this.fpsLimit=o>n.DN?o:n.i8,this._smooth=c;for(const t of this.plugins)await(t.init?.());for(const t of this.effectDrawers.values())await(t.init?.(this));for(const t of this.shapeDrawers.values())await(t.init?.(this));this._engine.dispatchEvent(p.B.containerInit,{container:this}),await this.particles.init(),this.particles.setDensity();for(const t of this.plugins)t.particlesSetup?.();this._engine.dispatchEvent(p.B.particlesSetup,{container:this})}pause(){if(C(this)&&(void 0!==this._drawAnimationFrame&&((0,s.px)(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(const t of this.plugins)t.pause?.();this.pageHidden||(this._paused=!0),this._engine.dispatchEvent(p.B.containerPaused,{container:this})}}play(t){if(!C(this))return;const i=this._paused||t;if(!this._firstStart||this.actualOptions.autoPlay){if(this._paused&&(this._paused=!1),i)for(const t of this.plugins)t.play&&t.play();this._engine.dispatchEvent(p.B.containerPlay,{container:this}),this.draw(i??!1)}else this._firstStart=!1}async refresh(){if(C(this))return this.stop(),this.start()}async reset(t){if(C(this))return this._initialSourceOptions=t,this._sourceOptions=t,this._options=T(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=T(this._engine,this,this._options),this.refresh()}async start(){C(this)&&!this.started&&(await this.init(),this.started=!0,await new Promise((t=>{const i=async()=>{this._eventListeners.addListeners();for(const t of this.plugins)await(t.start?.());this._engine.dispatchEvent(p.B.containerStarted,{container:this}),this.play(),t()};this._delayTimeout=setTimeout((()=>{i()}),this._delay)})))}stop(){if(C(this)&&this.started){this._delayTimeout&&(clearTimeout(this._delayTimeout),delete this._delayTimeout),this._firstStart=!0,this.started=!1,this._eventListeners.removeListeners(),this.pause(),this.particles.clear(),this.canvas.stop();for(const t of this.plugins)t.stop?.();this.plugins.length=0,this._sourceOptions=this._options,this._engine.dispatchEvent(p.B.containerStopped,{container:this})}}updateActualOptions(){let t=!1;for(const i of this.plugins)i.updateActualOptions&&(t=i.updateActualOptions()||t);return t}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Engine v4.0.0-alpha.4 by Matteo Bruni */
package/README.md CHANGED
@@ -295,7 +295,7 @@ tsParticles.setOnClickHandler((event, particles) => {
295
295
  // now you can control the animations too, it's possible to pause and resume the animations
296
296
  // these methods don't change the config so you're safe with all your configurations
297
297
  // domItem(0) returns the first tsParticles instance loaded in the dom
298
- const particles = tsParticles.domItem(0);
298
+ const particles = tsParticles.item(0);
299
299
 
300
300
  // play will start the animations, if the move is not enabled it won't enable it, it just updates the frame
301
301
  particles.play();
@@ -755,6 +755,7 @@ flowchart TD
755
755
  interaction-external-bubble[Bubble]
756
756
  interaction-external-connect[Connect]
757
757
  interaction-external-grab[Grab]
758
+ interaction-external-parallax[Parallax]
758
759
  interaction-external-pause[Pause]
759
760
  interaction-external-push[Push]
760
761
  interaction-external-remove[Remove]
@@ -770,10 +771,6 @@ flowchart TD
770
771
 
771
772
  end
772
773
 
773
- subgraph slim-movers [Movers]
774
- move-parallax[Parallax]
775
- end
776
-
777
774
  subgraph slim-plugins [Plugins]
778
775
 
779
776
  subgraph slim-plugins-easings [Easings]
@@ -184,7 +184,7 @@ export class Canvas {
184
184
  }
185
185
  clear() {
186
186
  let pluginHandled = false;
187
- for (const plugin of this.container.plugins.values()) {
187
+ for (const plugin of this.container.plugins) {
188
188
  if (!pluginHandled && plugin.canvasClear) {
189
189
  pluginHandled = plugin.canvasClear();
190
190
  }
@@ -322,7 +322,7 @@ export class Canvas {
322
322
  }
323
323
  initPlugins() {
324
324
  this._resizePlugins = [];
325
- for (const plugin of this.container.plugins.values()) {
325
+ for (const plugin of this.container.plugins) {
326
326
  if (plugin.resize) {
327
327
  this._resizePlugins.push(plugin);
328
328
  }
@@ -380,7 +380,7 @@ export class Canvas {
380
380
  }
381
381
  paint() {
382
382
  let handled = false;
383
- for (const plugin of this.container.plugins.values()) {
383
+ for (const plugin of this.container.plugins) {
384
384
  if (handled) {
385
385
  break;
386
386
  }
@@ -1,5 +1,5 @@
1
1
  import { animate, cancelAnimation, getRangeValue } from "../Utils/MathUtils.js";
2
- import { clickRadius, defaultFps, defaultFpsLimit, millisecondsToSeconds, minCoordinate, minFpsLimit, removeDeleteCount, removeMinIndex, touchEndLengthOffset, } from "./Utils/Constants.js";
2
+ import { defaultFps, defaultFpsLimit, millisecondsToSeconds, minFpsLimit, removeDeleteCount, removeMinIndex, } from "./Utils/Constants.js";
3
3
  import { Canvas } from "./Canvas.js";
4
4
  import { EventListeners } from "./Utils/EventListeners.js";
5
5
  import { EventType } from "../Enums/Types/EventType.js";
@@ -8,7 +8,6 @@ import { Particles } from "./Particles.js";
8
8
  import { Retina } from "./Retina.js";
9
9
  import { getLogger } from "../Utils/LogUtils.js";
10
10
  import { loadOptions } from "../Utils/OptionsUtils.js";
11
- import { safeIntersectionObserver } from "../Utils/Utils.js";
12
11
  function guardCheck(container) {
13
12
  return !container.destroyed;
14
13
  }
@@ -24,22 +23,6 @@ function loadContainerOptions(engine, container, ...sourceOptionsArr) {
24
23
  export class Container {
25
24
  constructor(engine, id, sourceOptions) {
26
25
  this._delta = { value: 0, factor: 0 };
27
- this._intersectionManager = entries => {
28
- if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
29
- return;
30
- }
31
- for (const entry of entries) {
32
- if (entry.target !== this.interactivity.element) {
33
- continue;
34
- }
35
- if (entry.isIntersecting) {
36
- this.play();
37
- }
38
- else {
39
- this.pause();
40
- }
41
- }
42
- };
43
26
  this._nextFrame = (timestamp) => {
44
27
  try {
45
28
  if (!this._smooth &&
@@ -84,28 +67,18 @@ export class Container {
84
67
  this._lastFrameTime = 0;
85
68
  this.zLayers = 100;
86
69
  this.pageHidden = false;
87
- this._clickHandlers = new Map();
88
70
  this._sourceOptions = sourceOptions;
89
71
  this._initialSourceOptions = sourceOptions;
90
72
  this.retina = new Retina(this);
91
73
  this.canvas = new Canvas(this, this._engine);
92
74
  this.particles = new Particles(this._engine, this);
93
75
  this.pathGenerators = new Map();
94
- this.interactivity = {
95
- mouse: {
96
- clicking: false,
97
- inside: false,
98
- },
99
- };
100
- this.plugins = new Map();
76
+ this.plugins = [];
101
77
  this.effectDrawers = new Map();
102
78
  this.shapeDrawers = new Map();
103
79
  this._options = loadContainerOptions(this._engine, this);
104
80
  this.actualOptions = loadContainerOptions(this._engine, this);
105
81
  this._eventListeners = new EventListeners(this);
106
- this._intersectionObserver = safeIntersectionObserver(entries => {
107
- this._intersectionManager(entries);
108
- });
109
82
  this._engine.dispatchEvent(EventType.containerBuilt, { container: this });
110
83
  }
111
84
  get animationStatus() {
@@ -117,77 +90,6 @@ export class Container {
117
90
  get sourceOptions() {
118
91
  return this._sourceOptions;
119
92
  }
120
- addClickHandler(callback) {
121
- if (!guardCheck(this)) {
122
- return;
123
- }
124
- const el = this.interactivity.element;
125
- if (!el) {
126
- return;
127
- }
128
- const clickOrTouchHandler = (e, pos, radius) => {
129
- if (!guardCheck(this)) {
130
- return;
131
- }
132
- const pxRatio = this.retina.pixelRatio, posRetina = {
133
- x: pos.x * pxRatio,
134
- y: pos.y * pxRatio,
135
- }, particles = this.particles.quadTree.queryCircle(posRetina, radius * pxRatio);
136
- callback(e, particles);
137
- }, clickHandler = (e) => {
138
- if (!guardCheck(this)) {
139
- return;
140
- }
141
- const mouseEvent = e, pos = {
142
- x: mouseEvent.offsetX || mouseEvent.clientX,
143
- y: mouseEvent.offsetY || mouseEvent.clientY,
144
- };
145
- clickOrTouchHandler(e, pos, clickRadius);
146
- }, touchStartHandler = () => {
147
- if (!guardCheck(this)) {
148
- return;
149
- }
150
- touched = true;
151
- touchMoved = false;
152
- }, touchMoveHandler = () => {
153
- if (!guardCheck(this)) {
154
- return;
155
- }
156
- touchMoved = true;
157
- }, touchEndHandler = (e) => {
158
- if (!guardCheck(this)) {
159
- return;
160
- }
161
- if (touched && !touchMoved) {
162
- const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - touchEndLengthOffset];
163
- if (!lastTouch) {
164
- return;
165
- }
166
- const element = this.canvas.element, canvasRect = element ? element.getBoundingClientRect() : undefined, pos = {
167
- x: lastTouch.clientX - (canvasRect ? canvasRect.left : minCoordinate),
168
- y: lastTouch.clientY - (canvasRect ? canvasRect.top : minCoordinate),
169
- };
170
- clickOrTouchHandler(e, pos, Math.max(lastTouch.radiusX, lastTouch.radiusY));
171
- }
172
- touched = false;
173
- touchMoved = false;
174
- }, touchCancelHandler = () => {
175
- if (!guardCheck(this)) {
176
- return;
177
- }
178
- touched = false;
179
- touchMoved = false;
180
- };
181
- let touched = false, touchMoved = false;
182
- this._clickHandlers.set("click", clickHandler);
183
- this._clickHandlers.set("touchstart", touchStartHandler);
184
- this._clickHandlers.set("touchmove", touchMoveHandler);
185
- this._clickHandlers.set("touchend", touchEndHandler);
186
- this._clickHandlers.set("touchcancel", touchCancelHandler);
187
- for (const [key, handler] of this._clickHandlers) {
188
- el.addEventListener(key, handler);
189
- }
190
- }
191
93
  addLifeTime(value) {
192
94
  this._lifeTime += value;
193
95
  }
@@ -201,21 +103,11 @@ export class Container {
201
103
  alive() {
202
104
  return !this._duration || this._lifeTime <= this._duration;
203
105
  }
204
- clearClickHandlers() {
205
- if (!guardCheck(this)) {
206
- return;
207
- }
208
- for (const [key, handler] of this._clickHandlers) {
209
- this.interactivity.element?.removeEventListener(key, handler);
210
- }
211
- this._clickHandlers.clear();
212
- }
213
106
  destroy(remove = true) {
214
107
  if (!guardCheck(this)) {
215
108
  return;
216
109
  }
217
110
  this.stop();
218
- this.clearClickHandlers();
219
111
  this.particles.destroy();
220
112
  this.canvas.destroy();
221
113
  for (const effectDrawer of this.effectDrawers.values()) {
@@ -226,10 +118,14 @@ export class Container {
226
118
  shapeDrawer.destroy?.(this);
227
119
  }
228
120
  this.shapeDrawers.clear();
121
+ for (const plugin of this.plugins) {
122
+ plugin.destroy?.();
123
+ }
124
+ this.plugins.length = 0;
229
125
  this._engine.clearPlugins(this);
230
126
  this.destroyed = true;
231
127
  if (remove) {
232
- const mainArr = this._engine.items, idx = mainArr.findIndex(t => t === this);
128
+ const mainArr = this._engine.items, idx = mainArr.indexOf(this);
233
129
  if (idx >= removeMinIndex) {
234
130
  mainArr.splice(idx, removeDeleteCount);
235
131
  }
@@ -253,7 +149,7 @@ export class Container {
253
149
  });
254
150
  }
255
151
  async export(type, options = {}) {
256
- for (const plugin of this.plugins.values()) {
152
+ for (const plugin of this.plugins) {
257
153
  if (!plugin.export) {
258
154
  continue;
259
155
  }
@@ -266,15 +162,6 @@ export class Container {
266
162
  getLogger().error(`Export plugin with type ${type} not found`);
267
163
  return undefined;
268
164
  }
269
- handleClickMode(mode) {
270
- if (!guardCheck(this)) {
271
- return;
272
- }
273
- this.particles.handleClickMode(mode);
274
- for (const plugin of this.plugins.values()) {
275
- plugin.handleClickMode?.(mode);
276
- }
277
- }
278
165
  async init() {
279
166
  if (!guardCheck(this)) {
280
167
  return;
@@ -293,12 +180,21 @@ export class Container {
293
180
  this.shapeDrawers.set(type, drawer);
294
181
  }
295
182
  }
183
+ const allContainerPlugins = new Map();
184
+ for (const plugin of this._engine.plugins) {
185
+ const containerPlugin = await plugin.getPlugin(this);
186
+ if (containerPlugin.preInit) {
187
+ await containerPlugin.preInit();
188
+ }
189
+ allContainerPlugins.set(plugin, containerPlugin);
190
+ }
296
191
  await this.particles.initPlugins();
297
192
  this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
298
193
  this.actualOptions = loadContainerOptions(this._engine, this, this._options);
299
- const availablePlugins = await this._engine.getAvailablePlugins(this);
300
- for (const [id, plugin] of availablePlugins) {
301
- this.plugins.set(id, plugin);
194
+ for (const [plugin, containerPlugin] of allContainerPlugins) {
195
+ if (plugin.needsPlugin(this.actualOptions)) {
196
+ this.plugins.push(containerPlugin);
197
+ }
302
198
  }
303
199
  this.retina.init();
304
200
  this.canvas.init();
@@ -313,30 +209,23 @@ export class Container {
313
209
  this._lifeTime = 0;
314
210
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
315
211
  this._smooth = smooth;
212
+ for (const plugin of this.plugins) {
213
+ await plugin.init?.();
214
+ }
316
215
  for (const drawer of this.effectDrawers.values()) {
317
216
  await drawer.init?.(this);
318
217
  }
319
218
  for (const drawer of this.shapeDrawers.values()) {
320
219
  await drawer.init?.(this);
321
220
  }
322
- for (const plugin of this.plugins.values()) {
323
- await plugin.init?.();
324
- }
325
221
  this._engine.dispatchEvent(EventType.containerInit, { container: this });
326
222
  await this.particles.init();
327
223
  this.particles.setDensity();
328
- for (const plugin of this.plugins.values()) {
224
+ for (const plugin of this.plugins) {
329
225
  plugin.particlesSetup?.();
330
226
  }
331
227
  this._engine.dispatchEvent(EventType.particlesSetup, { container: this });
332
228
  }
333
- async loadTheme(name) {
334
- if (!guardCheck(this)) {
335
- return;
336
- }
337
- this._currentTheme = name;
338
- await this.refresh();
339
- }
340
229
  pause() {
341
230
  if (!guardCheck(this)) {
342
231
  return;
@@ -348,7 +237,7 @@ export class Container {
348
237
  if (this._paused) {
349
238
  return;
350
239
  }
351
- for (const plugin of this.plugins.values()) {
240
+ for (const plugin of this.plugins) {
352
241
  plugin.pause?.();
353
242
  }
354
243
  if (!this.pageHidden) {
@@ -369,7 +258,7 @@ export class Container {
369
258
  this._paused = false;
370
259
  }
371
260
  if (needsUpdate) {
372
- for (const plugin of this.plugins.values()) {
261
+ for (const plugin of this.plugins) {
373
262
  if (plugin.play) {
374
263
  plugin.play();
375
264
  }
@@ -404,10 +293,7 @@ export class Container {
404
293
  await new Promise(resolve => {
405
294
  const start = async () => {
406
295
  this._eventListeners.addListeners();
407
- if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
408
- this._intersectionObserver.observe(this.interactivity.element);
409
- }
410
- for (const plugin of this.plugins.values()) {
296
+ for (const plugin of this.plugins) {
411
297
  await plugin.start?.();
412
298
  }
413
299
  this._engine.dispatchEvent(EventType.containerStarted, { container: this });
@@ -431,26 +317,20 @@ export class Container {
431
317
  this.pause();
432
318
  this.particles.clear();
433
319
  this.canvas.stop();
434
- if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
435
- this._intersectionObserver.unobserve(this.interactivity.element);
436
- }
437
- for (const plugin of this.plugins.values()) {
320
+ for (const plugin of this.plugins) {
438
321
  plugin.stop?.();
439
322
  }
440
- for (const key of this.plugins.keys()) {
441
- this.plugins.delete(key);
442
- }
323
+ this.plugins.length = 0;
443
324
  this._sourceOptions = this._options;
444
325
  this._engine.dispatchEvent(EventType.containerStopped, { container: this });
445
326
  }
446
327
  updateActualOptions() {
447
- this.actualOptions.responsive = [];
448
- const newMaxWidth = this.actualOptions.setResponsive(this.canvas.size.width, this.retina.pixelRatio, this._options);
449
- this.actualOptions.setTheme(this._currentTheme);
450
- if (this._responsiveMaxWidth === newMaxWidth) {
451
- return false;
328
+ let refresh = false;
329
+ for (const plugin of this.plugins) {
330
+ if (plugin.updateActualOptions) {
331
+ refresh = plugin.updateActualOptions() || refresh;
332
+ }
452
333
  }
453
- this._responsiveMaxWidth = newMaxWidth;
454
- return true;
334
+ return refresh;
455
335
  }
456
336
  }
@@ -1,18 +1,10 @@
1
1
  import { canvasFirstIndex, canvasTag, generatedAttribute, generatedFalse, generatedTrue, loadMinIndex, loadRandomFactor, none, one, removeDeleteCount, } from "./Utils/Constants.js";
2
- import { itemFromSingleOrMultiple, safeDocument } from "../Utils/Utils.js";
2
+ import { getItemsFromInitializer, itemFromSingleOrMultiple, safeDocument } from "../Utils/Utils.js";
3
3
  import { EventDispatcher } from "../Utils/EventDispatcher.js";
4
4
  import { EventType } from "../Enums/Types/EventType.js";
5
5
  import { getLogger } from "../Utils/LogUtils.js";
6
6
  import { getRandom } from "../Utils/MathUtils.js";
7
7
  const fullPercent = "100%";
8
- async function getItemsFromInitializer(container, map, initializers, force = false) {
9
- let res = map.get(container);
10
- if (!res || force) {
11
- res = await Promise.all([...initializers.values()].map(t => t(container)));
12
- map.set(container, res);
13
- }
14
- return res;
15
- }
16
8
  async function getDataFromUrl(data) {
17
9
  const url = itemFromSingleOrMultiple(data.url, data.index);
18
10
  if (!url) {
@@ -49,7 +41,7 @@ const getCanvasFromContainer = (domContainer) => {
49
41
  return canvasEl;
50
42
  }, getDomContainer = (id, source) => {
51
43
  const documentSafe = safeDocument();
52
- let domContainer = source ?? document.getElementById(id);
44
+ let domContainer = source ?? documentSafe.getElementById(id);
53
45
  if (domContainer) {
54
46
  return domContainer;
55
47
  }
@@ -70,11 +62,9 @@ export class Engine {
70
62
  this.colorManagers = new Map();
71
63
  this.easingFunctions = new Map();
72
64
  this._initializers = {
73
- interactors: new Map(),
74
65
  movers: new Map(),
75
66
  updaters: new Map(),
76
67
  };
77
- this.interactors = new Map();
78
68
  this.movers = new Map();
79
69
  this.updaters = new Map();
80
70
  this.presets = new Map();
@@ -93,7 +83,7 @@ export class Engine {
93
83
  return this._domArray;
94
84
  }
95
85
  get version() {
96
- return "4.0.0-alpha.3";
86
+ return "4.0.0-alpha.4";
97
87
  }
98
88
  addColorManager(manager) {
99
89
  this.colorManagers.set(manager.key, manager);
@@ -118,9 +108,6 @@ export class Engine {
118
108
  addEventListener(type, listener) {
119
109
  this._eventDispatcher.addEventListener(type, listener);
120
110
  }
121
- addInteractor(name, interactorInitializer) {
122
- this._initializers.interactors.set(name, interactorInitializer);
123
- }
124
111
  addMover(name, moverInitializer) {
125
112
  this._initializers.movers.set(name, moverInitializer);
126
113
  }
@@ -162,35 +149,16 @@ export class Engine {
162
149
  clearPlugins(container) {
163
150
  this.updaters.delete(container);
164
151
  this.movers.delete(container);
165
- this.interactors.delete(container);
166
152
  }
167
153
  dispatchEvent(type, args) {
168
154
  this._eventDispatcher.dispatchEvent(type, args);
169
155
  }
170
- dom() {
171
- return this.items;
172
- }
173
- domItem(index) {
174
- return this.item(index);
175
- }
176
- async getAvailablePlugins(container) {
177
- const res = new Map();
178
- for (const plugin of this.plugins) {
179
- if (plugin.needsPlugin(container.actualOptions)) {
180
- res.set(plugin.id, await plugin.getPlugin(container));
181
- }
182
- }
183
- return res;
184
- }
185
156
  getEasing(name) {
186
157
  return this.easingFunctions.get(name) ?? ((value) => value);
187
158
  }
188
159
  getEffectDrawer(type) {
189
160
  return this.effectDrawers.get(type);
190
161
  }
191
- async getInteractors(container, force = false) {
192
- return getItemsFromInitializer(container, this.interactors, this._initializers.interactors, force);
193
- }
194
162
  async getMovers(container, force = false) {
195
163
  return getItemsFromInitializer(container, this.movers, this._initializers.movers, force);
196
164
  }
@@ -236,8 +204,12 @@ export class Engine {
236
204
  allLoaders.add(loader);
237
205
  }
238
206
  };
239
- await loader(this);
240
- this.register = origRegister;
207
+ try {
208
+ await loader(this);
209
+ }
210
+ finally {
211
+ this.register = origRegister;
212
+ }
241
213
  stack.unshift(...inner);
242
214
  this._loadPromises.delete(loader);
243
215
  }
@@ -257,6 +229,7 @@ export class Engine {
257
229
  }
258
230
  async load(params) {
259
231
  await this.init();
232
+ this._loadPromises.clear();
260
233
  const { Container } = await import("./Container.js"), id = params.id ??
261
234
  params.element?.id ??
262
235
  `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container(this, id, currentOptions);
@@ -275,11 +248,6 @@ export class Engine {
275
248
  await newItem.start();
276
249
  return newItem;
277
250
  }
278
- loadOptions(options, sourceOptions) {
279
- this.plugins.forEach(plugin => {
280
- plugin.loadOptions(options, sourceOptions);
281
- });
282
- }
283
251
  loadParticlesOptions(container, options, ...sourceOptions) {
284
252
  const updaters = this.updaters.get(container);
285
253
  if (!updaters) {
@@ -304,13 +272,4 @@ export class Engine {
304
272
  removeEventListener(type, listener) {
305
273
  this._eventDispatcher.removeEventListener(type, listener);
306
274
  }
307
- setOnClickHandler(callback) {
308
- const { items } = this;
309
- if (!items.length) {
310
- throw new Error("Click handlers can only be set after calling tsParticles.load()");
311
- }
312
- items.forEach(item => {
313
- item.addClickHandler(callback);
314
- });
315
- }
316
275
  }
@@ -3,7 +3,6 @@ import { calcExactPositionOrRandomFromSize, clamp, degToRad, getParticleBaseVelo
3
3
  import { decayOffset, defaultAngle, defaultOpacity, defaultRetryCount, defaultTransform, double, half, identity, millisecondsToSeconds, minZ, none, randomColorValue, rollFactor, squareExp, tryCountIncrement, zIndexFactorOffset, } from "./Utils/Constants.js";
4
4
  import { deepExtend, getPosition, initParticleNumericAnimationValue, isInArray, itemFromSingleOrMultiple, } from "../Utils/Utils.js";
5
5
  import { EventType } from "../Enums/Types/EventType.js";
6
- import { Interactivity } from "../Options/Classes/Interactivity/Interactivity.js";
7
6
  import { MoveDirection } from "../Enums/Directions/MoveDirection.js";
8
7
  import { OutMode } from "../Enums/Modes/OutMode.js";
9
8
  import { ParticleOutType } from "../Enums/Types/ParticleOutType.js";
@@ -53,7 +52,7 @@ export class Particle {
53
52
  };
54
53
  this._calcPosition = (position, zIndex) => {
55
54
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
56
- const container = this.container, plugins = Array.from(container.plugins.values()), outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
55
+ const container = this.container, plugins = Array.from(container.plugins), outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
57
56
  while (!signal.aborted) {
58
57
  for (const plugin of plugins) {
59
58
  const pluginPos = plugin.particlePosition?.(posVec, this);
@@ -173,7 +172,7 @@ export class Particle {
173
172
  this.slow.inRange = false;
174
173
  const container = this.container, pathGenerator = this.pathGenerator, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
175
174
  shapeDrawer?.particleDestroy?.(this);
176
- for (const plugin of container.plugins.values()) {
175
+ for (const plugin of container.plugins) {
177
176
  plugin.particleDestroyed?.(this, override);
178
177
  }
179
178
  for (const updater of container.particles.updaters) {
@@ -189,7 +188,7 @@ export class Particle {
189
188
  }
190
189
  draw(delta) {
191
190
  const container = this.container, canvas = container.canvas;
192
- for (const plugin of container.plugins.values()) {
191
+ for (const plugin of container.plugins) {
193
192
  canvas.drawParticlePlugin(plugin, this, delta);
194
193
  }
195
194
  canvas.drawParticle(this, delta);
@@ -240,7 +239,7 @@ export class Particle {
240
239
  return this._cachedTransform;
241
240
  }
242
241
  init(id, position, overrideOptions, group) {
243
- const container = this.container, engine = this._engine;
242
+ const container = this.container;
244
243
  this.id = id;
245
244
  this.group = group;
246
245
  this.effectClose = true;
@@ -300,10 +299,6 @@ export class Particle {
300
299
  if (shapeData) {
301
300
  particlesOptions.load(shapeData.particles);
302
301
  }
303
- const interactivity = new Interactivity(engine, container);
304
- interactivity.load(container.actualOptions.interactivity);
305
- interactivity.load(particlesOptions.interactivity);
306
- this.interactivity = interactivity;
307
302
  this.effectFill = effectData?.fill ?? particlesOptions.effect.fill;
308
303
  this.effectClose = effectData?.close ?? particlesOptions.effect.close;
309
304
  this.shapeFill = shapeData?.fill ?? particlesOptions.shape.fill;
@@ -372,7 +367,7 @@ export class Particle {
372
367
  }
373
368
  effectDrawer?.particleInit?.(container, this);
374
369
  shapeDrawer?.particleInit?.(container, this);
375
- for (const plugin of container.plugins.values()) {
370
+ for (const plugin of container.plugins) {
376
371
  plugin.particleCreated?.(this);
377
372
  }
378
373
  }