UNPKG

272 kBJavaScriptView Raw
1/*!
2 * Author : Matteo Bruni
3 * MIT license: https://opensource.org/licenses/MIT
4 * Demo / Generator : https://particles.js.org/
5 * GitHub : https://www.github.com/matteobruni/tsparticles
6 * How to use? : Check the GitHub README
7 * v2.9.3
8 */
9(function webpackUniversalModuleDefinition(root, factory) {
10 if(typeof exports === 'object' && typeof module === 'object')
11 module.exports = factory();
12 else if(typeof define === 'function' && define.amd)
13 define([], factory);
14 else {
15 var a = factory();
16 for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17 }
18})(this, () => {
19return /******/ (() => { // webpackBootstrap
20/******/ "use strict";
21/******/ // The require scope
22/******/ var __webpack_require__ = {};
23/******/
24/************************************************************************/
25/******/ /* webpack/runtime/define property getters */
26/******/ (() => {
27/******/ // define getter functions for harmony exports
28/******/ __webpack_require__.d = (exports, definition) => {
29/******/ for(var key in definition) {
30/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
31/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
32/******/ }
33/******/ }
34/******/ };
35/******/ })();
36/******/
37/******/ /* webpack/runtime/hasOwnProperty shorthand */
38/******/ (() => {
39/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
40/******/ })();
41/******/
42/******/ /* webpack/runtime/make namespace object */
43/******/ (() => {
44/******/ // define __esModule on exports
45/******/ __webpack_require__.r = (exports) => {
46/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48/******/ }
49/******/ Object.defineProperty(exports, '__esModule', { value: true });
50/******/ };
51/******/ })();
52/******/
53/************************************************************************/
54var __webpack_exports__ = {};
55// ESM COMPAT FLAG
56__webpack_require__.r(__webpack_exports__);
57
58// EXPORTS
59__webpack_require__.d(__webpack_exports__, {
60 "AnimatableColor": () => (/* reexport */ AnimatableColor),
61 "AnimationOptions": () => (/* reexport */ AnimationOptions),
62 "Background": () => (/* reexport */ Background),
63 "BackgroundMask": () => (/* reexport */ BackgroundMask),
64 "BackgroundMaskCover": () => (/* reexport */ BackgroundMaskCover),
65 "Circle": () => (/* reexport */ Circle),
66 "ClickEvent": () => (/* reexport */ ClickEvent),
67 "Collisions": () => (/* reexport */ Collisions),
68 "CollisionsAbsorb": () => (/* reexport */ CollisionsAbsorb),
69 "CollisionsOverlap": () => (/* reexport */ CollisionsOverlap),
70 "ColorAnimation": () => (/* reexport */ ColorAnimation),
71 "DivEvent": () => (/* reexport */ DivEvent),
72 "Events": () => (/* reexport */ Events),
73 "ExternalInteractorBase": () => (/* reexport */ ExternalInteractorBase),
74 "FullScreen": () => (/* reexport */ FullScreen),
75 "HoverEvent": () => (/* reexport */ HoverEvent),
76 "HslAnimation": () => (/* reexport */ HslAnimation),
77 "HslColorManager": () => (/* reexport */ HslColorManager),
78 "Interactivity": () => (/* reexport */ Interactivity),
79 "ManualParticle": () => (/* reexport */ ManualParticle),
80 "Modes": () => (/* reexport */ Modes),
81 "Move": () => (/* reexport */ Move),
82 "MoveAngle": () => (/* reexport */ MoveAngle),
83 "MoveAttract": () => (/* reexport */ MoveAttract),
84 "MoveCenter": () => (/* reexport */ MoveCenter),
85 "MoveGravity": () => (/* reexport */ MoveGravity),
86 "MovePath": () => (/* reexport */ MovePath),
87 "MoveTrail": () => (/* reexport */ MoveTrail),
88 "Opacity": () => (/* reexport */ Opacity),
89 "OpacityAnimation": () => (/* reexport */ OpacityAnimation),
90 "Options": () => (/* reexport */ Options),
91 "OptionsColor": () => (/* reexport */ OptionsColor),
92 "OutModes": () => (/* reexport */ OutModes),
93 "Parallax": () => (/* reexport */ Parallax),
94 "ParticlesBounce": () => (/* reexport */ ParticlesBounce),
95 "ParticlesBounceFactor": () => (/* reexport */ ParticlesBounceFactor),
96 "ParticlesDensity": () => (/* reexport */ ParticlesDensity),
97 "ParticlesInteractorBase": () => (/* reexport */ ParticlesInteractorBase),
98 "ParticlesNumber": () => (/* reexport */ ParticlesNumber),
99 "ParticlesOptions": () => (/* reexport */ ParticlesOptions),
100 "Point": () => (/* reexport */ Point),
101 "Range": () => (/* reexport */ Range),
102 "Rectangle": () => (/* reexport */ Rectangle),
103 "ResizeEvent": () => (/* reexport */ ResizeEvent),
104 "Responsive": () => (/* reexport */ Responsive),
105 "RgbColorManager": () => (/* reexport */ RgbColorManager),
106 "Shadow": () => (/* reexport */ Shadow),
107 "Shape": () => (/* reexport */ Shape),
108 "Size": () => (/* reexport */ Size),
109 "SizeAnimation": () => (/* reexport */ SizeAnimation),
110 "Spin": () => (/* reexport */ Spin),
111 "Stroke": () => (/* reexport */ Stroke),
112 "Theme": () => (/* reexport */ Theme),
113 "ThemeDefault": () => (/* reexport */ ThemeDefault),
114 "ValueWithRandom": () => (/* reexport */ ValueWithRandom),
115 "Vector": () => (/* reexport */ Vector),
116 "Vector3d": () => (/* reexport */ Vector3d),
117 "ZIndex": () => (/* reexport */ ZIndex),
118 "addColorManager": () => (/* reexport */ addColorManager),
119 "addEasing": () => (/* reexport */ addEasing),
120 "alterHsl": () => (/* reexport */ alterHsl),
121 "animate": () => (/* reexport */ animate),
122 "areBoundsInside": () => (/* reexport */ areBoundsInside),
123 "arrayRandomIndex": () => (/* reexport */ arrayRandomIndex),
124 "calcExactPositionOrRandomFromSize": () => (/* reexport */ calcExactPositionOrRandomFromSize),
125 "calcExactPositionOrRandomFromSizeRanged": () => (/* reexport */ calcExactPositionOrRandomFromSizeRanged),
126 "calcPositionFromSize": () => (/* reexport */ calcPositionFromSize),
127 "calcPositionOrRandomFromSize": () => (/* reexport */ calcPositionOrRandomFromSize),
128 "calcPositionOrRandomFromSizeRanged": () => (/* reexport */ calcPositionOrRandomFromSizeRanged),
129 "calculateBounds": () => (/* reexport */ calculateBounds),
130 "cancelAnimation": () => (/* reexport */ cancelAnimation),
131 "circleBounce": () => (/* reexport */ circleBounce),
132 "circleBounceDataFromParticle": () => (/* reexport */ circleBounceDataFromParticle),
133 "clamp": () => (/* reexport */ clamp),
134 "clear": () => (/* reexport */ clear),
135 "collisionVelocity": () => (/* reexport */ collisionVelocity),
136 "colorMix": () => (/* reexport */ colorMix),
137 "colorToHsl": () => (/* reexport */ colorToHsl),
138 "colorToRgb": () => (/* reexport */ colorToRgb),
139 "confetti": () => (/* reexport */ confetti),
140 "deepExtend": () => (/* reexport */ deepExtend),
141 "divMode": () => (/* reexport */ divMode),
142 "divModeExecute": () => (/* reexport */ divModeExecute),
143 "drawLine": () => (/* reexport */ drawLine),
144 "drawParticle": () => (/* reexport */ drawParticle),
145 "drawParticlePlugin": () => (/* reexport */ drawParticlePlugin),
146 "drawPlugin": () => (/* reexport */ drawPlugin),
147 "drawShape": () => (/* reexport */ drawShape),
148 "drawShapeAfterEffect": () => (/* reexport */ drawShapeAfterEffect),
149 "drawTriangle": () => (/* reexport */ drawTriangle),
150 "executeOnSingleOrMultiple": () => (/* reexport */ executeOnSingleOrMultiple),
151 "findItemFromSingleOrMultiple": () => (/* reexport */ findItemFromSingleOrMultiple),
152 "generatedAttribute": () => (/* reexport */ generatedAttribute),
153 "getDistance": () => (/* reexport */ getDistance),
154 "getDistances": () => (/* reexport */ getDistances),
155 "getEasing": () => (/* reexport */ getEasing),
156 "getHslAnimationFromHsl": () => (/* reexport */ getHslAnimationFromHsl),
157 "getHslFromAnimation": () => (/* reexport */ getHslFromAnimation),
158 "getLinkColor": () => (/* reexport */ getLinkColor),
159 "getLinkRandomColor": () => (/* reexport */ getLinkRandomColor),
160 "getParticleBaseVelocity": () => (/* reexport */ getParticleBaseVelocity),
161 "getParticleDirectionAngle": () => (/* reexport */ getParticleDirectionAngle),
162 "getRandom": () => (/* reexport */ getRandom),
163 "getRandomRgbColor": () => (/* reexport */ getRandomRgbColor),
164 "getRangeMax": () => (/* reexport */ getRangeMax),
165 "getRangeMin": () => (/* reexport */ getRangeMin),
166 "getRangeValue": () => (/* reexport */ getRangeValue),
167 "getStyleFromHsl": () => (/* reexport */ getStyleFromHsl),
168 "getStyleFromRgb": () => (/* reexport */ getStyleFromRgb),
169 "getValue": () => (/* reexport */ getValue),
170 "hasMatchMedia": () => (/* reexport */ hasMatchMedia),
171 "hslToRgb": () => (/* reexport */ hslToRgb),
172 "hslaToRgba": () => (/* reexport */ hslaToRgba),
173 "isDivModeEnabled": () => (/* reexport */ isDivModeEnabled),
174 "isInArray": () => (/* reexport */ isInArray),
175 "isPointInside": () => (/* reexport */ isPointInside),
176 "isSsr": () => (/* reexport */ isSsr),
177 "itemFromArray": () => (/* reexport */ itemFromArray),
178 "itemFromSingleOrMultiple": () => (/* reexport */ itemFromSingleOrMultiple),
179 "loadFont": () => (/* reexport */ loadFont),
180 "loadOptions": () => (/* reexport */ loadOptions),
181 "loadParticlesOptions": () => (/* reexport */ loadParticlesOptions),
182 "mix": () => (/* reexport */ mix),
183 "mouseDownEvent": () => (/* reexport */ mouseDownEvent),
184 "mouseLeaveEvent": () => (/* reexport */ mouseLeaveEvent),
185 "mouseMoveEvent": () => (/* reexport */ mouseMoveEvent),
186 "mouseOutEvent": () => (/* reexport */ mouseOutEvent),
187 "mouseUpEvent": () => (/* reexport */ mouseUpEvent),
188 "paintBase": () => (/* reexport */ paintBase),
189 "paintImage": () => (/* reexport */ paintImage),
190 "parseAlpha": () => (/* reexport */ parseAlpha),
191 "randomInRange": () => (/* reexport */ randomInRange),
192 "rangeColorToHsl": () => (/* reexport */ rangeColorToHsl),
193 "rangeColorToRgb": () => (/* reexport */ rangeColorToRgb),
194 "rectBounce": () => (/* reexport */ rectBounce),
195 "resizeEvent": () => (/* reexport */ resizeEvent),
196 "rgbToHsl": () => (/* reexport */ rgbToHsl),
197 "safeMatchMedia": () => (/* reexport */ safeMatchMedia),
198 "setRandom": () => (/* reexport */ setRandom),
199 "setRangeValue": () => (/* reexport */ setRangeValue),
200 "singleDivModeExecute": () => (/* reexport */ singleDivModeExecute),
201 "stringToAlpha": () => (/* reexport */ stringToAlpha),
202 "stringToRgb": () => (/* reexport */ stringToRgb),
203 "touchCancelEvent": () => (/* reexport */ touchCancelEvent),
204 "touchEndEvent": () => (/* reexport */ touchEndEvent),
205 "touchMoveEvent": () => (/* reexport */ touchMoveEvent),
206 "touchStartEvent": () => (/* reexport */ touchStartEvent),
207 "tsParticles": () => (/* reexport */ tsParticles),
208 "visibilityChangeEvent": () => (/* reexport */ visibilityChangeEvent)
209});
210
211;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/EventDispatcher.js
212class EventDispatcher {
213 constructor() {
214 this._listeners = new Map();
215 }
216 addEventListener(type, listener) {
217 var _a;
218 this.removeEventListener(type, listener);
219 if (!this._listeners.get(type)) {
220 this._listeners.set(type, []);
221 }
222 (_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.push(listener);
223 }
224 dispatchEvent(type, args) {
225 var _a;
226 (_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(handler => handler(args));
227 }
228 hasEventListener(type) {
229 return !!this._listeners.get(type);
230 }
231 removeAllEventListeners(type) {
232 if (!type) {
233 this._listeners = new Map();
234 } else {
235 this._listeners.delete(type);
236 }
237 }
238 removeEventListener(type, listener) {
239 const arr = this._listeners.get(type);
240 if (!arr) {
241 return;
242 }
243 const length = arr.length,
244 idx = arr.indexOf(listener);
245 if (idx < 0) {
246 return;
247 }
248 if (length === 1) {
249 this._listeners.delete(type);
250 } else {
251 arr.splice(idx, 1);
252 }
253 }
254}
255;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Vector3d.js
256class Vector3d {
257 constructor(xOrCoords, y, z) {
258 if (typeof xOrCoords !== "number" && xOrCoords) {
259 this.x = xOrCoords.x;
260 this.y = xOrCoords.y;
261 const coords3d = xOrCoords;
262 this.z = coords3d.z ? coords3d.z : 0;
263 } else if (xOrCoords !== undefined && y !== undefined) {
264 this.x = xOrCoords;
265 this.y = y;
266 this.z = z !== null && z !== void 0 ? z : 0;
267 } else {
268 throw new Error("tsParticles - Vector3d not initialized correctly");
269 }
270 }
271 static get origin() {
272 return Vector3d.create(0, 0, 0);
273 }
274 get angle() {
275 return Math.atan2(this.y, this.x);
276 }
277 set angle(angle) {
278 this.updateFromAngle(angle, this.length);
279 }
280 get length() {
281 return Math.sqrt(this.getLengthSq());
282 }
283 set length(length) {
284 this.updateFromAngle(this.angle, length);
285 }
286 static clone(source) {
287 return Vector3d.create(source.x, source.y, source.z);
288 }
289 static create(x, y, z) {
290 return new Vector3d(x, y, z);
291 }
292 add(v) {
293 return Vector3d.create(this.x + v.x, this.y + v.y, this.z + v.z);
294 }
295 addTo(v) {
296 this.x += v.x;
297 this.y += v.y;
298 this.z += v.z;
299 }
300 copy() {
301 return Vector3d.clone(this);
302 }
303 distanceTo(v) {
304 return this.sub(v).length;
305 }
306 distanceToSq(v) {
307 return this.sub(v).getLengthSq();
308 }
309 div(n) {
310 return Vector3d.create(this.x / n, this.y / n, this.z / n);
311 }
312 divTo(n) {
313 this.x /= n;
314 this.y /= n;
315 this.z /= n;
316 }
317 getLengthSq() {
318 return this.x ** 2 + this.y ** 2;
319 }
320 mult(n) {
321 return Vector3d.create(this.x * n, this.y * n, this.z * n);
322 }
323 multTo(n) {
324 this.x *= n;
325 this.y *= n;
326 this.z *= n;
327 }
328 rotate(angle) {
329 return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), 0);
330 }
331 setTo(c) {
332 this.x = c.x;
333 this.y = c.y;
334 const v3d = c;
335 this.z = v3d.z ? v3d.z : 0;
336 }
337 sub(v) {
338 return Vector3d.create(this.x - v.x, this.y - v.y, this.z - v.z);
339 }
340 subFrom(v) {
341 this.x -= v.x;
342 this.y -= v.y;
343 this.z -= v.z;
344 }
345 updateFromAngle(angle, length) {
346 this.x = Math.cos(angle) * length;
347 this.y = Math.sin(angle) * length;
348 }
349}
350;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Vector.js
351
352class Vector extends Vector3d {
353 constructor(xOrCoords, y) {
354 super(xOrCoords, y, 0);
355 }
356 static get origin() {
357 return Vector.create(0, 0);
358 }
359 static clone(source) {
360 return Vector.create(source.x, source.y);
361 }
362 static create(x, y) {
363 return new Vector(x, y);
364 }
365}
366;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/NumberUtils.js
367
368let _random = Math.random;
369const easings = new Map();
370function addEasing(name, easing) {
371 if (!easings.get(name)) {
372 easings.set(name, easing);
373 }
374}
375function getEasing(name) {
376 return easings.get(name) || (value => value);
377}
378function setRandom(rnd = Math.random) {
379 _random = rnd;
380}
381function getRandom() {
382 return clamp(_random(), 0, 1 - 1e-16);
383}
384function clamp(num, min, max) {
385 return Math.min(Math.max(num, min), max);
386}
387function mix(comp1, comp2, weight1, weight2) {
388 return Math.floor((comp1 * weight1 + comp2 * weight2) / (weight1 + weight2));
389}
390function randomInRange(r) {
391 const max = getRangeMax(r);
392 let min = getRangeMin(r);
393 if (max === min) {
394 min = 0;
395 }
396 return getRandom() * (max - min) + min;
397}
398function getRangeValue(value) {
399 return typeof value === "number" ? value : randomInRange(value);
400}
401function getRangeMin(value) {
402 return typeof value === "number" ? value : value.min;
403}
404function getRangeMax(value) {
405 return typeof value === "number" ? value : value.max;
406}
407function setRangeValue(source, value) {
408 if (source === value || value === undefined && typeof source === "number") {
409 return source;
410 }
411 const min = getRangeMin(source),
412 max = getRangeMax(source);
413 return value !== undefined ? {
414 min: Math.min(min, value),
415 max: Math.max(max, value)
416 } : setRangeValue(min, max);
417}
418function getValue(options) {
419 const random = options.random,
420 {
421 enable,
422 minimumValue
423 } = typeof random === "boolean" ? {
424 enable: random,
425 minimumValue: 0
426 } : random;
427 return enable ? getRangeValue(setRangeValue(options.value, minimumValue)) : getRangeValue(options.value);
428}
429function getDistances(pointA, pointB) {
430 const dx = pointA.x - pointB.x,
431 dy = pointA.y - pointB.y;
432 return {
433 dx: dx,
434 dy: dy,
435 distance: Math.sqrt(dx ** 2 + dy ** 2)
436 };
437}
438function getDistance(pointA, pointB) {
439 return getDistances(pointA, pointB).distance;
440}
441function getParticleDirectionAngle(direction, position, center) {
442 if (typeof direction === "number") {
443 return direction * Math.PI / 180;
444 } else {
445 switch (direction) {
446 case "top":
447 return -Math.PI / 2;
448 case "top-right":
449 return -Math.PI / 4;
450 case "right":
451 return 0;
452 case "bottom-right":
453 return Math.PI / 4;
454 case "bottom":
455 return Math.PI / 2;
456 case "bottom-left":
457 return 3 * Math.PI / 4;
458 case "left":
459 return Math.PI;
460 case "top-left":
461 return -3 * Math.PI / 4;
462 case "inside":
463 return Math.atan2(center.y - position.y, center.x - position.x);
464 case "outside":
465 return Math.atan2(position.y - center.y, position.x - center.x);
466 default:
467 return getRandom() * Math.PI * 2;
468 }
469 }
470}
471function getParticleBaseVelocity(direction) {
472 const baseVelocity = Vector.origin;
473 baseVelocity.length = 1;
474 baseVelocity.angle = direction;
475 return baseVelocity;
476}
477function collisionVelocity(v1, v2, m1, m2) {
478 return Vector.create(v1.x * (m1 - m2) / (m1 + m2) + v2.x * 2 * m2 / (m1 + m2), v1.y);
479}
480function calcPositionFromSize(data) {
481 return data.position && data.position.x !== undefined && data.position.y !== undefined ? {
482 x: data.position.x * data.size.width / 100,
483 y: data.position.y * data.size.height / 100
484 } : undefined;
485}
486function calcPositionOrRandomFromSize(data) {
487 var _a, _b, _c, _d;
488 return {
489 x: ((_b = (_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : getRandom() * 100) * data.size.width / 100,
490 y: ((_d = (_c = data.position) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : getRandom() * 100) * data.size.height / 100
491 };
492}
493function calcPositionOrRandomFromSizeRanged(data) {
494 var _a, _b;
495 const position = {
496 x: ((_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== undefined ? getRangeValue(data.position.x) : undefined,
497 y: ((_b = data.position) === null || _b === void 0 ? void 0 : _b.y) !== undefined ? getRangeValue(data.position.y) : undefined
498 };
499 return calcPositionOrRandomFromSize({
500 size: data.size,
501 position
502 });
503}
504function calcExactPositionOrRandomFromSize(data) {
505 var _a, _b, _c, _d;
506 return {
507 x: (_b = (_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : getRandom() * data.size.width,
508 y: (_d = (_c = data.position) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : getRandom() * data.size.height
509 };
510}
511function calcExactPositionOrRandomFromSizeRanged(data) {
512 var _a, _b;
513 const position = {
514 x: ((_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== undefined ? getRangeValue(data.position.x) : undefined,
515 y: ((_b = data.position) === null || _b === void 0 ? void 0 : _b.y) !== undefined ? getRangeValue(data.position.y) : undefined
516 };
517 return calcExactPositionOrRandomFromSize({
518 size: data.size,
519 position
520 });
521}
522function parseAlpha(input) {
523 return input ? input.endsWith("%") ? parseFloat(input) / 100 : parseFloat(input) : 1;
524}
525;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/Utils.js
526
527
528function rectSideBounce(pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor) {
529 const res = {
530 bounced: false
531 };
532 if (pOtherSide.min < rectOtherSide.min || pOtherSide.min > rectOtherSide.max || pOtherSide.max < rectOtherSide.min || pOtherSide.max > rectOtherSide.max) {
533 return res;
534 }
535 if (pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) / 2 && velocity > 0 || pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) / 2 && velocity < 0) {
536 res.velocity = velocity * -factor;
537 res.bounced = true;
538 }
539 return res;
540}
541function checkSelector(element, selectors) {
542 const res = executeOnSingleOrMultiple(selectors, selector => {
543 return element.matches(selector);
544 });
545 return res instanceof Array ? res.some(t => t) : res;
546}
547function isSsr() {
548 return typeof window === "undefined" || !window || typeof window.document === "undefined" || !window.document;
549}
550function hasMatchMedia() {
551 return !isSsr() && typeof matchMedia !== "undefined";
552}
553function safeMatchMedia(query) {
554 if (!hasMatchMedia()) {
555 return;
556 }
557 return matchMedia(query);
558}
559function animate() {
560 return isSsr() ? callback => setTimeout(callback) : callback => (requestAnimationFrame || setTimeout)(callback);
561}
562function cancelAnimation() {
563 return isSsr() ? handle => clearTimeout(handle) : handle => (cancelAnimationFrame || clearTimeout)(handle);
564}
565function isInArray(value, array) {
566 return value === array || array instanceof Array && array.indexOf(value) > -1;
567}
568async function loadFont(font, weight) {
569 try {
570 await document.fonts.load(`${weight !== null && weight !== void 0 ? weight : "400"} 36px '${font !== null && font !== void 0 ? font : "Verdana"}'`);
571 } catch (_a) {}
572}
573function arrayRandomIndex(array) {
574 return Math.floor(getRandom() * array.length);
575}
576function itemFromArray(array, index, useIndex = true) {
577 return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
578}
579function isPointInside(point, size, offset, radius, direction) {
580 return areBoundsInside(calculateBounds(point, radius !== null && radius !== void 0 ? radius : 0), size, offset, direction);
581}
582function areBoundsInside(bounds, size, offset, direction) {
583 let inside = true;
584 if (!direction || direction === "bottom") {
585 inside = bounds.top < size.height + offset.x;
586 }
587 if (inside && (!direction || direction === "left")) {
588 inside = bounds.right > offset.x;
589 }
590 if (inside && (!direction || direction === "right")) {
591 inside = bounds.left < size.width + offset.y;
592 }
593 if (inside && (!direction || direction === "top")) {
594 inside = bounds.bottom > offset.y;
595 }
596 return inside;
597}
598function calculateBounds(point, radius) {
599 return {
600 bottom: point.y + radius,
601 left: point.x - radius,
602 right: point.x + radius,
603 top: point.y - radius
604 };
605}
606function deepExtend(destination, ...sources) {
607 for (const source of sources) {
608 if (source === undefined || source === null) {
609 continue;
610 }
611 if (typeof source !== "object") {
612 destination = source;
613 continue;
614 }
615 const sourceIsArray = Array.isArray(source);
616 if (sourceIsArray && (typeof destination !== "object" || !destination || !Array.isArray(destination))) {
617 destination = [];
618 } else if (!sourceIsArray && (typeof destination !== "object" || !destination || Array.isArray(destination))) {
619 destination = {};
620 }
621 for (const key in source) {
622 if (key === "__proto__") {
623 continue;
624 }
625 const sourceDict = source,
626 value = sourceDict[key],
627 isObject = typeof value === "object",
628 destDict = destination;
629 destDict[key] = isObject && Array.isArray(value) ? value.map(v => deepExtend(destDict[key], v)) : deepExtend(destDict[key], value);
630 }
631 }
632 return destination;
633}
634function isDivModeEnabled(mode, divs) {
635 return !!findItemFromSingleOrMultiple(divs, t => t.enable && isInArray(mode, t.mode));
636}
637function divModeExecute(mode, divs, callback) {
638 executeOnSingleOrMultiple(divs, div => {
639 const divMode = div.mode,
640 divEnabled = div.enable;
641 if (divEnabled && isInArray(mode, divMode)) {
642 singleDivModeExecute(div, callback);
643 }
644 });
645}
646function singleDivModeExecute(div, callback) {
647 const selectors = div.selectors;
648 executeOnSingleOrMultiple(selectors, selector => {
649 callback(selector, div);
650 });
651}
652function divMode(divs, element) {
653 if (!element || !divs) {
654 return;
655 }
656 return findItemFromSingleOrMultiple(divs, div => {
657 return checkSelector(element, div.selectors);
658 });
659}
660function circleBounceDataFromParticle(p) {
661 return {
662 position: p.getPosition(),
663 radius: p.getRadius(),
664 mass: p.getMass(),
665 velocity: p.velocity,
666 factor: Vector.create(getValue(p.options.bounce.horizontal), getValue(p.options.bounce.vertical))
667 };
668}
669function circleBounce(p1, p2) {
670 const {
671 x: xVelocityDiff,
672 y: yVelocityDiff
673 } = p1.velocity.sub(p2.velocity),
674 [pos1, pos2] = [p1.position, p2.position],
675 {
676 dx: xDist,
677 dy: yDist
678 } = getDistances(pos2, pos1);
679 if (xVelocityDiff * xDist + yVelocityDiff * yDist < 0) {
680 return;
681 }
682 const angle = -Math.atan2(yDist, xDist),
683 m1 = p1.mass,
684 m2 = p2.mass,
685 u1 = p1.velocity.rotate(angle),
686 u2 = p2.velocity.rotate(angle),
687 v1 = collisionVelocity(u1, u2, m1, m2),
688 v2 = collisionVelocity(u2, u1, m1, m2),
689 vFinal1 = v1.rotate(-angle),
690 vFinal2 = v2.rotate(-angle);
691 p1.velocity.x = vFinal1.x * p1.factor.x;
692 p1.velocity.y = vFinal1.y * p1.factor.y;
693 p2.velocity.x = vFinal2.x * p2.factor.x;
694 p2.velocity.y = vFinal2.y * p2.factor.y;
695}
696function rectBounce(particle, divBounds) {
697 const pPos = particle.getPosition(),
698 size = particle.getRadius(),
699 bounds = calculateBounds(pPos, size),
700 resH = rectSideBounce({
701 min: bounds.left,
702 max: bounds.right
703 }, {
704 min: bounds.top,
705 max: bounds.bottom
706 }, {
707 min: divBounds.left,
708 max: divBounds.right
709 }, {
710 min: divBounds.top,
711 max: divBounds.bottom
712 }, particle.velocity.x, getValue(particle.options.bounce.horizontal));
713 if (resH.bounced) {
714 if (resH.velocity !== undefined) {
715 particle.velocity.x = resH.velocity;
716 }
717 if (resH.position !== undefined) {
718 particle.position.x = resH.position;
719 }
720 }
721 const resV = rectSideBounce({
722 min: bounds.top,
723 max: bounds.bottom
724 }, {
725 min: bounds.left,
726 max: bounds.right
727 }, {
728 min: divBounds.top,
729 max: divBounds.bottom
730 }, {
731 min: divBounds.left,
732 max: divBounds.right
733 }, particle.velocity.y, getValue(particle.options.bounce.vertical));
734 if (resV.bounced) {
735 if (resV.velocity !== undefined) {
736 particle.velocity.y = resV.velocity;
737 }
738 if (resV.position !== undefined) {
739 particle.position.y = resV.position;
740 }
741 }
742}
743function executeOnSingleOrMultiple(obj, callback) {
744 return obj instanceof Array ? obj.map((item, index) => callback(item, index)) : callback(obj, 0);
745}
746function itemFromSingleOrMultiple(obj, index, useIndex) {
747 return obj instanceof Array ? itemFromArray(obj, index, useIndex) : obj;
748}
749function findItemFromSingleOrMultiple(obj, callback) {
750 return obj instanceof Array ? obj.find((t, index) => callback(t, index)) : callback(obj, 0) ? obj : undefined;
751}
752;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/ColorUtils.js
753
754
755const randomColorValue = "random",
756 midColorValue = "mid",
757 colorManagers = new Map();
758function addColorManager(manager) {
759 colorManagers.set(manager.key, manager);
760}
761function hue2rgb(p, q, t) {
762 if (t < 0) {
763 t += 1;
764 }
765 if (t > 1) {
766 t -= 1;
767 }
768 if (t < 1 / 6) {
769 return p + (q - p) * 6 * t;
770 }
771 if (t < 1 / 2) {
772 return q;
773 }
774 if (t < 2 / 3) {
775 return p + (q - p) * (2 / 3 - t) * 6;
776 }
777 return p;
778}
779function stringToRgba(input) {
780 for (const [, manager] of colorManagers) {
781 if (input.startsWith(manager.stringPrefix)) {
782 return manager.parseString(input);
783 }
784 }
785 const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i,
786 hexFixed = input.replace(shorthandRegex, (_, r, g, b, a) => {
787 return r + r + g + g + b + b + (a !== undefined ? a + a : "");
788 }),
789 regex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i,
790 result = regex.exec(hexFixed);
791 return result ? {
792 a: result[4] !== undefined ? parseInt(result[4], 16) / 0xff : 1,
793 b: parseInt(result[3], 16),
794 g: parseInt(result[2], 16),
795 r: parseInt(result[1], 16)
796 } : undefined;
797}
798function rangeColorToRgb(input, index, useIndex = true) {
799 if (!input) {
800 return;
801 }
802 const color = typeof input === "string" ? {
803 value: input
804 } : input;
805 if (typeof color.value === "string") {
806 return colorToRgb(color.value, index, useIndex);
807 }
808 if (color.value instanceof Array) {
809 return rangeColorToRgb({
810 value: itemFromArray(color.value, index, useIndex)
811 });
812 }
813 for (const [, manager] of colorManagers) {
814 const res = manager.handleRangeColor(color);
815 if (res) {
816 return res;
817 }
818 }
819}
820function colorToRgb(input, index, useIndex = true) {
821 if (!input) {
822 return;
823 }
824 const color = typeof input === "string" ? {
825 value: input
826 } : input;
827 if (typeof color.value === "string") {
828 return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(color.value);
829 }
830 if (color.value instanceof Array) {
831 return colorToRgb({
832 value: itemFromArray(color.value, index, useIndex)
833 });
834 }
835 for (const [, manager] of colorManagers) {
836 const res = manager.handleColor(color);
837 if (res) {
838 return res;
839 }
840 }
841}
842function colorToHsl(color, index, useIndex = true) {
843 const rgb = colorToRgb(color, index, useIndex);
844 return rgb ? rgbToHsl(rgb) : undefined;
845}
846function rangeColorToHsl(color, index, useIndex = true) {
847 const rgb = rangeColorToRgb(color, index, useIndex);
848 return rgb ? rgbToHsl(rgb) : undefined;
849}
850function rgbToHsl(color) {
851 const r1 = color.r / 255,
852 g1 = color.g / 255,
853 b1 = color.b / 255,
854 max = Math.max(r1, g1, b1),
855 min = Math.min(r1, g1, b1),
856 res = {
857 h: 0,
858 l: (max + min) / 2,
859 s: 0
860 };
861 if (max !== min) {
862 res.s = res.l < 0.5 ? (max - min) / (max + min) : (max - min) / (2.0 - max - min);
863 res.h = r1 === max ? (g1 - b1) / (max - min) : res.h = g1 === max ? 2.0 + (b1 - r1) / (max - min) : 4.0 + (r1 - g1) / (max - min);
864 }
865 res.l *= 100;
866 res.s *= 100;
867 res.h *= 60;
868 if (res.h < 0) {
869 res.h += 360;
870 }
871 if (res.h >= 360) {
872 res.h -= 360;
873 }
874 return res;
875}
876function stringToAlpha(input) {
877 var _a;
878 return (_a = stringToRgba(input)) === null || _a === void 0 ? void 0 : _a.a;
879}
880function stringToRgb(input) {
881 return stringToRgba(input);
882}
883function hslToRgb(hsl) {
884 const result = {
885 b: 0,
886 g: 0,
887 r: 0
888 },
889 hslPercent = {
890 h: hsl.h / 360,
891 l: hsl.l / 100,
892 s: hsl.s / 100
893 };
894 if (!hslPercent.s) {
895 result.b = hslPercent.l;
896 result.g = hslPercent.l;
897 result.r = hslPercent.l;
898 } else {
899 const q = hslPercent.l < 0.5 ? hslPercent.l * (1 + hslPercent.s) : hslPercent.l + hslPercent.s - hslPercent.l * hslPercent.s,
900 p = 2 * hslPercent.l - q;
901 result.r = hue2rgb(p, q, hslPercent.h + 1 / 3);
902 result.g = hue2rgb(p, q, hslPercent.h);
903 result.b = hue2rgb(p, q, hslPercent.h - 1 / 3);
904 }
905 result.r = Math.floor(result.r * 255);
906 result.g = Math.floor(result.g * 255);
907 result.b = Math.floor(result.b * 255);
908 return result;
909}
910function hslaToRgba(hsla) {
911 const rgbResult = hslToRgb(hsla);
912 return {
913 a: hsla.a,
914 b: rgbResult.b,
915 g: rgbResult.g,
916 r: rgbResult.r
917 };
918}
919function getRandomRgbColor(min) {
920 const fixedMin = min !== null && min !== void 0 ? min : 0;
921 return {
922 b: Math.floor(randomInRange(setRangeValue(fixedMin, 256))),
923 g: Math.floor(randomInRange(setRangeValue(fixedMin, 256))),
924 r: Math.floor(randomInRange(setRangeValue(fixedMin, 256)))
925 };
926}
927function getStyleFromRgb(color, opacity) {
928 return `rgba(${color.r}, ${color.g}, ${color.b}, ${opacity !== null && opacity !== void 0 ? opacity : 1})`;
929}
930function getStyleFromHsl(color, opacity) {
931 return `hsla(${color.h}, ${color.s}%, ${color.l}%, ${opacity !== null && opacity !== void 0 ? opacity : 1})`;
932}
933function colorMix(color1, color2, size1, size2) {
934 let rgb1 = color1,
935 rgb2 = color2;
936 if (rgb1.r === undefined) {
937 rgb1 = hslToRgb(color1);
938 }
939 if (rgb2.r === undefined) {
940 rgb2 = hslToRgb(color2);
941 }
942 return {
943 b: mix(rgb1.b, rgb2.b, size1, size2),
944 g: mix(rgb1.g, rgb2.g, size1, size2),
945 r: mix(rgb1.r, rgb2.r, size1, size2)
946 };
947}
948function getLinkColor(p1, p2, linkColor) {
949 var _a, _b;
950 if (linkColor === randomColorValue) {
951 return getRandomRgbColor();
952 } else if (linkColor === midColorValue) {
953 const sourceColor = (_a = p1.getFillColor()) !== null && _a !== void 0 ? _a : p1.getStrokeColor(),
954 destColor = (_b = p2 === null || p2 === void 0 ? void 0 : p2.getFillColor()) !== null && _b !== void 0 ? _b : p2 === null || p2 === void 0 ? void 0 : p2.getStrokeColor();
955 if (sourceColor && destColor && p2) {
956 return colorMix(sourceColor, destColor, p1.getRadius(), p2.getRadius());
957 } else {
958 const hslColor = sourceColor !== null && sourceColor !== void 0 ? sourceColor : destColor;
959 if (hslColor) {
960 return hslToRgb(hslColor);
961 }
962 }
963 } else {
964 return linkColor;
965 }
966}
967function getLinkRandomColor(optColor, blink, consent) {
968 const color = typeof optColor === "string" ? optColor : optColor.value;
969 if (color === randomColorValue) {
970 if (consent) {
971 return rangeColorToRgb({
972 value: color
973 });
974 }
975 if (blink) {
976 return randomColorValue;
977 }
978 return midColorValue;
979 } else if (color === midColorValue) {
980 return midColorValue;
981 } else {
982 return rangeColorToRgb({
983 value: color
984 });
985 }
986}
987function getHslFromAnimation(animation) {
988 return animation !== undefined ? {
989 h: animation.h.value,
990 s: animation.s.value,
991 l: animation.l.value
992 } : undefined;
993}
994function getHslAnimationFromHsl(hsl, animationOptions, reduceFactor) {
995 const resColor = {
996 h: {
997 enable: false,
998 value: hsl.h
999 },
1000 s: {
1001 enable: false,
1002 value: hsl.s
1003 },
1004 l: {
1005 enable: false,
1006 value: hsl.l
1007 }
1008 };
1009 if (animationOptions) {
1010 setColorAnimation(resColor.h, animationOptions.h, reduceFactor);
1011 setColorAnimation(resColor.s, animationOptions.s, reduceFactor);
1012 setColorAnimation(resColor.l, animationOptions.l, reduceFactor);
1013 }
1014 return resColor;
1015}
1016function setColorAnimation(colorValue, colorAnimation, reduceFactor) {
1017 colorValue.enable = colorAnimation.enable;
1018 if (colorValue.enable) {
1019 colorValue.velocity = getRangeValue(colorAnimation.speed) / 100 * reduceFactor;
1020 colorValue.decay = 1 - getRangeValue(colorAnimation.decay);
1021 colorValue.status = "increasing";
1022 colorValue.loops = 0;
1023 colorValue.maxLoops = getRangeValue(colorAnimation.count);
1024 if (!colorAnimation.sync) {
1025 colorValue.velocity *= getRandom();
1026 colorValue.value *= getRandom();
1027 }
1028 colorValue.initialValue = colorValue.value;
1029 } else {
1030 colorValue.velocity = 0;
1031 }
1032}
1033;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/CanvasUtils.js
1034
1035function drawLine(context, begin, end) {
1036 context.beginPath();
1037 context.moveTo(begin.x, begin.y);
1038 context.lineTo(end.x, end.y);
1039 context.closePath();
1040}
1041function drawTriangle(context, p1, p2, p3) {
1042 context.beginPath();
1043 context.moveTo(p1.x, p1.y);
1044 context.lineTo(p2.x, p2.y);
1045 context.lineTo(p3.x, p3.y);
1046 context.closePath();
1047}
1048function paintBase(context, dimension, baseColor) {
1049 context.fillStyle = baseColor !== null && baseColor !== void 0 ? baseColor : "rgba(0,0,0,0)";
1050 context.fillRect(0, 0, dimension.width, dimension.height);
1051}
1052function paintImage(context, dimension, image, opacity) {
1053 if (!image) {
1054 return;
1055 }
1056 context.globalAlpha = opacity;
1057 context.drawImage(image, 0, 0, dimension.width, dimension.height);
1058 context.globalAlpha = 1;
1059}
1060function clear(context, dimension) {
1061 context.clearRect(0, 0, dimension.width, dimension.height);
1062}
1063function drawParticle(data) {
1064 var _a, _b, _c, _d, _e;
1065 const {
1066 container,
1067 context,
1068 particle,
1069 delta,
1070 colorStyles,
1071 backgroundMask,
1072 composite,
1073 radius,
1074 opacity,
1075 shadow,
1076 transform
1077 } = data;
1078 const pos = particle.getPosition(),
1079 angle = particle.rotation + (particle.pathRotation ? particle.velocity.angle : 0),
1080 rotateData = {
1081 sin: Math.sin(angle),
1082 cos: Math.cos(angle)
1083 },
1084 transformData = {
1085 a: rotateData.cos * ((_a = transform.a) !== null && _a !== void 0 ? _a : 1),
1086 b: rotateData.sin * ((_b = transform.b) !== null && _b !== void 0 ? _b : 1),
1087 c: -rotateData.sin * ((_c = transform.c) !== null && _c !== void 0 ? _c : 1),
1088 d: rotateData.cos * ((_d = transform.d) !== null && _d !== void 0 ? _d : 1)
1089 };
1090 context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
1091 context.beginPath();
1092 if (backgroundMask) {
1093 context.globalCompositeOperation = composite;
1094 }
1095 const shadowColor = particle.shadowColor;
1096 if (shadow.enable && shadowColor) {
1097 context.shadowBlur = shadow.blur;
1098 context.shadowColor = getStyleFromRgb(shadowColor);
1099 context.shadowOffsetX = shadow.offset.x;
1100 context.shadowOffsetY = shadow.offset.y;
1101 }
1102 if (colorStyles.fill) {
1103 context.fillStyle = colorStyles.fill;
1104 }
1105 const strokeWidth = (_e = particle.strokeWidth) !== null && _e !== void 0 ? _e : 0;
1106 context.lineWidth = strokeWidth;
1107 if (colorStyles.stroke) {
1108 context.strokeStyle = colorStyles.stroke;
1109 }
1110 drawShape(container, context, particle, radius, opacity, delta);
1111 if (strokeWidth > 0) {
1112 context.stroke();
1113 }
1114 if (particle.close) {
1115 context.closePath();
1116 }
1117 if (particle.fill) {
1118 context.fill();
1119 }
1120 drawShapeAfterEffect(container, context, particle, radius, opacity, delta);
1121 context.globalCompositeOperation = "source-over";
1122 context.setTransform(1, 0, 0, 1, 0, 0);
1123}
1124function drawShape(container, context, particle, radius, opacity, delta) {
1125 if (!particle.shape) {
1126 return;
1127 }
1128 const drawer = container.drawers.get(particle.shape);
1129 if (!drawer) {
1130 return;
1131 }
1132 drawer.draw(context, particle, radius, opacity, delta, container.retina.pixelRatio);
1133}
1134function drawShapeAfterEffect(container, context, particle, radius, opacity, delta) {
1135 if (!particle.shape) {
1136 return;
1137 }
1138 const drawer = container.drawers.get(particle.shape);
1139 if (!(drawer === null || drawer === void 0 ? void 0 : drawer.afterEffect)) {
1140 return;
1141 }
1142 drawer.afterEffect(context, particle, radius, opacity, delta, container.retina.pixelRatio);
1143}
1144function drawPlugin(context, plugin, delta) {
1145 if (!plugin.draw) {
1146 return;
1147 }
1148 plugin.draw(context, delta);
1149}
1150function drawParticlePlugin(context, plugin, particle, delta) {
1151 if (!plugin.drawParticle) {
1152 return;
1153 }
1154 plugin.drawParticle(context, particle, delta);
1155}
1156function alterHsl(color, type, value) {
1157 return {
1158 h: color.h,
1159 s: color.s,
1160 l: color.l + (type === "darken" ? -1 : 1) * value
1161 };
1162}
1163;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Constants.js
1164const generatedAttribute = "generated";
1165const touchEndEvent = "touchend";
1166const mouseDownEvent = "pointerdown";
1167const mouseUpEvent = "pointerup";
1168const mouseMoveEvent = "pointermove";
1169const touchStartEvent = "touchstart";
1170const touchMoveEvent = "touchmove";
1171const mouseLeaveEvent = "pointerleave";
1172const mouseOutEvent = "pointerout";
1173const touchCancelEvent = "touchcancel";
1174const resizeEvent = "resize";
1175const visibilityChangeEvent = "visibilitychange";
1176;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Canvas.js
1177
1178
1179
1180
1181function setTransformValue(factor, newFactor, key) {
1182 var _a;
1183 const newValue = newFactor[key];
1184 if (newValue !== undefined) {
1185 factor[key] = ((_a = factor[key]) !== null && _a !== void 0 ? _a : 1) * newValue;
1186 }
1187}
1188class Canvas {
1189 constructor(container) {
1190 this.container = container;
1191 this.size = {
1192 height: 0,
1193 width: 0
1194 };
1195 this._context = null;
1196 this._generated = false;
1197 this._preDrawUpdaters = [];
1198 this._postDrawUpdaters = [];
1199 this._resizePlugins = [];
1200 this._colorPlugins = [];
1201 this._mutationObserver = !isSsr() && typeof MutationObserver !== "undefined" ? new MutationObserver(records => {
1202 for (const record of records) {
1203 if (record.type === "attributes" && record.attributeName === "style") {
1204 this._repairStyle();
1205 }
1206 }
1207 }) : undefined;
1208 }
1209 get _fullScreen() {
1210 return this.container.actualOptions.fullScreen.enable;
1211 }
1212 clear() {
1213 const options = this.container.actualOptions,
1214 trail = options.particles.move.trail,
1215 trailFill = this._trailFill;
1216 if (options.backgroundMask.enable) {
1217 this.paint();
1218 } else if (trail.enable && trail.length > 0 && trailFill) {
1219 if (trailFill.color) {
1220 this._paintBase(getStyleFromRgb(trailFill.color, trailFill.opacity));
1221 } else if (trailFill.image) {
1222 this._paintImage(trailFill.image, trailFill.opacity);
1223 }
1224 } else {
1225 this.draw(ctx => {
1226 clear(ctx, this.size);
1227 });
1228 }
1229 }
1230 destroy() {
1231 var _a, _b;
1232 (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1233 if (this._generated) {
1234 (_b = this.element) === null || _b === void 0 ? void 0 : _b.remove();
1235 } else {
1236 this._resetOriginalStyle();
1237 }
1238 this.stop();
1239 this._preDrawUpdaters = [];
1240 this._postDrawUpdaters = [];
1241 this._resizePlugins = [];
1242 this._colorPlugins = [];
1243 }
1244 draw(cb) {
1245 if (!this._context) {
1246 return;
1247 }
1248 return cb(this._context);
1249 }
1250 drawParticle(particle, delta) {
1251 var _a;
1252 if (particle.spawning || particle.destroyed) {
1253 return;
1254 }
1255 const radius = particle.getRadius();
1256 if (radius <= 0) {
1257 return;
1258 }
1259 const pfColor = particle.getFillColor(),
1260 psColor = (_a = particle.getStrokeColor()) !== null && _a !== void 0 ? _a : pfColor;
1261 let [fColor, sColor] = this._getPluginParticleColors(particle);
1262 if (!fColor) {
1263 fColor = pfColor;
1264 }
1265 if (!sColor) {
1266 sColor = psColor;
1267 }
1268 if (!fColor && !sColor) {
1269 return;
1270 }
1271 this.draw(ctx => {
1272 var _a, _b, _c, _d;
1273 const options = this.container.actualOptions,
1274 zIndexOptions = particle.options.zIndex,
1275 zOpacityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.opacityRate,
1276 opacity = (_c = (_a = particle.bubble.opacity) !== null && _a !== void 0 ? _a : (_b = particle.opacity) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : 1,
1277 strokeOpacity = (_d = particle.strokeOpacity) !== null && _d !== void 0 ? _d : opacity,
1278 zOpacity = opacity * zOpacityFactor,
1279 zStrokeOpacity = strokeOpacity * zOpacityFactor,
1280 transform = {},
1281 colorStyles = {
1282 fill: fColor ? getStyleFromHsl(fColor, zOpacity) : undefined
1283 };
1284 colorStyles.stroke = sColor ? getStyleFromHsl(sColor, zStrokeOpacity) : colorStyles.fill;
1285 this._applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform);
1286 drawParticle({
1287 container: this.container,
1288 context: ctx,
1289 particle,
1290 delta,
1291 colorStyles,
1292 backgroundMask: options.backgroundMask.enable,
1293 composite: options.backgroundMask.composite,
1294 radius: radius * (1 - particle.zIndexFactor) ** zIndexOptions.sizeRate,
1295 opacity: zOpacity,
1296 shadow: particle.options.shadow,
1297 transform
1298 });
1299 this._applyPostDrawUpdaters(particle);
1300 });
1301 }
1302 drawParticlePlugin(plugin, particle, delta) {
1303 this.draw(ctx => {
1304 drawParticlePlugin(ctx, plugin, particle, delta);
1305 });
1306 }
1307 drawPlugin(plugin, delta) {
1308 this.draw(ctx => {
1309 drawPlugin(ctx, plugin, delta);
1310 });
1311 }
1312 async init() {
1313 var _a;
1314 this.resize();
1315 this._initStyle();
1316 this._initCover();
1317 try {
1318 await this._initTrail();
1319 } catch (e) {
1320 console.error(e);
1321 }
1322 this.initBackground();
1323 if (this.element) {
1324 (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.element, {
1325 attributes: true
1326 });
1327 }
1328 this.initUpdaters();
1329 this.initPlugins();
1330 this.paint();
1331 }
1332 initBackground() {
1333 const options = this.container.actualOptions,
1334 background = options.background,
1335 element = this.element,
1336 elementStyle = element === null || element === void 0 ? void 0 : element.style;
1337 if (!elementStyle) {
1338 return;
1339 }
1340 if (background.color) {
1341 const color = rangeColorToRgb(background.color);
1342 elementStyle.backgroundColor = color ? getStyleFromRgb(color, background.opacity) : "";
1343 } else {
1344 elementStyle.backgroundColor = "";
1345 }
1346 elementStyle.backgroundImage = background.image || "";
1347 elementStyle.backgroundPosition = background.position || "";
1348 elementStyle.backgroundRepeat = background.repeat || "";
1349 elementStyle.backgroundSize = background.size || "";
1350 }
1351 initPlugins() {
1352 this._resizePlugins = [];
1353 for (const [, plugin] of this.container.plugins) {
1354 if (plugin.resize) {
1355 this._resizePlugins.push(plugin);
1356 }
1357 if (plugin.particleFillColor || plugin.particleStrokeColor) {
1358 this._colorPlugins.push(plugin);
1359 }
1360 }
1361 }
1362 initUpdaters() {
1363 this._preDrawUpdaters = [];
1364 this._postDrawUpdaters = [];
1365 for (const updater of this.container.particles.updaters) {
1366 if (updater.afterDraw) {
1367 this._postDrawUpdaters.push(updater);
1368 }
1369 if (updater.getColorStyles || updater.getTransformValues || updater.beforeDraw) {
1370 this._preDrawUpdaters.push(updater);
1371 }
1372 }
1373 }
1374 loadCanvas(canvas) {
1375 var _a, _b;
1376 if (this._generated) {
1377 (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
1378 }
1379 this._generated = canvas.dataset && generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this._generated;
1380 this.element = canvas;
1381 this.element.ariaHidden = "true";
1382 this._originalStyle = deepExtend({}, this.element.style);
1383 this.size.height = canvas.offsetHeight;
1384 this.size.width = canvas.offsetWidth;
1385 this._context = this.element.getContext("2d");
1386 (_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(this.element, {
1387 attributes: true
1388 });
1389 this.container.retina.init();
1390 this.initBackground();
1391 }
1392 paint() {
1393 const options = this.container.actualOptions;
1394 this.draw(ctx => {
1395 if (options.backgroundMask.enable && options.backgroundMask.cover) {
1396 clear(ctx, this.size);
1397 this._paintBase(this._coverColorStyle);
1398 } else {
1399 this._paintBase();
1400 }
1401 });
1402 }
1403 resize() {
1404 if (!this.element) {
1405 return;
1406 }
1407 const container = this.container,
1408 pxRatio = container.retina.pixelRatio,
1409 size = container.canvas.size,
1410 newSize = {
1411 width: this.element.offsetWidth * pxRatio,
1412 height: this.element.offsetHeight * pxRatio
1413 };
1414 if (newSize.height === size.height && newSize.width === size.width && newSize.height === this.element.height && newSize.width === this.element.width) {
1415 return;
1416 }
1417 const oldSize = Object.assign({}, size);
1418 this.element.width = size.width = this.element.offsetWidth * pxRatio;
1419 this.element.height = size.height = this.element.offsetHeight * pxRatio;
1420 if (this.container.started) {
1421 this.resizeFactor = {
1422 width: size.width / oldSize.width,
1423 height: size.height / oldSize.height
1424 };
1425 }
1426 }
1427 stop() {
1428 this.draw(ctx => {
1429 clear(ctx, this.size);
1430 });
1431 }
1432 async windowResize() {
1433 if (!this.element) {
1434 return;
1435 }
1436 this.resize();
1437 const container = this.container,
1438 needsRefresh = container.updateActualOptions();
1439 container.particles.setDensity();
1440 this._applyResizePlugins();
1441 if (needsRefresh) {
1442 await container.refresh();
1443 }
1444 }
1445 _applyPostDrawUpdaters(particle) {
1446 var _a;
1447 for (const updater of this._postDrawUpdaters) {
1448 (_a = updater.afterDraw) === null || _a === void 0 ? void 0 : _a.call(updater, particle);
1449 }
1450 }
1451 _applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
1452 var _a;
1453 for (const updater of this._preDrawUpdaters) {
1454 if (updater.getColorStyles) {
1455 const {
1456 fill,
1457 stroke
1458 } = updater.getColorStyles(particle, ctx, radius, zOpacity);
1459 if (fill) {
1460 colorStyles.fill = fill;
1461 }
1462 if (stroke) {
1463 colorStyles.stroke = stroke;
1464 }
1465 }
1466 if (updater.getTransformValues) {
1467 const updaterTransform = updater.getTransformValues(particle);
1468 for (const key in updaterTransform) {
1469 setTransformValue(transform, updaterTransform, key);
1470 }
1471 }
1472 (_a = updater.beforeDraw) === null || _a === void 0 ? void 0 : _a.call(updater, particle);
1473 }
1474 }
1475 _applyResizePlugins() {
1476 for (const plugin of this._resizePlugins) {
1477 if (plugin.resize) {
1478 plugin.resize();
1479 }
1480 }
1481 }
1482 _getPluginParticleColors(particle) {
1483 let fColor, sColor;
1484 for (const plugin of this._colorPlugins) {
1485 if (!fColor && plugin.particleFillColor) {
1486 fColor = rangeColorToHsl(plugin.particleFillColor(particle));
1487 }
1488 if (!sColor && plugin.particleStrokeColor) {
1489 sColor = rangeColorToHsl(plugin.particleStrokeColor(particle));
1490 }
1491 if (fColor && sColor) {
1492 break;
1493 }
1494 }
1495 return [fColor, sColor];
1496 }
1497 _initCover() {
1498 const options = this.container.actualOptions,
1499 cover = options.backgroundMask.cover,
1500 color = cover.color,
1501 coverRgb = rangeColorToRgb(color);
1502 if (coverRgb) {
1503 const coverColor = {
1504 r: coverRgb.r,
1505 g: coverRgb.g,
1506 b: coverRgb.b,
1507 a: cover.opacity
1508 };
1509 this._coverColorStyle = getStyleFromRgb(coverColor, coverColor.a);
1510 }
1511 }
1512 _initStyle() {
1513 const element = this.element,
1514 options = this.container.actualOptions;
1515 if (!element) {
1516 return;
1517 }
1518 if (this._fullScreen) {
1519 this._originalStyle = deepExtend({}, element.style);
1520 this._setFullScreenStyle();
1521 } else {
1522 this._resetOriginalStyle();
1523 }
1524 for (const key in options.style) {
1525 if (!key || !options.style) {
1526 continue;
1527 }
1528 const value = options.style[key];
1529 if (!value) {
1530 continue;
1531 }
1532 element.style.setProperty(key, value, "important");
1533 }
1534 }
1535 async _initTrail() {
1536 const options = this.container.actualOptions,
1537 trail = options.particles.move.trail,
1538 trailFill = trail.fill;
1539 if (!trail.enable) {
1540 return;
1541 }
1542 if (trailFill.color) {
1543 const fillColor = rangeColorToRgb(trailFill.color);
1544 if (!fillColor) {
1545 return;
1546 }
1547 const trail = options.particles.move.trail;
1548 this._trailFill = {
1549 color: Object.assign({}, fillColor),
1550 opacity: 1 / trail.length
1551 };
1552 } else {
1553 await new Promise((resolve, reject) => {
1554 if (!trailFill.image) {
1555 return;
1556 }
1557 const img = document.createElement("img");
1558 img.addEventListener("load", () => {
1559 this._trailFill = {
1560 image: img,
1561 opacity: 1 / trail.length
1562 };
1563 resolve();
1564 });
1565 img.addEventListener("error", evt => {
1566 reject(evt.error);
1567 });
1568 img.src = trailFill.image;
1569 });
1570 }
1571 }
1572 _paintBase(baseColor) {
1573 this.draw(ctx => {
1574 paintBase(ctx, this.size, baseColor);
1575 });
1576 }
1577 _paintImage(image, opacity) {
1578 this.draw(ctx => {
1579 paintImage(ctx, this.size, image, opacity);
1580 });
1581 }
1582 _repairStyle() {
1583 var _a, _b;
1584 const element = this.element;
1585 if (!element) {
1586 return;
1587 }
1588 (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1589 this._initStyle();
1590 this.initBackground();
1591 (_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(element, {
1592 attributes: true
1593 });
1594 }
1595 _resetOriginalStyle() {
1596 const element = this.element,
1597 originalStyle = this._originalStyle;
1598 if (!(element && originalStyle)) {
1599 return;
1600 }
1601 element.style.position = originalStyle.position;
1602 element.style.zIndex = originalStyle.zIndex;
1603 element.style.top = originalStyle.top;
1604 element.style.left = originalStyle.left;
1605 element.style.width = originalStyle.width;
1606 element.style.height = originalStyle.height;
1607 }
1608 _setFullScreenStyle() {
1609 const element = this.element;
1610 if (!element) {
1611 return;
1612 }
1613 const priority = "important";
1614 element.style.setProperty("position", "fixed", priority);
1615 element.style.setProperty("z-index", this.container.actualOptions.fullScreen.zIndex.toString(10), priority);
1616 element.style.setProperty("top", "0", priority);
1617 element.style.setProperty("left", "0", priority);
1618 element.style.setProperty("width", "100%", priority);
1619 element.style.setProperty("height", "100%", priority);
1620 }
1621}
1622;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/EventListeners.js
1623
1624
1625function manageListener(element, event, handler, add, options) {
1626 if (add) {
1627 let addOptions = {
1628 passive: true
1629 };
1630 if (typeof options === "boolean") {
1631 addOptions.capture = options;
1632 } else if (options !== undefined) {
1633 addOptions = options;
1634 }
1635 element.addEventListener(event, handler, addOptions);
1636 } else {
1637 const removeOptions = options;
1638 element.removeEventListener(event, handler, removeOptions);
1639 }
1640}
1641class EventListeners {
1642 constructor(container) {
1643 this.container = container;
1644 this.canPush = true;
1645 this.handlers = {
1646 mouseMove: e => this.mouseTouchMove(e),
1647 touchStart: e => this.mouseTouchMove(e),
1648 touchMove: e => this.mouseTouchMove(e),
1649 touchEnd: () => this.mouseTouchFinish(),
1650 mouseLeave: () => this.mouseTouchFinish(),
1651 touchCancel: () => this.mouseTouchFinish(),
1652 touchEndClick: e => this.mouseTouchClick(e),
1653 mouseUp: e => this.mouseTouchClick(e),
1654 mouseDown: () => this.mouseDown(),
1655 visibilityChange: () => this.handleVisibilityChange(),
1656 themeChange: e => this.handleThemeChange(e),
1657 oldThemeChange: e => this.handleThemeChange(e),
1658 resize: () => this.handleWindowResize()
1659 };
1660 }
1661 addListeners() {
1662 this.manageListeners(true);
1663 }
1664 removeListeners() {
1665 this.manageListeners(false);
1666 }
1667 doMouseTouchClick(e) {
1668 const container = this.container,
1669 options = container.actualOptions;
1670 if (this.canPush) {
1671 const mouseInteractivity = container.interactivity.mouse,
1672 mousePos = mouseInteractivity.position;
1673 if (!mousePos) {
1674 return;
1675 }
1676 mouseInteractivity.clickPosition = Object.assign({}, mousePos);
1677 mouseInteractivity.clickTime = new Date().getTime();
1678 const onClick = options.interactivity.events.onClick;
1679 executeOnSingleOrMultiple(onClick.mode, mode => this.handleClickMode(mode));
1680 }
1681 if (e.type === "touchend") {
1682 setTimeout(() => this.mouseTouchFinish(), 500);
1683 }
1684 }
1685 handleClickMode(mode) {
1686 this.container.handleClickMode(mode);
1687 }
1688 handleThemeChange(e) {
1689 const mediaEvent = e,
1690 container = this.container,
1691 options = container.options,
1692 defaultThemes = options.defaultThemes,
1693 themeName = mediaEvent.matches ? defaultThemes.dark : defaultThemes.light,
1694 theme = options.themes.find(theme => theme.name === themeName);
1695 if (theme && theme.default.auto) {
1696 container.loadTheme(themeName);
1697 }
1698 }
1699 handleVisibilityChange() {
1700 const container = this.container,
1701 options = container.actualOptions;
1702 this.mouseTouchFinish();
1703 if (!options.pauseOnBlur) {
1704 return;
1705 }
1706 if (document === null || document === void 0 ? void 0 : document.hidden) {
1707 container.pageHidden = true;
1708 container.pause();
1709 } else {
1710 container.pageHidden = false;
1711 if (container.getAnimationStatus()) {
1712 container.play(true);
1713 } else {
1714 container.draw(true);
1715 }
1716 }
1717 }
1718 handleWindowResize() {
1719 if (this.resizeTimeout) {
1720 clearTimeout(this.resizeTimeout);
1721 delete this.resizeTimeout;
1722 }
1723 this.resizeTimeout = setTimeout(async () => {
1724 var _a;
1725 return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize();
1726 }, this.container.actualOptions.interactivity.events.resize.delay * 1000);
1727 }
1728 manageListeners(add) {
1729 var _a;
1730 const handlers = this.handlers,
1731 container = this.container,
1732 options = container.actualOptions,
1733 detectType = options.interactivity.detectsOn;
1734 let mouseLeaveTmpEvent = mouseLeaveEvent;
1735 if (detectType === "window") {
1736 container.interactivity.element = window;
1737 mouseLeaveTmpEvent = mouseOutEvent;
1738 } else if (detectType === "parent" && container.canvas.element) {
1739 const canvasEl = container.canvas.element;
1740 container.interactivity.element = (_a = canvasEl.parentElement) !== null && _a !== void 0 ? _a : canvasEl.parentNode;
1741 } else {
1742 container.interactivity.element = container.canvas.element;
1743 }
1744 const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
1745 if (mediaMatch) {
1746 if (mediaMatch.addEventListener !== undefined) {
1747 manageListener(mediaMatch, "change", handlers.themeChange, add);
1748 } else if (mediaMatch.addListener !== undefined) {
1749 if (add) {
1750 mediaMatch.addListener(handlers.oldThemeChange);
1751 } else {
1752 mediaMatch.removeListener(handlers.oldThemeChange);
1753 }
1754 }
1755 }
1756 const interactivityEl = container.interactivity.element;
1757 if (!interactivityEl) {
1758 return;
1759 }
1760 const html = interactivityEl;
1761 if (options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable) {
1762 manageListener(interactivityEl, mouseMoveEvent, handlers.mouseMove, add);
1763 manageListener(interactivityEl, touchStartEvent, handlers.touchStart, add);
1764 manageListener(interactivityEl, touchMoveEvent, handlers.touchMove, add);
1765 if (!options.interactivity.events.onClick.enable) {
1766 manageListener(interactivityEl, touchEndEvent, handlers.touchEnd, add);
1767 } else {
1768 manageListener(interactivityEl, touchEndEvent, handlers.touchEndClick, add);
1769 manageListener(interactivityEl, mouseUpEvent, handlers.mouseUp, add);
1770 manageListener(interactivityEl, mouseDownEvent, handlers.mouseDown, add);
1771 }
1772 manageListener(interactivityEl, mouseLeaveTmpEvent, handlers.mouseLeave, add);
1773 manageListener(interactivityEl, touchCancelEvent, handlers.touchCancel, add);
1774 }
1775 if (container.canvas.element) {
1776 container.canvas.element.style.pointerEvents = html === container.canvas.element ? "initial" : "none";
1777 }
1778 if (options.interactivity.events.resize) {
1779 if (typeof ResizeObserver !== "undefined") {
1780 if (this.resizeObserver && !add) {
1781 if (container.canvas.element) {
1782 this.resizeObserver.unobserve(container.canvas.element);
1783 }
1784 this.resizeObserver.disconnect();
1785 delete this.resizeObserver;
1786 } else if (!this.resizeObserver && add && container.canvas.element) {
1787 this.resizeObserver = new ResizeObserver(entries => {
1788 const entry = entries.find(e => e.target === container.canvas.element);
1789 if (!entry) {
1790 return;
1791 }
1792 this.handleWindowResize();
1793 });
1794 this.resizeObserver.observe(container.canvas.element);
1795 }
1796 } else {
1797 manageListener(window, resizeEvent, handlers.resize, add);
1798 }
1799 }
1800 if (document) {
1801 manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
1802 }
1803 }
1804 mouseDown() {
1805 const interactivity = this.container.interactivity;
1806 if (interactivity) {
1807 const mouse = interactivity.mouse;
1808 mouse.clicking = true;
1809 mouse.downPosition = mouse.position;
1810 }
1811 }
1812 mouseTouchClick(e) {
1813 const container = this.container,
1814 options = container.actualOptions,
1815 mouse = container.interactivity.mouse;
1816 mouse.inside = true;
1817 let handled = false;
1818 const mousePosition = mouse.position;
1819 if (!mousePosition || !options.interactivity.events.onClick.enable) {
1820 return;
1821 }
1822 for (const [, plugin] of container.plugins) {
1823 if (!plugin.clickPositionValid) {
1824 continue;
1825 }
1826 handled = plugin.clickPositionValid(mousePosition);
1827 if (handled) {
1828 break;
1829 }
1830 }
1831 if (!handled) {
1832 this.doMouseTouchClick(e);
1833 }
1834 mouse.clicking = false;
1835 }
1836 mouseTouchFinish() {
1837 const interactivity = this.container.interactivity;
1838 if (!interactivity) {
1839 return;
1840 }
1841 const mouse = interactivity.mouse;
1842 delete mouse.position;
1843 delete mouse.clickPosition;
1844 delete mouse.downPosition;
1845 interactivity.status = mouseLeaveEvent;
1846 mouse.inside = false;
1847 mouse.clicking = false;
1848 }
1849 mouseTouchMove(e) {
1850 var _a, _b, _c, _d, _e, _f, _g;
1851 const container = this.container,
1852 options = container.actualOptions;
1853 if (!((_a = container.interactivity) === null || _a === void 0 ? void 0 : _a.element)) {
1854 return;
1855 }
1856 container.interactivity.mouse.inside = true;
1857 let pos;
1858 const canvas = container.canvas.element;
1859 if (e.type.startsWith("pointer")) {
1860 this.canPush = true;
1861 const mouseEvent = e;
1862 if (container.interactivity.element === window) {
1863 if (canvas) {
1864 const clientRect = canvas.getBoundingClientRect();
1865 pos = {
1866 x: mouseEvent.clientX - clientRect.left,
1867 y: mouseEvent.clientY - clientRect.top
1868 };
1869 }
1870 } else if (options.interactivity.detectsOn === "parent") {
1871 const source = mouseEvent.target,
1872 target = mouseEvent.currentTarget,
1873 canvasEl = container.canvas.element;
1874 if (source && target && canvasEl) {
1875 const sourceRect = source.getBoundingClientRect(),
1876 targetRect = target.getBoundingClientRect(),
1877 canvasRect = canvasEl.getBoundingClientRect();
1878 pos = {
1879 x: mouseEvent.offsetX + 2 * sourceRect.left - (targetRect.left + canvasRect.left),
1880 y: mouseEvent.offsetY + 2 * sourceRect.top - (targetRect.top + canvasRect.top)
1881 };
1882 } else {
1883 pos = {
1884 x: (_b = mouseEvent.offsetX) !== null && _b !== void 0 ? _b : mouseEvent.clientX,
1885 y: (_c = mouseEvent.offsetY) !== null && _c !== void 0 ? _c : mouseEvent.clientY
1886 };
1887 }
1888 } else if (mouseEvent.target === container.canvas.element) {
1889 pos = {
1890 x: (_d = mouseEvent.offsetX) !== null && _d !== void 0 ? _d : mouseEvent.clientX,
1891 y: (_e = mouseEvent.offsetY) !== null && _e !== void 0 ? _e : mouseEvent.clientY
1892 };
1893 }
1894 } else {
1895 this.canPush = e.type !== "touchmove";
1896 const touchEvent = e,
1897 lastTouch = touchEvent.touches[touchEvent.touches.length - 1],
1898 canvasRect = canvas === null || canvas === void 0 ? void 0 : canvas.getBoundingClientRect();
1899 pos = {
1900 x: lastTouch.clientX - ((_f = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.left) !== null && _f !== void 0 ? _f : 0),
1901 y: lastTouch.clientY - ((_g = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.top) !== null && _g !== void 0 ? _g : 0)
1902 };
1903 }
1904 const pxRatio = container.retina.pixelRatio;
1905 if (pos) {
1906 pos.x *= pxRatio;
1907 pos.y *= pxRatio;
1908 }
1909 container.interactivity.mouse.position = pos;
1910 container.interactivity.status = mouseMoveEvent;
1911 }
1912}
1913;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/FrameManager.js
1914function initDelta(value, fpsLimit = 60, smooth = false) {
1915 return {
1916 value,
1917 factor: smooth ? 60 / fpsLimit : 60 * value / 1000
1918 };
1919}
1920class FrameManager {
1921 constructor(container) {
1922 this.container = container;
1923 }
1924 async nextFrame(timestamp) {
1925 var _a;
1926 try {
1927 const container = this.container;
1928 if (!container.smooth && container.lastFrameTime !== undefined && timestamp < container.lastFrameTime + 1000 / container.fpsLimit) {
1929 container.draw(false);
1930 return;
1931 }
1932 (_a = container.lastFrameTime) !== null && _a !== void 0 ? _a : container.lastFrameTime = timestamp;
1933 const delta = initDelta(timestamp - container.lastFrameTime, container.fpsLimit, container.smooth);
1934 container.lifeTime += delta.value;
1935 container.lastFrameTime = timestamp;
1936 if (delta.value > 1000) {
1937 container.draw(false);
1938 return;
1939 }
1940 await container.particles.draw(delta);
1941 if (container.duration > 0 && container.lifeTime > container.duration) {
1942 container.destroy();
1943 return;
1944 }
1945 if (container.getAnimationStatus()) {
1946 container.draw(false);
1947 }
1948 } catch (e) {
1949 console.error("tsParticles error in animation loop", e);
1950 }
1951 }
1952}
1953;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/OptionsColor.js
1954class OptionsColor {
1955 constructor() {
1956 this.value = "";
1957 }
1958 static create(source, data) {
1959 const color = new OptionsColor();
1960 color.load(source);
1961 if (data !== undefined) {
1962 if (typeof data === "string" || data instanceof Array) {
1963 color.load({
1964 value: data
1965 });
1966 } else {
1967 color.load(data);
1968 }
1969 }
1970 return color;
1971 }
1972 load(data) {
1973 if ((data === null || data === void 0 ? void 0 : data.value) === undefined) {
1974 return;
1975 }
1976 this.value = data.value;
1977 }
1978}
1979;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Background/Background.js
1980
1981class Background {
1982 constructor() {
1983 this.color = new OptionsColor();
1984 this.color.value = "";
1985 this.image = "";
1986 this.position = "";
1987 this.repeat = "";
1988 this.size = "";
1989 this.opacity = 1;
1990 }
1991 load(data) {
1992 if (!data) {
1993 return;
1994 }
1995 if (data.color !== undefined) {
1996 this.color = OptionsColor.create(this.color, data.color);
1997 }
1998 if (data.image !== undefined) {
1999 this.image = data.image;
2000 }
2001 if (data.position !== undefined) {
2002 this.position = data.position;
2003 }
2004 if (data.repeat !== undefined) {
2005 this.repeat = data.repeat;
2006 }
2007 if (data.size !== undefined) {
2008 this.size = data.size;
2009 }
2010 if (data.opacity !== undefined) {
2011 this.opacity = data.opacity;
2012 }
2013 }
2014}
2015;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/BackgroundMask/BackgroundMaskCover.js
2016
2017class BackgroundMaskCover {
2018 constructor() {
2019 this.color = new OptionsColor();
2020 this.color.value = "#fff";
2021 this.opacity = 1;
2022 }
2023 load(data) {
2024 if (!data) {
2025 return;
2026 }
2027 if (data.color !== undefined) {
2028 this.color = OptionsColor.create(this.color, data.color);
2029 }
2030 if (data.opacity !== undefined) {
2031 this.opacity = data.opacity;
2032 }
2033 }
2034}
2035;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/BackgroundMask/BackgroundMask.js
2036
2037class BackgroundMask {
2038 constructor() {
2039 this.composite = "destination-out";
2040 this.cover = new BackgroundMaskCover();
2041 this.enable = false;
2042 }
2043 load(data) {
2044 if (!data) {
2045 return;
2046 }
2047 if (data.composite !== undefined) {
2048 this.composite = data.composite;
2049 }
2050 if (data.cover !== undefined) {
2051 const cover = data.cover;
2052 const color = typeof data.cover === "string" ? {
2053 color: data.cover
2054 } : data.cover;
2055 this.cover.load(cover.color !== undefined ? cover : {
2056 color: color
2057 });
2058 }
2059 if (data.enable !== undefined) {
2060 this.enable = data.enable;
2061 }
2062 }
2063}
2064;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/FullScreen/FullScreen.js
2065class FullScreen {
2066 constructor() {
2067 this.enable = true;
2068 this.zIndex = 0;
2069 }
2070 load(data) {
2071 if (!data) {
2072 return;
2073 }
2074 if (data.enable !== undefined) {
2075 this.enable = data.enable;
2076 }
2077 if (data.zIndex !== undefined) {
2078 this.zIndex = data.zIndex;
2079 }
2080 }
2081}
2082;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Interactivity/Events/ClickEvent.js
2083class ClickEvent {
2084 constructor() {
2085 this.enable = false;
2086 this.mode = [];
2087 }
2088 load(data) {
2089 if (!data) {
2090 return;
2091 }
2092 if (data.enable !== undefined) {
2093 this.enable = data.enable;
2094 }
2095 if (data.mode !== undefined) {
2096 this.mode = data.mode;
2097 }
2098 }
2099}
2100;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Interactivity/Events/DivEvent.js
2101
2102class DivEvent {
2103 constructor() {
2104 this.selectors = [];
2105 this.enable = false;
2106 this.mode = [];
2107 this.type = "circle";
2108 }
2109 get el() {
2110 return this.elementId;
2111 }
2112 set el(value) {
2113 this.elementId = value;
2114 }
2115 get elementId() {
2116 return this.ids;
2117 }
2118 set elementId(value) {
2119 this.ids = value;
2120 }
2121 get ids() {
2122 return executeOnSingleOrMultiple(this.selectors, t => t.replace("#", ""));
2123 }
2124 set ids(value) {
2125 this.selectors = executeOnSingleOrMultiple(value, t => `#${t}`);
2126 }
2127 load(data) {
2128 var _a, _b;
2129 if (!data) {
2130 return;
2131 }
2132 const ids = (_b = (_a = data.ids) !== null && _a !== void 0 ? _a : data.elementId) !== null && _b !== void 0 ? _b : data.el;
2133 if (ids !== undefined) {
2134 this.ids = ids;
2135 }
2136 if (data.selectors !== undefined) {
2137 this.selectors = data.selectors;
2138 }
2139 if (data.enable !== undefined) {
2140 this.enable = data.enable;
2141 }
2142 if (data.mode !== undefined) {
2143 this.mode = data.mode;
2144 }
2145 if (data.type !== undefined) {
2146 this.type = data.type;
2147 }
2148 }
2149}
2150;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Interactivity/Events/Parallax.js
2151class Parallax {
2152 constructor() {
2153 this.enable = false;
2154 this.force = 2;
2155 this.smooth = 10;
2156 }
2157 load(data) {
2158 if (!data) {
2159 return;
2160 }
2161 if (data.enable !== undefined) {
2162 this.enable = data.enable;
2163 }
2164 if (data.force !== undefined) {
2165 this.force = data.force;
2166 }
2167 if (data.smooth !== undefined) {
2168 this.smooth = data.smooth;
2169 }
2170 }
2171}
2172;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Interactivity/Events/HoverEvent.js
2173
2174class HoverEvent {
2175 constructor() {
2176 this.enable = false;
2177 this.mode = [];
2178 this.parallax = new Parallax();
2179 }
2180 load(data) {
2181 if (!data) {
2182 return;
2183 }
2184 if (data.enable !== undefined) {
2185 this.enable = data.enable;
2186 }
2187 if (data.mode !== undefined) {
2188 this.mode = data.mode;
2189 }
2190 this.parallax.load(data.parallax);
2191 }
2192}
2193;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Interactivity/Events/ResizeEvent.js
2194class ResizeEvent {
2195 constructor() {
2196 this.delay = 0.5;
2197 this.enable = true;
2198 }
2199 load(data) {
2200 if (data === undefined) {
2201 return;
2202 }
2203 if (data.delay !== undefined) {
2204 this.delay = data.delay;
2205 }
2206 if (data.enable !== undefined) {
2207 this.enable = data.enable;
2208 }
2209 }
2210}
2211;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Interactivity/Events/Events.js
2212
2213
2214
2215
2216
2217class Events {
2218 constructor() {
2219 this.onClick = new ClickEvent();
2220 this.onDiv = new DivEvent();
2221 this.onHover = new HoverEvent();
2222 this.resize = new ResizeEvent();
2223 }
2224 get onclick() {
2225 return this.onClick;
2226 }
2227 set onclick(value) {
2228 this.onClick = value;
2229 }
2230 get ondiv() {
2231 return this.onDiv;
2232 }
2233 set ondiv(value) {
2234 this.onDiv = value;
2235 }
2236 get onhover() {
2237 return this.onHover;
2238 }
2239 set onhover(value) {
2240 this.onHover = value;
2241 }
2242 load(data) {
2243 var _a, _b, _c;
2244 if (!data) {
2245 return;
2246 }
2247 this.onClick.load((_a = data.onClick) !== null && _a !== void 0 ? _a : data.onclick);
2248 const onDiv = (_b = data.onDiv) !== null && _b !== void 0 ? _b : data.ondiv;
2249 if (onDiv !== undefined) {
2250 this.onDiv = executeOnSingleOrMultiple(onDiv, t => {
2251 const tmp = new DivEvent();
2252 tmp.load(t);
2253 return tmp;
2254 });
2255 }
2256 this.onHover.load((_c = data.onHover) !== null && _c !== void 0 ? _c : data.onhover);
2257 if (typeof data.resize === "boolean") {
2258 this.resize.enable = data.resize;
2259 } else {
2260 this.resize.load(data.resize);
2261 }
2262 }
2263}
2264;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Interactivity/Modes/Modes.js
2265class Modes {
2266 constructor(engine, container) {
2267 this._engine = engine;
2268 this._container = container;
2269 }
2270 load(data) {
2271 if (!data) {
2272 return;
2273 }
2274 if (this._container) {
2275 const interactors = this._engine.plugins.interactors.get(this._container);
2276 if (interactors) {
2277 for (const interactor of interactors) {
2278 if (interactor.loadModeOptions) {
2279 interactor.loadModeOptions(this, data);
2280 }
2281 }
2282 }
2283 }
2284 }
2285}
2286;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Interactivity/Interactivity.js
2287
2288
2289class Interactivity {
2290 constructor(engine, container) {
2291 this.detectsOn = "window";
2292 this.events = new Events();
2293 this.modes = new Modes(engine, container);
2294 }
2295 get detect_on() {
2296 return this.detectsOn;
2297 }
2298 set detect_on(value) {
2299 this.detectsOn = value;
2300 }
2301 load(data) {
2302 var _a;
2303 if (!data) {
2304 return;
2305 }
2306 const detectsOn = (_a = data.detectsOn) !== null && _a !== void 0 ? _a : data.detect_on;
2307 if (detectsOn !== undefined) {
2308 this.detectsOn = detectsOn;
2309 }
2310 this.events.load(data.events);
2311 this.modes.load(data.modes);
2312 }
2313}
2314;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/ManualParticle.js
2315
2316class ManualParticle {
2317 load(data) {
2318 var _a, _b;
2319 if (!data) {
2320 return;
2321 }
2322 if (data.position !== undefined) {
2323 this.position = {
2324 x: (_a = data.position.x) !== null && _a !== void 0 ? _a : 50,
2325 y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50
2326 };
2327 }
2328 if (data.options !== undefined) {
2329 this.options = deepExtend({}, data.options);
2330 }
2331 }
2332}
2333;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Responsive.js
2334
2335class Responsive {
2336 constructor() {
2337 this.maxWidth = Infinity;
2338 this.options = {};
2339 this.mode = "canvas";
2340 }
2341 load(data) {
2342 if (!data) {
2343 return;
2344 }
2345 if (data.maxWidth !== undefined) {
2346 this.maxWidth = data.maxWidth;
2347 }
2348 if (data.mode !== undefined) {
2349 if (data.mode === "screen") {
2350 this.mode = "screen";
2351 } else {
2352 this.mode = "canvas";
2353 }
2354 }
2355 if (data.options !== undefined) {
2356 this.options = deepExtend({}, data.options);
2357 }
2358 }
2359}
2360;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Theme/ThemeDefault.js
2361class ThemeDefault {
2362 constructor() {
2363 this.auto = false;
2364 this.mode = "any";
2365 this.value = false;
2366 }
2367 load(data) {
2368 if (!data) {
2369 return;
2370 }
2371 if (data.auto !== undefined) {
2372 this.auto = data.auto;
2373 }
2374 if (data.mode !== undefined) {
2375 this.mode = data.mode;
2376 }
2377 if (data.value !== undefined) {
2378 this.value = data.value;
2379 }
2380 }
2381}
2382;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Theme/Theme.js
2383
2384
2385class Theme {
2386 constructor() {
2387 this.name = "";
2388 this.default = new ThemeDefault();
2389 }
2390 load(data) {
2391 if (!data) {
2392 return;
2393 }
2394 if (data.name !== undefined) {
2395 this.name = data.name;
2396 }
2397 this.default.load(data.default);
2398 if (data.options !== undefined) {
2399 this.options = deepExtend({}, data.options);
2400 }
2401 }
2402}
2403;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/ColorAnimation.js
2404
2405class ColorAnimation {
2406 constructor() {
2407 this.count = 0;
2408 this.enable = false;
2409 this.offset = 0;
2410 this.speed = 1;
2411 this.decay = 0;
2412 this.sync = true;
2413 }
2414 load(data) {
2415 if (!data) {
2416 return;
2417 }
2418 if (data.count !== undefined) {
2419 this.count = setRangeValue(data.count);
2420 }
2421 if (data.enable !== undefined) {
2422 this.enable = data.enable;
2423 }
2424 if (data.offset !== undefined) {
2425 this.offset = setRangeValue(data.offset);
2426 }
2427 if (data.speed !== undefined) {
2428 this.speed = setRangeValue(data.speed);
2429 }
2430 if (data.decay !== undefined) {
2431 this.decay = setRangeValue(data.decay);
2432 }
2433 if (data.sync !== undefined) {
2434 this.sync = data.sync;
2435 }
2436 }
2437}
2438;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/HslAnimation.js
2439
2440class HslAnimation {
2441 constructor() {
2442 this.h = new ColorAnimation();
2443 this.s = new ColorAnimation();
2444 this.l = new ColorAnimation();
2445 }
2446 load(data) {
2447 if (!data) {
2448 return;
2449 }
2450 this.h.load(data.h);
2451 this.s.load(data.s);
2452 this.l.load(data.l);
2453 }
2454}
2455;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/AnimatableColor.js
2456
2457
2458class AnimatableColor extends OptionsColor {
2459 constructor() {
2460 super();
2461 this.animation = new HslAnimation();
2462 }
2463 static create(source, data) {
2464 const color = new AnimatableColor();
2465 color.load(source);
2466 if (data !== undefined) {
2467 if (typeof data === "string" || data instanceof Array) {
2468 color.load({
2469 value: data
2470 });
2471 } else {
2472 color.load(data);
2473 }
2474 }
2475 return color;
2476 }
2477 load(data) {
2478 super.load(data);
2479 if (!data) {
2480 return;
2481 }
2482 const colorAnimation = data.animation;
2483 if (colorAnimation !== undefined) {
2484 if (colorAnimation.enable !== undefined) {
2485 this.animation.h.load(colorAnimation);
2486 } else {
2487 this.animation.load(data.animation);
2488 }
2489 }
2490 }
2491}
2492;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Collisions/CollisionsAbsorb.js
2493class CollisionsAbsorb {
2494 constructor() {
2495 this.speed = 2;
2496 }
2497 load(data) {
2498 if (!data) {
2499 return;
2500 }
2501 if (data.speed !== undefined) {
2502 this.speed = data.speed;
2503 }
2504 }
2505}
2506;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Collisions/CollisionsOverlap.js
2507class CollisionsOverlap {
2508 constructor() {
2509 this.enable = true;
2510 this.retries = 0;
2511 }
2512 load(data) {
2513 if (!data) {
2514 return;
2515 }
2516 if (data.enable !== undefined) {
2517 this.enable = data.enable;
2518 }
2519 if (data.retries !== undefined) {
2520 this.retries = data.retries;
2521 }
2522 }
2523}
2524;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Random.js
2525class Random {
2526 constructor() {
2527 this.enable = false;
2528 this.minimumValue = 0;
2529 }
2530 load(data) {
2531 if (!data) {
2532 return;
2533 }
2534 if (data.enable !== undefined) {
2535 this.enable = data.enable;
2536 }
2537 if (data.minimumValue !== undefined) {
2538 this.minimumValue = data.minimumValue;
2539 }
2540 }
2541}
2542;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/ValueWithRandom.js
2543
2544
2545class ValueWithRandom {
2546 constructor() {
2547 this.random = new Random();
2548 this.value = 0;
2549 }
2550 load(data) {
2551 if (!data) {
2552 return;
2553 }
2554 if (typeof data.random === "boolean") {
2555 this.random.enable = data.random;
2556 } else {
2557 this.random.load(data.random);
2558 }
2559 if (data.value !== undefined) {
2560 this.value = setRangeValue(data.value, this.random.enable ? this.random.minimumValue : undefined);
2561 }
2562 }
2563}
2564;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js
2565
2566class ParticlesBounceFactor extends ValueWithRandom {
2567 constructor() {
2568 super();
2569 this.random.minimumValue = 0.1;
2570 this.value = 1;
2571 }
2572}
2573;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js
2574
2575class ParticlesBounce {
2576 constructor() {
2577 this.horizontal = new ParticlesBounceFactor();
2578 this.vertical = new ParticlesBounceFactor();
2579 }
2580 load(data) {
2581 if (!data) {
2582 return;
2583 }
2584 this.horizontal.load(data.horizontal);
2585 this.vertical.load(data.vertical);
2586 }
2587}
2588;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Collisions/Collisions.js
2589
2590
2591
2592class Collisions {
2593 constructor() {
2594 this.absorb = new CollisionsAbsorb();
2595 this.bounce = new ParticlesBounce();
2596 this.enable = false;
2597 this.mode = "bounce";
2598 this.overlap = new CollisionsOverlap();
2599 }
2600 load(data) {
2601 if (!data) {
2602 return;
2603 }
2604 this.absorb.load(data.absorb);
2605 this.bounce.load(data.bounce);
2606 if (data.enable !== undefined) {
2607 this.enable = data.enable;
2608 }
2609 if (data.mode !== undefined) {
2610 this.mode = data.mode;
2611 }
2612 this.overlap.load(data.overlap);
2613 }
2614}
2615;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/MoveAngle.js
2616
2617class MoveAngle {
2618 constructor() {
2619 this.offset = 0;
2620 this.value = 90;
2621 }
2622 load(data) {
2623 if (!data) {
2624 return;
2625 }
2626 if (data.offset !== undefined) {
2627 this.offset = setRangeValue(data.offset);
2628 }
2629 if (data.value !== undefined) {
2630 this.value = setRangeValue(data.value);
2631 }
2632 }
2633}
2634;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/MoveAttract.js
2635
2636class MoveAttract {
2637 constructor() {
2638 this.distance = 200;
2639 this.enable = false;
2640 this.rotate = {
2641 x: 3000,
2642 y: 3000
2643 };
2644 }
2645 get rotateX() {
2646 return this.rotate.x;
2647 }
2648 set rotateX(value) {
2649 this.rotate.x = value;
2650 }
2651 get rotateY() {
2652 return this.rotate.y;
2653 }
2654 set rotateY(value) {
2655 this.rotate.y = value;
2656 }
2657 load(data) {
2658 var _a, _b, _c, _d;
2659 if (!data) {
2660 return;
2661 }
2662 if (data.distance !== undefined) {
2663 this.distance = setRangeValue(data.distance);
2664 }
2665 if (data.enable !== undefined) {
2666 this.enable = data.enable;
2667 }
2668 const rotateX = (_b = (_a = data.rotate) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : data.rotateX;
2669 if (rotateX !== undefined) {
2670 this.rotate.x = rotateX;
2671 }
2672 const rotateY = (_d = (_c = data.rotate) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : data.rotateY;
2673 if (rotateY !== undefined) {
2674 this.rotate.y = rotateY;
2675 }
2676 }
2677}
2678;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/MoveCenter.js
2679class MoveCenter {
2680 constructor() {
2681 this.x = 50;
2682 this.y = 50;
2683 this.mode = "percent";
2684 this.radius = 0;
2685 }
2686 load(data) {
2687 if (!data) {
2688 return;
2689 }
2690 if (data.x !== undefined) {
2691 this.x = data.x;
2692 }
2693 if (data.y !== undefined) {
2694 this.y = data.y;
2695 }
2696 if (data.mode !== undefined) {
2697 this.mode = data.mode;
2698 }
2699 if (data.radius !== undefined) {
2700 this.radius = data.radius;
2701 }
2702 }
2703}
2704;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/MoveGravity.js
2705
2706class MoveGravity {
2707 constructor() {
2708 this.acceleration = 9.81;
2709 this.enable = false;
2710 this.inverse = false;
2711 this.maxSpeed = 50;
2712 }
2713 load(data) {
2714 if (!data) {
2715 return;
2716 }
2717 if (data.acceleration !== undefined) {
2718 this.acceleration = setRangeValue(data.acceleration);
2719 }
2720 if (data.enable !== undefined) {
2721 this.enable = data.enable;
2722 }
2723 if (data.inverse !== undefined) {
2724 this.inverse = data.inverse;
2725 }
2726 if (data.maxSpeed !== undefined) {
2727 this.maxSpeed = setRangeValue(data.maxSpeed);
2728 }
2729 }
2730}
2731;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/Path/MovePath.js
2732
2733
2734class MovePath {
2735 constructor() {
2736 this.clamp = true;
2737 this.delay = new ValueWithRandom();
2738 this.enable = false;
2739 this.options = {};
2740 }
2741 load(data) {
2742 if (!data) {
2743 return;
2744 }
2745 if (data.clamp !== undefined) {
2746 this.clamp = data.clamp;
2747 }
2748 this.delay.load(data.delay);
2749 if (data.enable !== undefined) {
2750 this.enable = data.enable;
2751 }
2752 this.generator = data.generator;
2753 if (data.options) {
2754 this.options = deepExtend(this.options, data.options);
2755 }
2756 }
2757}
2758;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/MoveTrailFill.js
2759
2760class MoveTrailFill {
2761 load(data) {
2762 if (!data) {
2763 return;
2764 }
2765 if (data.color !== undefined) {
2766 this.color = OptionsColor.create(this.color, data.color);
2767 }
2768 if (data.image !== undefined) {
2769 this.image = data.image;
2770 }
2771 }
2772}
2773;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/MoveTrail.js
2774
2775class MoveTrail {
2776 constructor() {
2777 this.enable = false;
2778 this.length = 10;
2779 this.fill = new MoveTrailFill();
2780 }
2781 get fillColor() {
2782 return this.fill.color;
2783 }
2784 set fillColor(value) {
2785 this.fill.load({
2786 color: value
2787 });
2788 }
2789 load(data) {
2790 if (!data) {
2791 return;
2792 }
2793 if (data.enable !== undefined) {
2794 this.enable = data.enable;
2795 }
2796 if (data.fill !== undefined || data.fillColor !== undefined) {
2797 this.fill.load(data.fill || {
2798 color: data.fillColor
2799 });
2800 }
2801 if (data.length !== undefined) {
2802 this.length = data.length;
2803 }
2804 }
2805}
2806;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/OutModes.js
2807class OutModes {
2808 constructor() {
2809 this.default = "out";
2810 }
2811 load(data) {
2812 var _a, _b, _c, _d;
2813 if (!data) {
2814 return;
2815 }
2816 if (data.default !== undefined) {
2817 this.default = data.default;
2818 }
2819 this.bottom = (_a = data.bottom) !== null && _a !== void 0 ? _a : data.default;
2820 this.left = (_b = data.left) !== null && _b !== void 0 ? _b : data.default;
2821 this.right = (_c = data.right) !== null && _c !== void 0 ? _c : data.default;
2822 this.top = (_d = data.top) !== null && _d !== void 0 ? _d : data.default;
2823 }
2824}
2825;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/Spin.js
2826
2827
2828class Spin {
2829 constructor() {
2830 this.acceleration = 0;
2831 this.enable = false;
2832 }
2833 load(data) {
2834 if (!data) {
2835 return;
2836 }
2837 if (data.acceleration !== undefined) {
2838 this.acceleration = setRangeValue(data.acceleration);
2839 }
2840 if (data.enable !== undefined) {
2841 this.enable = data.enable;
2842 }
2843 this.position = data.position ? deepExtend({}, data.position) : undefined;
2844 }
2845}
2846;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/Move.js
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856class Move {
2857 constructor() {
2858 this.angle = new MoveAngle();
2859 this.attract = new MoveAttract();
2860 this.center = new MoveCenter();
2861 this.decay = 0;
2862 this.distance = {};
2863 this.direction = "none";
2864 this.drift = 0;
2865 this.enable = false;
2866 this.gravity = new MoveGravity();
2867 this.path = new MovePath();
2868 this.outModes = new OutModes();
2869 this.random = false;
2870 this.size = false;
2871 this.speed = 2;
2872 this.spin = new Spin();
2873 this.straight = false;
2874 this.trail = new MoveTrail();
2875 this.vibrate = false;
2876 this.warp = false;
2877 }
2878 get bounce() {
2879 return this.collisions;
2880 }
2881 set bounce(value) {
2882 this.collisions = value;
2883 }
2884 get collisions() {
2885 return false;
2886 }
2887 set collisions(_) {}
2888 get noise() {
2889 return this.path;
2890 }
2891 set noise(value) {
2892 this.path = value;
2893 }
2894 get outMode() {
2895 return this.outModes.default;
2896 }
2897 set outMode(value) {
2898 this.outModes.default = value;
2899 }
2900 get out_mode() {
2901 return this.outMode;
2902 }
2903 set out_mode(value) {
2904 this.outMode = value;
2905 }
2906 load(data) {
2907 var _a, _b, _c;
2908 if (!data) {
2909 return;
2910 }
2911 this.angle.load(typeof data.angle === "number" ? {
2912 value: data.angle
2913 } : data.angle);
2914 this.attract.load(data.attract);
2915 this.center.load(data.center);
2916 if (data.decay !== undefined) {
2917 this.decay = setRangeValue(data.decay);
2918 }
2919 if (data.direction !== undefined) {
2920 this.direction = data.direction;
2921 }
2922 if (data.distance !== undefined) {
2923 this.distance = typeof data.distance === "number" ? {
2924 horizontal: data.distance,
2925 vertical: data.distance
2926 } : Object.assign({}, data.distance);
2927 }
2928 if (data.drift !== undefined) {
2929 this.drift = setRangeValue(data.drift);
2930 }
2931 if (data.enable !== undefined) {
2932 this.enable = data.enable;
2933 }
2934 this.gravity.load(data.gravity);
2935 const outModes = (_b = (_a = data.outModes) !== null && _a !== void 0 ? _a : data.outMode) !== null && _b !== void 0 ? _b : data.out_mode;
2936 if (outModes !== undefined) {
2937 if (typeof outModes === "object") {
2938 this.outModes.load(outModes);
2939 } else {
2940 this.outModes.load({
2941 default: outModes
2942 });
2943 }
2944 }
2945 this.path.load((_c = data.path) !== null && _c !== void 0 ? _c : data.noise);
2946 if (data.random !== undefined) {
2947 this.random = data.random;
2948 }
2949 if (data.size !== undefined) {
2950 this.size = data.size;
2951 }
2952 if (data.speed !== undefined) {
2953 this.speed = setRangeValue(data.speed);
2954 }
2955 this.spin.load(data.spin);
2956 if (data.straight !== undefined) {
2957 this.straight = data.straight;
2958 }
2959 this.trail.load(data.trail);
2960 if (data.vibrate !== undefined) {
2961 this.vibrate = data.vibrate;
2962 }
2963 if (data.warp !== undefined) {
2964 this.warp = data.warp;
2965 }
2966 }
2967}
2968;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/AnimationOptions.js
2969
2970class AnimationOptions {
2971 constructor() {
2972 this.count = 0;
2973 this.enable = false;
2974 this.speed = 1;
2975 this.decay = 0;
2976 this.sync = false;
2977 }
2978 load(data) {
2979 if (!data) {
2980 return;
2981 }
2982 if (data.count !== undefined) {
2983 this.count = setRangeValue(data.count);
2984 }
2985 if (data.enable !== undefined) {
2986 this.enable = data.enable;
2987 }
2988 if (data.speed !== undefined) {
2989 this.speed = setRangeValue(data.speed);
2990 }
2991 if (data.decay !== undefined) {
2992 this.decay = setRangeValue(data.decay);
2993 }
2994 if (data.sync !== undefined) {
2995 this.sync = data.sync;
2996 }
2997 }
2998}
2999;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js
3000
3001class OpacityAnimation extends AnimationOptions {
3002 constructor() {
3003 super();
3004 this.destroy = "none";
3005 this.enable = false;
3006 this.speed = 2;
3007 this.startValue = "random";
3008 this.sync = false;
3009 }
3010 get opacity_min() {
3011 return this.minimumValue;
3012 }
3013 set opacity_min(value) {
3014 this.minimumValue = value;
3015 }
3016 load(data) {
3017 var _a;
3018 if (!data) {
3019 return;
3020 }
3021 super.load(data);
3022 if (data.destroy !== undefined) {
3023 this.destroy = data.destroy;
3024 }
3025 if (data.enable !== undefined) {
3026 this.enable = data.enable;
3027 }
3028 this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.opacity_min;
3029 if (data.speed !== undefined) {
3030 this.speed = data.speed;
3031 }
3032 if (data.startValue !== undefined) {
3033 this.startValue = data.startValue;
3034 }
3035 if (data.sync !== undefined) {
3036 this.sync = data.sync;
3037 }
3038 }
3039}
3040;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Opacity/Opacity.js
3041
3042
3043
3044class Opacity extends ValueWithRandom {
3045 constructor() {
3046 super();
3047 this.animation = new OpacityAnimation();
3048 this.random.minimumValue = 0.1;
3049 this.value = 1;
3050 }
3051 get anim() {
3052 return this.animation;
3053 }
3054 set anim(value) {
3055 this.animation = value;
3056 }
3057 load(data) {
3058 var _a;
3059 if (!data) {
3060 return;
3061 }
3062 super.load(data);
3063 const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
3064 if (animation !== undefined) {
3065 this.animation.load(animation);
3066 this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
3067 }
3068 }
3069}
3070;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Number/ParticlesDensity.js
3071class ParticlesDensity {
3072 constructor() {
3073 this.enable = false;
3074 this.width = 1920;
3075 this.height = 1080;
3076 }
3077 get area() {
3078 return this.width;
3079 }
3080 set area(value) {
3081 this.width = value;
3082 }
3083 get factor() {
3084 return this.height;
3085 }
3086 set factor(value) {
3087 this.height = value;
3088 }
3089 get value_area() {
3090 return this.area;
3091 }
3092 set value_area(value) {
3093 this.area = value;
3094 }
3095 load(data) {
3096 var _a, _b, _c;
3097 if (!data) {
3098 return;
3099 }
3100 if (data.enable !== undefined) {
3101 this.enable = data.enable;
3102 }
3103 const width = (_b = (_a = data.width) !== null && _a !== void 0 ? _a : data.area) !== null && _b !== void 0 ? _b : data.value_area;
3104 if (width !== undefined) {
3105 this.width = width;
3106 }
3107 const height = (_c = data.height) !== null && _c !== void 0 ? _c : data.factor;
3108 if (height !== undefined) {
3109 this.height = height;
3110 }
3111 }
3112}
3113;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Number/ParticlesNumber.js
3114
3115class ParticlesNumber {
3116 constructor() {
3117 this.density = new ParticlesDensity();
3118 this.limit = 0;
3119 this.value = 0;
3120 }
3121 get max() {
3122 return this.limit;
3123 }
3124 set max(value) {
3125 this.limit = value;
3126 }
3127 load(data) {
3128 var _a;
3129 if (!data) {
3130 return;
3131 }
3132 this.density.load(data.density);
3133 const limit = (_a = data.limit) !== null && _a !== void 0 ? _a : data.max;
3134 if (limit !== undefined) {
3135 this.limit = limit;
3136 }
3137 if (data.value !== undefined) {
3138 this.value = data.value;
3139 }
3140 }
3141}
3142;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Shadow.js
3143
3144class Shadow {
3145 constructor() {
3146 this.blur = 0;
3147 this.color = new OptionsColor();
3148 this.enable = false;
3149 this.offset = {
3150 x: 0,
3151 y: 0
3152 };
3153 this.color.value = "#000";
3154 }
3155 load(data) {
3156 if (!data) {
3157 return;
3158 }
3159 if (data.blur !== undefined) {
3160 this.blur = data.blur;
3161 }
3162 this.color = OptionsColor.create(this.color, data.color);
3163 if (data.enable !== undefined) {
3164 this.enable = data.enable;
3165 }
3166 if (data.offset === undefined) {
3167 return;
3168 }
3169 if (data.offset.x !== undefined) {
3170 this.offset.x = data.offset.x;
3171 }
3172 if (data.offset.y !== undefined) {
3173 this.offset.y = data.offset.y;
3174 }
3175 }
3176}
3177;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Shape/Shape.js
3178
3179const charKey = "character",
3180 charAltKey = "char",
3181 imageKey = "image",
3182 imageAltKey = "images",
3183 polygonKey = "polygon",
3184 polygonAltKey = "star";
3185class Shape {
3186 constructor() {
3187 this.options = {};
3188 this.type = "circle";
3189 }
3190 get character() {
3191 var _a;
3192 return (_a = this.options[charKey]) !== null && _a !== void 0 ? _a : this.options[charAltKey];
3193 }
3194 set character(value) {
3195 this.options[charAltKey] = this.options[charKey] = value;
3196 }
3197 get custom() {
3198 return this.options;
3199 }
3200 set custom(value) {
3201 this.options = value;
3202 }
3203 get image() {
3204 var _a;
3205 return (_a = this.options[imageKey]) !== null && _a !== void 0 ? _a : this.options[imageAltKey];
3206 }
3207 set image(value) {
3208 this.options[imageAltKey] = this.options[imageKey] = value;
3209 }
3210 get images() {
3211 return this.image;
3212 }
3213 set images(value) {
3214 this.image = value;
3215 }
3216 get polygon() {
3217 var _a;
3218 return (_a = this.options[polygonKey]) !== null && _a !== void 0 ? _a : this.options[polygonAltKey];
3219 }
3220 set polygon(value) {
3221 this.options[polygonAltKey] = this.options[polygonKey] = value;
3222 }
3223 get stroke() {
3224 return [];
3225 }
3226 set stroke(_value) {}
3227 load(data) {
3228 var _a, _b, _c;
3229 if (!data) {
3230 return;
3231 }
3232 const options = (_a = data.options) !== null && _a !== void 0 ? _a : data.custom;
3233 if (options !== undefined) {
3234 for (const shape in options) {
3235 const item = options[shape];
3236 if (item) {
3237 this.options[shape] = deepExtend((_b = this.options[shape]) !== null && _b !== void 0 ? _b : {}, item);
3238 }
3239 }
3240 }
3241 this.loadShape(data.character, charKey, charAltKey, true);
3242 this.loadShape(data.polygon, polygonKey, polygonAltKey, false);
3243 this.loadShape((_c = data.image) !== null && _c !== void 0 ? _c : data.images, imageKey, imageAltKey, true);
3244 if (data.type !== undefined) {
3245 this.type = data.type;
3246 }
3247 }
3248 loadShape(item, mainKey, altKey, altOverride) {
3249 var _a, _b;
3250 if (!item) {
3251 return;
3252 }
3253 const isArray = item instanceof Array;
3254 const emptyValue = isArray ? [] : {},
3255 mainDifferentValues = isArray !== this.options[mainKey] instanceof Array,
3256 altDifferentValues = isArray !== this.options[altKey] instanceof Array;
3257 if (mainDifferentValues) {
3258 this.options[mainKey] = emptyValue;
3259 }
3260 if (altDifferentValues && altOverride) {
3261 this.options[altKey] = emptyValue;
3262 }
3263 this.options[mainKey] = deepExtend((_a = this.options[mainKey]) !== null && _a !== void 0 ? _a : emptyValue, item);
3264 if (!this.options[altKey] || altOverride) {
3265 this.options[altKey] = deepExtend((_b = this.options[altKey]) !== null && _b !== void 0 ? _b : emptyValue, item);
3266 }
3267 }
3268}
3269;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Size/SizeAnimation.js
3270
3271class SizeAnimation extends AnimationOptions {
3272 constructor() {
3273 super();
3274 this.destroy = "none";
3275 this.enable = false;
3276 this.speed = 5;
3277 this.startValue = "random";
3278 this.sync = false;
3279 }
3280 get size_min() {
3281 return this.minimumValue;
3282 }
3283 set size_min(value) {
3284 this.minimumValue = value;
3285 }
3286 load(data) {
3287 var _a;
3288 super.load(data);
3289 if (!data) {
3290 return;
3291 }
3292 if (data.destroy !== undefined) {
3293 this.destroy = data.destroy;
3294 }
3295 if (data.enable !== undefined) {
3296 this.enable = data.enable;
3297 }
3298 this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.size_min;
3299 if (data.speed !== undefined) {
3300 this.speed = data.speed;
3301 }
3302 if (data.startValue !== undefined) {
3303 this.startValue = data.startValue;
3304 }
3305 if (data.sync !== undefined) {
3306 this.sync = data.sync;
3307 }
3308 }
3309}
3310;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Size/Size.js
3311
3312
3313
3314class Size extends ValueWithRandom {
3315 constructor() {
3316 super();
3317 this.animation = new SizeAnimation();
3318 this.random.minimumValue = 1;
3319 this.value = 3;
3320 }
3321 get anim() {
3322 return this.animation;
3323 }
3324 set anim(value) {
3325 this.animation = value;
3326 }
3327 load(data) {
3328 var _a;
3329 super.load(data);
3330 if (!data) {
3331 return;
3332 }
3333 const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
3334 if (animation !== undefined) {
3335 this.animation.load(animation);
3336 this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
3337 }
3338 }
3339}
3340;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Stroke.js
3341
3342
3343class Stroke {
3344 constructor() {
3345 this.width = 0;
3346 }
3347 load(data) {
3348 if (!data) {
3349 return;
3350 }
3351 if (data.color !== undefined) {
3352 this.color = AnimatableColor.create(this.color, data.color);
3353 }
3354 if (data.width !== undefined) {
3355 this.width = setRangeValue(data.width);
3356 }
3357 if (data.opacity !== undefined) {
3358 this.opacity = setRangeValue(data.opacity);
3359 }
3360 }
3361}
3362;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/ZIndex/ZIndex.js
3363
3364class ZIndex extends ValueWithRandom {
3365 constructor() {
3366 super();
3367 this.opacityRate = 1;
3368 this.sizeRate = 1;
3369 this.velocityRate = 1;
3370 }
3371 load(data) {
3372 super.load(data);
3373 if (!data) {
3374 return;
3375 }
3376 if (data.opacityRate !== undefined) {
3377 this.opacityRate = data.opacityRate;
3378 }
3379 if (data.sizeRate !== undefined) {
3380 this.sizeRate = data.sizeRate;
3381 }
3382 if (data.velocityRate !== undefined) {
3383 this.velocityRate = data.velocityRate;
3384 }
3385 }
3386}
3387;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/ParticlesOptions.js
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400class ParticlesOptions {
3401 constructor(engine, container) {
3402 this._engine = engine;
3403 this._container = container;
3404 this.bounce = new ParticlesBounce();
3405 this.collisions = new Collisions();
3406 this.color = new AnimatableColor();
3407 this.color.value = "#fff";
3408 this.groups = {};
3409 this.move = new Move();
3410 this.number = new ParticlesNumber();
3411 this.opacity = new Opacity();
3412 this.reduceDuplicates = false;
3413 this.shadow = new Shadow();
3414 this.shape = new Shape();
3415 this.size = new Size();
3416 this.stroke = new Stroke();
3417 this.zIndex = new ZIndex();
3418 }
3419 load(data) {
3420 var _a, _b, _c, _d, _e, _f;
3421 if (!data) {
3422 return;
3423 }
3424 this.bounce.load(data.bounce);
3425 this.color.load(AnimatableColor.create(this.color, data.color));
3426 if (data.groups !== undefined) {
3427 for (const group in data.groups) {
3428 const item = data.groups[group];
3429 if (item !== undefined) {
3430 this.groups[group] = deepExtend((_a = this.groups[group]) !== null && _a !== void 0 ? _a : {}, item);
3431 }
3432 }
3433 }
3434 this.move.load(data.move);
3435 this.number.load(data.number);
3436 this.opacity.load(data.opacity);
3437 if (data.reduceDuplicates !== undefined) {
3438 this.reduceDuplicates = data.reduceDuplicates;
3439 }
3440 this.shape.load(data.shape);
3441 this.size.load(data.size);
3442 this.shadow.load(data.shadow);
3443 this.zIndex.load(data.zIndex);
3444 const collisions = (_c = (_b = data.move) === null || _b === void 0 ? void 0 : _b.collisions) !== null && _c !== void 0 ? _c : (_d = data.move) === null || _d === void 0 ? void 0 : _d.bounce;
3445 if (collisions !== undefined) {
3446 this.collisions.enable = collisions;
3447 }
3448 this.collisions.load(data.collisions);
3449 if (data.interactivity !== undefined) {
3450 this.interactivity = deepExtend({}, data.interactivity);
3451 }
3452 const strokeToLoad = (_e = data.stroke) !== null && _e !== void 0 ? _e : (_f = data.shape) === null || _f === void 0 ? void 0 : _f.stroke;
3453 if (strokeToLoad) {
3454 this.stroke = executeOnSingleOrMultiple(strokeToLoad, t => {
3455 const tmp = new Stroke();
3456 tmp.load(t);
3457 return tmp;
3458 });
3459 }
3460 if (this._container) {
3461 const updaters = this._engine.plugins.updaters.get(this._container);
3462 if (updaters) {
3463 for (const updater of updaters) {
3464 if (updater.loadOptions) {
3465 updater.loadOptions(this, data);
3466 }
3467 }
3468 }
3469 const interactors = this._engine.plugins.interactors.get(this._container);
3470 if (interactors) {
3471 for (const interactor of interactors) {
3472 if (interactor.loadParticlesOptions) {
3473 interactor.loadParticlesOptions(this, data);
3474 }
3475 }
3476 }
3477 }
3478 }
3479}
3480;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/OptionsUtils.js
3481
3482function loadOptions(options, ...sourceOptionsArr) {
3483 for (const sourceOptions of sourceOptionsArr) {
3484 options.load(sourceOptions);
3485 }
3486}
3487function loadParticlesOptions(engine, container, ...sourceOptionsArr) {
3488 const options = new ParticlesOptions(engine, container);
3489 loadOptions(options, ...sourceOptionsArr);
3490 return options;
3491}
3492;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Options.js
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503class Options {
3504 constructor(engine, container) {
3505 this._engine = engine;
3506 this._container = container;
3507 this.autoPlay = true;
3508 this.background = new Background();
3509 this.backgroundMask = new BackgroundMask();
3510 this.defaultThemes = {};
3511 this.delay = 0;
3512 this.fullScreen = new FullScreen();
3513 this.detectRetina = true;
3514 this.duration = 0;
3515 this.fpsLimit = 120;
3516 this.interactivity = new Interactivity(engine, container);
3517 this.manualParticles = [];
3518 this.particles = loadParticlesOptions(this._engine, this._container);
3519 this.pauseOnBlur = true;
3520 this.pauseOnOutsideViewport = true;
3521 this.responsive = [];
3522 this.smooth = false;
3523 this.style = {};
3524 this.themes = [];
3525 this.zLayers = 100;
3526 }
3527 get backgroundMode() {
3528 return this.fullScreen;
3529 }
3530 set backgroundMode(value) {
3531 this.fullScreen.load(value);
3532 }
3533 get fps_limit() {
3534 return this.fpsLimit;
3535 }
3536 set fps_limit(value) {
3537 this.fpsLimit = value;
3538 }
3539 get retina_detect() {
3540 return this.detectRetina;
3541 }
3542 set retina_detect(value) {
3543 this.detectRetina = value;
3544 }
3545 load(data) {
3546 var _a, _b, _c, _d, _e;
3547 if (!data) {
3548 return;
3549 }
3550 if (data.preset !== undefined) {
3551 executeOnSingleOrMultiple(data.preset, preset => this._importPreset(preset));
3552 }
3553 if (data.autoPlay !== undefined) {
3554 this.autoPlay = data.autoPlay;
3555 }
3556 if (data.delay !== undefined) {
3557 this.delay = setRangeValue(data.delay);
3558 }
3559 const detectRetina = (_a = data.detectRetina) !== null && _a !== void 0 ? _a : data.retina_detect;
3560 if (detectRetina !== undefined) {
3561 this.detectRetina = detectRetina;
3562 }
3563 if (data.duration !== undefined) {
3564 this.duration = setRangeValue(data.duration);
3565 }
3566 const fpsLimit = (_b = data.fpsLimit) !== null && _b !== void 0 ? _b : data.fps_limit;
3567 if (fpsLimit !== undefined) {
3568 this.fpsLimit = fpsLimit;
3569 }
3570 if (data.pauseOnBlur !== undefined) {
3571 this.pauseOnBlur = data.pauseOnBlur;
3572 }
3573 if (data.pauseOnOutsideViewport !== undefined) {
3574 this.pauseOnOutsideViewport = data.pauseOnOutsideViewport;
3575 }
3576 if (data.zLayers !== undefined) {
3577 this.zLayers = data.zLayers;
3578 }
3579 this.background.load(data.background);
3580 const fullScreen = (_c = data.fullScreen) !== null && _c !== void 0 ? _c : data.backgroundMode;
3581 if (typeof fullScreen === "boolean") {
3582 this.fullScreen.enable = fullScreen;
3583 } else {
3584 this.fullScreen.load(fullScreen);
3585 }
3586 this.backgroundMask.load(data.backgroundMask);
3587 this.interactivity.load(data.interactivity);
3588 if (data.manualParticles !== undefined) {
3589 this.manualParticles = data.manualParticles.map(t => {
3590 const tmp = new ManualParticle();
3591 tmp.load(t);
3592 return tmp;
3593 });
3594 }
3595 this.particles.load(data.particles);
3596 this.style = deepExtend(this.style, data.style);
3597 this._engine.plugins.loadOptions(this, data);
3598 if (data.smooth !== undefined) {
3599 this.smooth = data.smooth;
3600 }
3601 const interactors = this._engine.plugins.interactors.get(this._container);
3602 if (interactors) {
3603 for (const interactor of interactors) {
3604 if (interactor.loadOptions) {
3605 interactor.loadOptions(this, data);
3606 }
3607 }
3608 }
3609 if (data.responsive !== undefined) {
3610 for (const responsive of data.responsive) {
3611 const optResponsive = new Responsive();
3612 optResponsive.load(responsive);
3613 this.responsive.push(optResponsive);
3614 }
3615 }
3616 this.responsive.sort((a, b) => a.maxWidth - b.maxWidth);
3617 if (data.themes !== undefined) {
3618 for (const theme of data.themes) {
3619 const existingTheme = this.themes.find(t => t.name === theme.name);
3620 if (!existingTheme) {
3621 const optTheme = new Theme();
3622 optTheme.load(theme);
3623 this.themes.push(optTheme);
3624 } else {
3625 existingTheme.load(theme);
3626 }
3627 }
3628 }
3629 this.defaultThemes.dark = (_d = this._findDefaultTheme("dark")) === null || _d === void 0 ? void 0 : _d.name;
3630 this.defaultThemes.light = (_e = this._findDefaultTheme("light")) === null || _e === void 0 ? void 0 : _e.name;
3631 }
3632 setResponsive(width, pxRatio, defaultOptions) {
3633 this.load(defaultOptions);
3634 const responsiveOptions = this.responsive.find(t => t.mode === "screen" && screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
3635 this.load(responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.options);
3636 return responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.maxWidth;
3637 }
3638 setTheme(name) {
3639 if (name) {
3640 const chosenTheme = this.themes.find(theme => theme.name === name);
3641 if (chosenTheme) {
3642 this.load(chosenTheme.options);
3643 }
3644 } else {
3645 const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)"),
3646 clientDarkMode = mediaMatch && mediaMatch.matches,
3647 defaultTheme = this._findDefaultTheme(clientDarkMode ? "dark" : "light");
3648 if (defaultTheme) {
3649 this.load(defaultTheme.options);
3650 }
3651 }
3652 }
3653 _findDefaultTheme(mode) {
3654 var _a;
3655 return (_a = this.themes.find(theme => theme.default.value && theme.default.mode === mode)) !== null && _a !== void 0 ? _a : this.themes.find(theme => theme.default.value && theme.default.mode === "any");
3656 }
3657 _importPreset(preset) {
3658 this.load(this._engine.plugins.getPreset(preset));
3659 }
3660}
3661;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/InteractionManager.js
3662class InteractionManager {
3663 constructor(engine, container) {
3664 this.container = container;
3665 this._engine = engine;
3666 this._interactors = this._engine.plugins.getInteractors(this.container, true);
3667 this._externalInteractors = [];
3668 this._particleInteractors = [];
3669 }
3670 async externalInteract(delta) {
3671 for (const interactor of this._externalInteractors) {
3672 if (interactor.isEnabled()) {
3673 await interactor.interact(delta);
3674 }
3675 }
3676 }
3677 handleClickMode(mode) {
3678 for (const interactor of this._externalInteractors) {
3679 if (interactor.handleClickMode) {
3680 interactor.handleClickMode(mode);
3681 }
3682 }
3683 }
3684 init() {
3685 this._externalInteractors = [];
3686 this._particleInteractors = [];
3687 for (const interactor of this._interactors) {
3688 switch (interactor.type) {
3689 case "external":
3690 this._externalInteractors.push(interactor);
3691 break;
3692 case "particles":
3693 this._particleInteractors.push(interactor);
3694 break;
3695 }
3696 interactor.init();
3697 }
3698 }
3699 async particlesInteract(particle, delta) {
3700 for (const interactor of this._externalInteractors) {
3701 interactor.clear(particle, delta);
3702 }
3703 for (const interactor of this._particleInteractors) {
3704 if (interactor.isEnabled(particle)) {
3705 await interactor.interact(particle, delta);
3706 }
3707 }
3708 }
3709 async reset(particle) {
3710 for (const interactor of this._externalInteractors) {
3711 if (interactor.isEnabled()) {
3712 await interactor.reset(particle);
3713 }
3714 }
3715 for (const interactor of this._particleInteractors) {
3716 if (interactor.isEnabled(particle)) {
3717 await interactor.reset(particle);
3718 }
3719 }
3720 }
3721}
3722;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Particle.js
3723
3724
3725
3726
3727
3728
3729
3730
3731const fixOutMode = data => {
3732 if (!isInArray(data.outMode, data.checkModes)) {
3733 return;
3734 }
3735 if (data.coord > data.maxCoord - data.radius * 2) {
3736 data.setCb(-data.radius);
3737 } else if (data.coord < data.radius * 2) {
3738 data.setCb(data.radius);
3739 }
3740};
3741class Particle {
3742 constructor(engine, id, container, position, overrideOptions, group) {
3743 this.container = container;
3744 this._engine = engine;
3745 this.init(id, position, overrideOptions, group);
3746 }
3747 destroy(override) {
3748 var _a;
3749 if (this.unbreakable || this.destroyed) {
3750 return;
3751 }
3752 this.destroyed = true;
3753 this.bubble.inRange = false;
3754 this.slow.inRange = false;
3755 for (const [, plugin] of this.container.plugins) {
3756 if (plugin.particleDestroyed) {
3757 plugin.particleDestroyed(this, override);
3758 }
3759 }
3760 for (const updater of this.container.particles.updaters) {
3761 if (updater.particleDestroyed) {
3762 updater.particleDestroyed(this, override);
3763 }
3764 }
3765 (_a = this.pathGenerator) === null || _a === void 0 ? void 0 : _a.reset(this);
3766 }
3767 draw(delta) {
3768 const container = this.container;
3769 for (const [, plugin] of container.plugins) {
3770 container.canvas.drawParticlePlugin(plugin, this, delta);
3771 }
3772 container.canvas.drawParticle(this, delta);
3773 }
3774 getFillColor() {
3775 var _a;
3776 return this._getRollColor((_a = this.bubble.color) !== null && _a !== void 0 ? _a : getHslFromAnimation(this.color));
3777 }
3778 getMass() {
3779 return this.getRadius() ** 2 * Math.PI / 2;
3780 }
3781 getPosition() {
3782 return {
3783 x: this.position.x + this.offset.x,
3784 y: this.position.y + this.offset.y,
3785 z: this.position.z
3786 };
3787 }
3788 getRadius() {
3789 var _a;
3790 return (_a = this.bubble.radius) !== null && _a !== void 0 ? _a : this.size.value;
3791 }
3792 getStrokeColor() {
3793 var _a;
3794 return this._getRollColor((_a = this.bubble.color) !== null && _a !== void 0 ? _a : getHslFromAnimation(this.strokeColor));
3795 }
3796 init(id, position, overrideOptions, group) {
3797 var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3798 const container = this.container,
3799 engine = this._engine;
3800 this.id = id;
3801 this.group = group;
3802 this.fill = true;
3803 this.pathRotation = false;
3804 this.close = true;
3805 this.lastPathTime = 0;
3806 this.destroyed = false;
3807 this.unbreakable = false;
3808 this.rotation = 0;
3809 this.misplaced = false;
3810 this.retina = {
3811 maxDistance: {}
3812 };
3813 this.outType = "normal";
3814 this.ignoresResizeRatio = true;
3815 const pxRatio = container.retina.pixelRatio,
3816 mainOptions = container.actualOptions,
3817 particlesOptions = loadParticlesOptions(this._engine, container, mainOptions.particles),
3818 shapeType = particlesOptions.shape.type,
3819 {
3820 reduceDuplicates
3821 } = particlesOptions;
3822 this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
3823 const shapeOptions = particlesOptions.shape;
3824 if (overrideOptions && overrideOptions.shape && overrideOptions.shape.type) {
3825 const overrideShapeType = overrideOptions.shape.type,
3826 shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
3827 if (shape) {
3828 this.shape = shape;
3829 shapeOptions.load(overrideOptions.shape);
3830 }
3831 }
3832 this.shapeData = this._loadShapeData(shapeOptions, reduceDuplicates);
3833 particlesOptions.load(overrideOptions);
3834 particlesOptions.load((_a = this.shapeData) === null || _a === void 0 ? void 0 : _a.particles);
3835 this.interactivity = new Interactivity(engine, container);
3836 this.interactivity.load(container.actualOptions.interactivity);
3837 this.interactivity.load(particlesOptions.interactivity);
3838 this.fill = (_c = (_b = this.shapeData) === null || _b === void 0 ? void 0 : _b.fill) !== null && _c !== void 0 ? _c : this.fill;
3839 this.close = (_e = (_d = this.shapeData) === null || _d === void 0 ? void 0 : _d.close) !== null && _e !== void 0 ? _e : this.close;
3840 this.options = particlesOptions;
3841 const pathOptions = this.options.move.path;
3842 this.pathDelay = getValue(pathOptions.delay) * 1000;
3843 if (pathOptions.generator) {
3844 this.pathGenerator = this._engine.plugins.getPathGenerator(pathOptions.generator);
3845 if (this.pathGenerator && container.addPath(pathOptions.generator, this.pathGenerator)) {
3846 this.pathGenerator.init(container);
3847 }
3848 }
3849 const zIndexValue = getRangeValue(this.options.zIndex.value);
3850 container.retina.initParticle(this);
3851 const sizeOptions = this.options.size,
3852 sizeRange = sizeOptions.value,
3853 sizeAnimation = sizeOptions.animation;
3854 this.size = {
3855 enable: sizeOptions.animation.enable,
3856 value: getRangeValue(sizeOptions.value) * container.retina.pixelRatio,
3857 max: getRangeMax(sizeRange) * pxRatio,
3858 min: getRangeMin(sizeRange) * pxRatio,
3859 loops: 0,
3860 maxLoops: getRangeValue(sizeOptions.animation.count)
3861 };
3862 if (sizeAnimation.enable) {
3863 this.size.status = "increasing";
3864 this.size.decay = 1 - getRangeValue(sizeAnimation.decay);
3865 switch (sizeAnimation.startValue) {
3866 case "min":
3867 this.size.value = this.size.min;
3868 this.size.status = "increasing";
3869 break;
3870 case "random":
3871 this.size.value = randomInRange(this.size);
3872 this.size.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
3873 break;
3874 case "max":
3875 default:
3876 this.size.value = this.size.max;
3877 this.size.status = "decreasing";
3878 break;
3879 }
3880 }
3881 this.size.initialValue = this.size.value;
3882 this.bubble = {
3883 inRange: false
3884 };
3885 this.slow = {
3886 inRange: false,
3887 factor: 1
3888 };
3889 this.position = this._calcPosition(container, position, clamp(zIndexValue, 0, container.zLayers));
3890 this.initialPosition = this.position.copy();
3891 const canvasSize = container.canvas.size,
3892 moveCenter = Object.assign({}, this.options.move.center),
3893 isCenterPercent = moveCenter.mode === "percent";
3894 this.moveCenter = {
3895 x: moveCenter.x * (isCenterPercent ? canvasSize.width / 100 : 1),
3896 y: moveCenter.y * (isCenterPercent ? canvasSize.height / 100 : 1),
3897 radius: (_f = this.options.move.center.radius) !== null && _f !== void 0 ? _f : 0,
3898 mode: (_g = this.options.move.center.mode) !== null && _g !== void 0 ? _g : "percent"
3899 };
3900 this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
3901 switch (this.options.move.direction) {
3902 case "inside":
3903 this.outType = "inside";
3904 break;
3905 case "outside":
3906 this.outType = "outside";
3907 break;
3908 }
3909 this.initialVelocity = this._calculateVelocity();
3910 this.velocity = this.initialVelocity.copy();
3911 this.moveDecay = 1 - getRangeValue(this.options.move.decay);
3912 this.offset = Vector.origin;
3913 const particles = container.particles;
3914 particles.needsSort = particles.needsSort || particles.lastZIndex < this.position.z;
3915 particles.lastZIndex = this.position.z;
3916 this.zIndexFactor = this.position.z / container.zLayers;
3917 this.sides = 24;
3918 let drawer = container.drawers.get(this.shape);
3919 if (!drawer) {
3920 drawer = this._engine.plugins.getShapeDrawer(this.shape);
3921 if (drawer) {
3922 container.drawers.set(this.shape, drawer);
3923 }
3924 }
3925 if (drawer === null || drawer === void 0 ? void 0 : drawer.loadShape) {
3926 drawer === null || drawer === void 0 ? void 0 : drawer.loadShape(this);
3927 }
3928 const sideCountFunc = drawer === null || drawer === void 0 ? void 0 : drawer.getSidesCount;
3929 if (sideCountFunc) {
3930 this.sides = sideCountFunc(this);
3931 }
3932 this.spawning = false;
3933 this.shadowColor = rangeColorToRgb(this.options.shadow.color);
3934 for (const updater of container.particles.updaters) {
3935 updater.init(this);
3936 }
3937 for (const mover of container.particles.movers) {
3938 (_h = mover.init) === null || _h === void 0 ? void 0 : _h.call(mover, this);
3939 }
3940 if (drawer === null || drawer === void 0 ? void 0 : drawer.particleInit) {
3941 drawer.particleInit(container, this);
3942 }
3943 for (const [, plugin] of container.plugins) {
3944 (_j = plugin.particleCreated) === null || _j === void 0 ? void 0 : _j.call(plugin, this);
3945 }
3946 }
3947 isInsideCanvas() {
3948 const radius = this.getRadius(),
3949 canvasSize = this.container.canvas.size;
3950 return this.position.x >= -radius && this.position.y >= -radius && this.position.y <= canvasSize.height + radius && this.position.x <= canvasSize.width + radius;
3951 }
3952 isVisible() {
3953 return !this.destroyed && !this.spawning && this.isInsideCanvas();
3954 }
3955 reset() {
3956 var _a;
3957 for (const updater of this.container.particles.updaters) {
3958 (_a = updater.reset) === null || _a === void 0 ? void 0 : _a.call(updater, this);
3959 }
3960 }
3961 _calcPosition(container, position, zIndex, tryCount = 0) {
3962 var _a, _b, _c, _d;
3963 for (const [, plugin] of container.plugins) {
3964 const pluginPos = plugin.particlePosition !== undefined ? plugin.particlePosition(position, this) : undefined;
3965 if (pluginPos !== undefined) {
3966 return Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
3967 }
3968 }
3969 const canvasSize = container.canvas.size,
3970 exactPosition = calcExactPositionOrRandomFromSize({
3971 size: canvasSize,
3972 position: position
3973 }),
3974 pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex),
3975 radius = this.getRadius(),
3976 outModes = this.options.move.outModes,
3977 fixHorizontal = outMode => {
3978 fixOutMode({
3979 outMode,
3980 checkModes: ["bounce", "bounce-horizontal"],
3981 coord: pos.x,
3982 maxCoord: container.canvas.size.width,
3983 setCb: value => pos.x += value,
3984 radius
3985 });
3986 },
3987 fixVertical = outMode => {
3988 fixOutMode({
3989 outMode,
3990 checkModes: ["bounce", "bounce-vertical"],
3991 coord: pos.y,
3992 maxCoord: container.canvas.size.height,
3993 setCb: value => pos.y += value,
3994 radius
3995 });
3996 };
3997 fixHorizontal((_a = outModes.left) !== null && _a !== void 0 ? _a : outModes.default);
3998 fixHorizontal((_b = outModes.right) !== null && _b !== void 0 ? _b : outModes.default);
3999 fixVertical((_c = outModes.top) !== null && _c !== void 0 ? _c : outModes.default);
4000 fixVertical((_d = outModes.bottom) !== null && _d !== void 0 ? _d : outModes.default);
4001 if (this._checkOverlap(pos, tryCount)) {
4002 return this._calcPosition(container, undefined, zIndex, tryCount + 1);
4003 }
4004 return pos;
4005 }
4006 _calculateVelocity() {
4007 const baseVelocity = getParticleBaseVelocity(this.direction),
4008 res = baseVelocity.copy(),
4009 moveOptions = this.options.move;
4010 if (moveOptions.direction === "inside" || moveOptions.direction === "outside") {
4011 return res;
4012 }
4013 const rad = Math.PI / 180 * getRangeValue(moveOptions.angle.value),
4014 radOffset = Math.PI / 180 * getRangeValue(moveOptions.angle.offset),
4015 range = {
4016 left: radOffset - rad / 2,
4017 right: radOffset + rad / 2
4018 };
4019 if (!moveOptions.straight) {
4020 res.angle += randomInRange(setRangeValue(range.left, range.right));
4021 }
4022 if (moveOptions.random && typeof moveOptions.speed === "number") {
4023 res.length *= getRandom();
4024 }
4025 return res;
4026 }
4027 _checkOverlap(pos, tryCount = 0) {
4028 const collisionsOptions = this.options.collisions,
4029 radius = this.getRadius();
4030 if (!collisionsOptions.enable) {
4031 return false;
4032 }
4033 const overlapOptions = collisionsOptions.overlap;
4034 if (overlapOptions.enable) {
4035 return false;
4036 }
4037 const retries = overlapOptions.retries;
4038 if (retries >= 0 && tryCount > retries) {
4039 throw new Error("Particle is overlapping and can't be placed");
4040 }
4041 let overlaps = false;
4042 for (const particle of this.container.particles.array) {
4043 if (getDistance(pos, particle.position) < radius + particle.getRadius()) {
4044 overlaps = true;
4045 break;
4046 }
4047 }
4048 return overlaps;
4049 }
4050 _getRollColor(color) {
4051 var _a;
4052 if (!color || !this.roll || !this.backColor && !this.roll.alter) {
4053 return color;
4054 }
4055 const backFactor = this.roll.horizontal && this.roll.vertical ? 2 : 1,
4056 backSum = this.roll.horizontal ? Math.PI / 2 : 0,
4057 rolled = Math.floor((((_a = this.roll.angle) !== null && _a !== void 0 ? _a : 0) + backSum) / (Math.PI / backFactor)) % 2;
4058 if (!rolled) {
4059 return color;
4060 }
4061 if (this.backColor) {
4062 return this.backColor;
4063 }
4064 if (this.roll.alter) {
4065 return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
4066 }
4067 return color;
4068 }
4069 _loadShapeData(shapeOptions, reduceDuplicates) {
4070 const shapeData = shapeOptions.options[this.shape];
4071 if (shapeData) {
4072 return deepExtend({}, itemFromSingleOrMultiple(shapeData, this.id, reduceDuplicates));
4073 }
4074 }
4075}
4076;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Point.js
4077class Point {
4078 constructor(position, particle) {
4079 this.position = position;
4080 this.particle = particle;
4081 }
4082}
4083;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Range.js
4084class Range {
4085 constructor(x, y) {
4086 this.position = {
4087 x: x,
4088 y: y
4089 };
4090 }
4091}
4092;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Circle.js
4093
4094
4095class Circle extends Range {
4096 constructor(x, y, radius) {
4097 super(x, y);
4098 this.radius = radius;
4099 }
4100 contains(point) {
4101 return getDistance(point, this.position) <= this.radius;
4102 }
4103 intersects(range) {
4104 const rect = range,
4105 circle = range,
4106 pos1 = this.position,
4107 pos2 = range.position,
4108 distPos = {
4109 x: Math.abs(pos2.x - pos1.x),
4110 y: Math.abs(pos2.y - pos1.y)
4111 },
4112 r = this.radius;
4113 if (circle.radius !== undefined) {
4114 const rSum = r + circle.radius,
4115 dist = Math.sqrt(distPos.x ** 2 + distPos.y ** 2);
4116 return rSum > dist;
4117 } else if (rect.size !== undefined) {
4118 const w = rect.size.width,
4119 h = rect.size.height,
4120 edges = Math.pow(distPos.x - w, 2) + Math.pow(distPos.y - h, 2);
4121 return edges <= r ** 2 || distPos.x <= r + w && distPos.y <= r + h || distPos.x <= w || distPos.y <= h;
4122 }
4123 return false;
4124 }
4125}
4126;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Rectangle.js
4127
4128
4129class Rectangle extends Range {
4130 constructor(x, y, width, height) {
4131 super(x, y);
4132 this.size = {
4133 height: height,
4134 width: width
4135 };
4136 }
4137 contains(point) {
4138 const w = this.size.width,
4139 h = this.size.height,
4140 pos = this.position;
4141 return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
4142 }
4143 intersects(range) {
4144 if (range instanceof Circle) {
4145 range.intersects(this);
4146 }
4147 const w = this.size.width,
4148 h = this.size.height,
4149 pos1 = this.position,
4150 pos2 = range.position,
4151 size2 = range instanceof Rectangle ? range.size : {
4152 width: 0,
4153 height: 0
4154 },
4155 w2 = size2.width,
4156 h2 = size2.height;
4157 return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
4158 }
4159}
4160;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/QuadTree.js
4161
4162
4163
4164class QuadTree {
4165 constructor(rectangle, capacity) {
4166 this.rectangle = rectangle;
4167 this.capacity = capacity;
4168 this._points = [];
4169 this._divided = false;
4170 }
4171 insert(point) {
4172 var _a, _b, _c, _d, _e;
4173 if (!this.rectangle.contains(point.position)) {
4174 return false;
4175 }
4176 if (this._points.length < this.capacity) {
4177 this._points.push(point);
4178 return true;
4179 }
4180 if (!this._divided) {
4181 this.subdivide();
4182 }
4183 return (_e = ((_a = this._NE) === null || _a === void 0 ? void 0 : _a.insert(point)) || ((_b = this._NW) === null || _b === void 0 ? void 0 : _b.insert(point)) || ((_c = this._SE) === null || _c === void 0 ? void 0 : _c.insert(point)) || ((_d = this._SW) === null || _d === void 0 ? void 0 : _d.insert(point))) !== null && _e !== void 0 ? _e : false;
4184 }
4185 query(range, check, found) {
4186 var _a, _b, _c, _d;
4187 const res = found !== null && found !== void 0 ? found : [];
4188 if (!range.intersects(this.rectangle)) {
4189 return [];
4190 }
4191 for (const p of this._points) {
4192 if (!range.contains(p.position) && getDistance(range.position, p.position) > p.particle.getRadius() && (!check || check(p.particle))) {
4193 continue;
4194 }
4195 res.push(p.particle);
4196 }
4197 if (this._divided) {
4198 (_a = this._NE) === null || _a === void 0 ? void 0 : _a.query(range, check, res);
4199 (_b = this._NW) === null || _b === void 0 ? void 0 : _b.query(range, check, res);
4200 (_c = this._SE) === null || _c === void 0 ? void 0 : _c.query(range, check, res);
4201 (_d = this._SW) === null || _d === void 0 ? void 0 : _d.query(range, check, res);
4202 }
4203 return res;
4204 }
4205 queryCircle(position, radius, check) {
4206 return this.query(new Circle(position.x, position.y, radius), check);
4207 }
4208 queryRectangle(position, size, check) {
4209 return this.query(new Rectangle(position.x, position.y, size.width, size.height), check);
4210 }
4211 subdivide() {
4212 const x = this.rectangle.position.x,
4213 y = this.rectangle.position.y,
4214 w = this.rectangle.size.width,
4215 h = this.rectangle.size.height,
4216 capacity = this.capacity;
4217 this._NE = new QuadTree(new Rectangle(x, y, w / 2, h / 2), capacity);
4218 this._NW = new QuadTree(new Rectangle(x + w / 2, y, w / 2, h / 2), capacity);
4219 this._SE = new QuadTree(new Rectangle(x, y + h / 2, w / 2, h / 2), capacity);
4220 this._SW = new QuadTree(new Rectangle(x + w / 2, y + h / 2, w / 2, h / 2), capacity);
4221 this._divided = true;
4222 }
4223}
4224;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Particles.js
4225
4226
4227
4228
4229
4230
4231class Particles {
4232 constructor(engine, container) {
4233 this.container = container;
4234 this._engine = engine;
4235 this.nextId = 0;
4236 this.array = [];
4237 this.zArray = [];
4238 this.pool = [];
4239 this.limit = 0;
4240 this.needsSort = false;
4241 this.lastZIndex = 0;
4242 this.interactionManager = new InteractionManager(this._engine, container);
4243 const canvasSize = this.container.canvas.size;
4244 this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
4245 this.movers = this._engine.plugins.getMovers(container, true);
4246 this.updaters = this._engine.plugins.getUpdaters(container, true);
4247 }
4248 get count() {
4249 return this.array.length;
4250 }
4251 addManualParticles() {
4252 const container = this.container,
4253 options = container.actualOptions;
4254 for (const particle of options.manualParticles) {
4255 this.addParticle(calcPositionFromSize({
4256 size: container.canvas.size,
4257 position: particle.position
4258 }), particle.options);
4259 }
4260 }
4261 addParticle(position, overrideOptions, group, initializer) {
4262 const container = this.container,
4263 options = container.actualOptions,
4264 limit = options.particles.number.limit;
4265 if (limit > 0) {
4266 const countToRemove = this.count + 1 - limit;
4267 if (countToRemove > 0) {
4268 this.removeQuantity(countToRemove);
4269 }
4270 }
4271 return this._pushParticle(position, overrideOptions, group, initializer);
4272 }
4273 clear() {
4274 this.array = [];
4275 this.zArray = [];
4276 }
4277 destroy() {
4278 this.array = [];
4279 this.zArray = [];
4280 this.movers = [];
4281 this.updaters = [];
4282 }
4283 async draw(delta) {
4284 const container = this.container,
4285 canvasSize = this.container.canvas.size;
4286 this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
4287 container.canvas.clear();
4288 await this.update(delta);
4289 if (this.needsSort) {
4290 this.zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
4291 this.lastZIndex = this.zArray[this.zArray.length - 1].position.z;
4292 this.needsSort = false;
4293 }
4294 for (const [, plugin] of container.plugins) {
4295 container.canvas.drawPlugin(plugin, delta);
4296 }
4297 for (const p of this.zArray) {
4298 p.draw(delta);
4299 }
4300 }
4301 handleClickMode(mode) {
4302 this.interactionManager.handleClickMode(mode);
4303 }
4304 init() {
4305 var _a;
4306 const container = this.container,
4307 options = container.actualOptions;
4308 this.lastZIndex = 0;
4309 this.needsSort = false;
4310 let handled = false;
4311 this.updaters = this._engine.plugins.getUpdaters(container, true);
4312 this.interactionManager.init();
4313 for (const [, plugin] of container.plugins) {
4314 if (plugin.particlesInitialization !== undefined) {
4315 handled = plugin.particlesInitialization();
4316 }
4317 if (handled) {
4318 break;
4319 }
4320 }
4321 this.interactionManager.init();
4322 for (const [, pathGenerator] of container.pathGenerators) {
4323 pathGenerator.init(container);
4324 }
4325 this.addManualParticles();
4326 if (!handled) {
4327 for (const group in options.particles.groups) {
4328 const groupOptions = options.particles.groups[group];
4329 for (let i = this.count, j = 0; j < ((_a = groupOptions.number) === null || _a === void 0 ? void 0 : _a.value) && i < options.particles.number.value; i++, j++) {
4330 this.addParticle(undefined, groupOptions, group);
4331 }
4332 }
4333 for (let i = this.count; i < options.particles.number.value; i++) {
4334 this.addParticle();
4335 }
4336 }
4337 }
4338 push(nb, mouse, overrideOptions, group) {
4339 this.pushing = true;
4340 for (let i = 0; i < nb; i++) {
4341 this.addParticle(mouse === null || mouse === void 0 ? void 0 : mouse.position, overrideOptions, group);
4342 }
4343 this.pushing = false;
4344 }
4345 async redraw() {
4346 this.clear();
4347 this.init();
4348 await this.draw({
4349 value: 0,
4350 factor: 0
4351 });
4352 }
4353 remove(particle, group, override) {
4354 this.removeAt(this.array.indexOf(particle), undefined, group, override);
4355 }
4356 removeAt(index, quantity = 1, group, override) {
4357 if (index < 0 || index > this.count) {
4358 return;
4359 }
4360 let deleted = 0;
4361 for (let i = index; deleted < quantity && i < this.count; i++) {
4362 const particle = this.array[i];
4363 if (!particle || particle.group !== group) {
4364 continue;
4365 }
4366 particle.destroy(override);
4367 this.array.splice(i--, 1);
4368 const zIdx = this.zArray.indexOf(particle);
4369 this.zArray.splice(zIdx, 1);
4370 this.pool.push(particle);
4371 deleted++;
4372 this._engine.dispatchEvent("particleRemoved", {
4373 container: this.container,
4374 data: {
4375 particle
4376 }
4377 });
4378 }
4379 }
4380 removeQuantity(quantity, group) {
4381 this.removeAt(0, quantity, group);
4382 }
4383 setDensity() {
4384 const options = this.container.actualOptions;
4385 for (const group in options.particles.groups) {
4386 this._applyDensity(options.particles.groups[group], 0, group);
4387 }
4388 this._applyDensity(options.particles, options.manualParticles.length);
4389 }
4390 async update(delta) {
4391 var _a, _b;
4392 const container = this.container,
4393 particlesToDelete = [];
4394 for (const [, pathGenerator] of container.pathGenerators) {
4395 pathGenerator.update();
4396 }
4397 for (const [, plugin] of container.plugins) {
4398 (_a = plugin.update) === null || _a === void 0 ? void 0 : _a.call(plugin, delta);
4399 }
4400 for (const particle of this.array) {
4401 const resizeFactor = container.canvas.resizeFactor;
4402 if (resizeFactor && !particle.ignoresResizeRatio) {
4403 particle.position.x *= resizeFactor.width;
4404 particle.position.y *= resizeFactor.height;
4405 particle.initialPosition.x *= resizeFactor.width;
4406 particle.initialPosition.y *= resizeFactor.height;
4407 }
4408 particle.ignoresResizeRatio = false;
4409 await this.interactionManager.reset(particle);
4410 for (const [, plugin] of this.container.plugins) {
4411 if (particle.destroyed) {
4412 break;
4413 }
4414 (_b = plugin.particleUpdate) === null || _b === void 0 ? void 0 : _b.call(plugin, particle, delta);
4415 }
4416 for (const mover of this.movers) {
4417 if (mover.isEnabled(particle)) {
4418 mover.move(particle, delta);
4419 }
4420 }
4421 if (particle.destroyed) {
4422 particlesToDelete.push(particle);
4423 continue;
4424 }
4425 this.quadTree.insert(new Point(particle.getPosition(), particle));
4426 }
4427 for (const particle of particlesToDelete) {
4428 this.remove(particle);
4429 }
4430 await this.interactionManager.externalInteract(delta);
4431 for (const particle of this.array) {
4432 for (const updater of this.updaters) {
4433 updater.update(particle, delta);
4434 }
4435 if (!particle.destroyed && !particle.spawning) {
4436 await this.interactionManager.particlesInteract(particle, delta);
4437 }
4438 }
4439 delete container.canvas.resizeFactor;
4440 }
4441 _applyDensity(options, manualCount, group) {
4442 var _a;
4443 if (!((_a = options.number.density) === null || _a === void 0 ? void 0 : _a.enable)) {
4444 return;
4445 }
4446 const numberOptions = options.number,
4447 densityFactor = this._initDensityFactor(numberOptions.density),
4448 optParticlesNumber = numberOptions.value,
4449 optParticlesLimit = numberOptions.limit > 0 ? numberOptions.limit : optParticlesNumber,
4450 particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + manualCount,
4451 particlesCount = Math.min(this.count, this.array.filter(t => t.group === group).length);
4452 this.limit = numberOptions.limit * densityFactor;
4453 if (particlesCount < particlesNumber) {
4454 this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
4455 } else if (particlesCount > particlesNumber) {
4456 this.removeQuantity(particlesCount - particlesNumber, group);
4457 }
4458 }
4459 _initDensityFactor(densityOptions) {
4460 const container = this.container;
4461 if (!container.canvas.element || !densityOptions.enable) {
4462 return 1;
4463 }
4464 const canvas = container.canvas.element,
4465 pxRatio = container.retina.pixelRatio;
4466 return canvas.width * canvas.height / (densityOptions.factor * pxRatio ** 2 * densityOptions.area);
4467 }
4468 _pushParticle(position, overrideOptions, group, initializer) {
4469 try {
4470 let particle = this.pool.pop();
4471 if (particle) {
4472 particle.init(this.nextId, position, overrideOptions, group);
4473 } else {
4474 particle = new Particle(this._engine, this.nextId, this.container, position, overrideOptions, group);
4475 }
4476 let canAdd = true;
4477 if (initializer) {
4478 canAdd = initializer(particle);
4479 }
4480 if (!canAdd) {
4481 return;
4482 }
4483 this.array.push(particle);
4484 this.zArray.push(particle);
4485 this.nextId++;
4486 this._engine.dispatchEvent("particleAdded", {
4487 container: this.container,
4488 data: {
4489 particle
4490 }
4491 });
4492 return particle;
4493 } catch (e) {
4494 console.warn(`error adding particle: ${e}`);
4495 return;
4496 }
4497 }
4498}
4499;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Retina.js
4500
4501
4502class Retina {
4503 constructor(container) {
4504 this.container = container;
4505 }
4506 init() {
4507 const container = this.container,
4508 options = container.actualOptions;
4509 this.pixelRatio = !options.detectRetina || isSsr() ? 1 : window.devicePixelRatio;
4510 this.reduceFactor = 1;
4511 const ratio = this.pixelRatio;
4512 if (container.canvas.element) {
4513 const element = container.canvas.element;
4514 container.canvas.size.width = element.offsetWidth * ratio;
4515 container.canvas.size.height = element.offsetHeight * ratio;
4516 }
4517 const particles = options.particles;
4518 this.attractDistance = getRangeValue(particles.move.attract.distance) * ratio;
4519 this.sizeAnimationSpeed = getRangeValue(particles.size.animation.speed) * ratio;
4520 this.maxSpeed = getRangeValue(particles.move.gravity.maxSpeed) * ratio;
4521 }
4522 initParticle(particle) {
4523 const options = particle.options,
4524 ratio = this.pixelRatio,
4525 moveDistance = options.move.distance,
4526 props = particle.retina;
4527 props.attractDistance = getRangeValue(options.move.attract.distance) * ratio;
4528 props.moveDrift = getRangeValue(options.move.drift) * ratio;
4529 props.moveSpeed = getRangeValue(options.move.speed) * ratio;
4530 props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
4531 const maxDistance = props.maxDistance;
4532 maxDistance.horizontal = moveDistance.horizontal !== undefined ? moveDistance.horizontal * ratio : undefined;
4533 maxDistance.vertical = moveDistance.vertical !== undefined ? moveDistance.vertical * ratio : undefined;
4534 props.maxSpeed = getRangeValue(options.move.gravity.maxSpeed) * ratio;
4535 }
4536}
4537;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Container.js
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547function guardCheck(container) {
4548 return container && !container.destroyed;
4549}
4550function loadContainerOptions(engine, container, ...sourceOptionsArr) {
4551 const options = new Options(engine, container);
4552 loadOptions(options, ...sourceOptionsArr);
4553 return options;
4554}
4555const defaultPathGeneratorKey = "default",
4556 defaultPathGenerator = {
4557 generate: p => {
4558 const v = p.velocity.copy();
4559 v.angle += v.length * Math.PI / 180;
4560 return v;
4561 },
4562 init: () => {},
4563 update: () => {},
4564 reset: () => {}
4565 };
4566class Container {
4567 constructor(engine, id, sourceOptions) {
4568 this.id = id;
4569 this._engine = engine;
4570 this.fpsLimit = 120;
4571 this.smooth = false;
4572 this._delay = 0;
4573 this.duration = 0;
4574 this.lifeTime = 0;
4575 this._firstStart = true;
4576 this.started = false;
4577 this.destroyed = false;
4578 this._paused = true;
4579 this.lastFrameTime = 0;
4580 this.zLayers = 100;
4581 this.pageHidden = false;
4582 this._sourceOptions = sourceOptions;
4583 this._initialSourceOptions = sourceOptions;
4584 this.retina = new Retina(this);
4585 this.canvas = new Canvas(this);
4586 this.particles = new Particles(this._engine, this);
4587 this.frameManager = new FrameManager(this);
4588 this.pathGenerators = new Map();
4589 this.interactivity = {
4590 mouse: {
4591 clicking: false,
4592 inside: false
4593 }
4594 };
4595 this.plugins = new Map();
4596 this.drawers = new Map();
4597 this._options = loadContainerOptions(this._engine, this);
4598 this.actualOptions = loadContainerOptions(this._engine, this);
4599 this._eventListeners = new EventListeners(this);
4600 if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) {
4601 this._intersectionObserver = new IntersectionObserver(entries => this._intersectionManager(entries));
4602 }
4603 this._engine.dispatchEvent("containerBuilt", {
4604 container: this
4605 });
4606 }
4607 get options() {
4608 return this._options;
4609 }
4610 get sourceOptions() {
4611 return this._sourceOptions;
4612 }
4613 addClickHandler(callback) {
4614 if (!guardCheck(this)) {
4615 return;
4616 }
4617 const el = this.interactivity.element;
4618 if (!el) {
4619 return;
4620 }
4621 const clickOrTouchHandler = (e, pos, radius) => {
4622 if (!guardCheck(this)) {
4623 return;
4624 }
4625 const pxRatio = this.retina.pixelRatio,
4626 posRetina = {
4627 x: pos.x * pxRatio,
4628 y: pos.y * pxRatio
4629 },
4630 particles = this.particles.quadTree.queryCircle(posRetina, radius * pxRatio);
4631 callback(e, particles);
4632 };
4633 const clickHandler = e => {
4634 if (!guardCheck(this)) {
4635 return;
4636 }
4637 const mouseEvent = e,
4638 pos = {
4639 x: mouseEvent.offsetX || mouseEvent.clientX,
4640 y: mouseEvent.offsetY || mouseEvent.clientY
4641 };
4642 clickOrTouchHandler(e, pos, 1);
4643 };
4644 const touchStartHandler = () => {
4645 if (!guardCheck(this)) {
4646 return;
4647 }
4648 touched = true;
4649 touchMoved = false;
4650 };
4651 const touchMoveHandler = () => {
4652 if (!guardCheck(this)) {
4653 return;
4654 }
4655 touchMoved = true;
4656 };
4657 const touchEndHandler = e => {
4658 if (!guardCheck(this)) {
4659 return;
4660 }
4661 if (touched && !touchMoved) {
4662 const touchEvent = e;
4663 let lastTouch = touchEvent.touches[touchEvent.touches.length - 1];
4664 if (!lastTouch) {
4665 lastTouch = touchEvent.changedTouches[touchEvent.changedTouches.length - 1];
4666 if (!lastTouch) {
4667 return;
4668 }
4669 }
4670 const element = this.canvas.element,
4671 canvasRect = element ? element.getBoundingClientRect() : undefined,
4672 pos = {
4673 x: lastTouch.clientX - (canvasRect ? canvasRect.left : 0),
4674 y: lastTouch.clientY - (canvasRect ? canvasRect.top : 0)
4675 };
4676 clickOrTouchHandler(e, pos, Math.max(lastTouch.radiusX, lastTouch.radiusY));
4677 }
4678 touched = false;
4679 touchMoved = false;
4680 };
4681 const touchCancelHandler = () => {
4682 if (!guardCheck(this)) {
4683 return;
4684 }
4685 touched = false;
4686 touchMoved = false;
4687 };
4688 let touched = false,
4689 touchMoved = false;
4690 el.addEventListener("click", clickHandler);
4691 el.addEventListener("touchstart", touchStartHandler);
4692 el.addEventListener("touchmove", touchMoveHandler);
4693 el.addEventListener("touchend", touchEndHandler);
4694 el.addEventListener("touchcancel", touchCancelHandler);
4695 }
4696 addPath(key, generator, override = false) {
4697 if (!guardCheck(this) || !override && this.pathGenerators.has(key)) {
4698 return false;
4699 }
4700 this.pathGenerators.set(key, generator !== null && generator !== void 0 ? generator : defaultPathGenerator);
4701 return true;
4702 }
4703 destroy() {
4704 if (!guardCheck(this)) {
4705 return;
4706 }
4707 this.stop();
4708 this.particles.destroy();
4709 this.canvas.destroy();
4710 for (const [, drawer] of this.drawers) {
4711 if (drawer.destroy) {
4712 drawer.destroy(this);
4713 }
4714 }
4715 for (const key of this.drawers.keys()) {
4716 this.drawers.delete(key);
4717 }
4718 this._engine.plugins.destroy(this);
4719 this.destroyed = true;
4720 const mainArr = this._engine.dom(),
4721 idx = mainArr.findIndex(t => t === this);
4722 if (idx >= 0) {
4723 mainArr.splice(idx, 1);
4724 }
4725 this._engine.dispatchEvent("containerDestroyed", {
4726 container: this
4727 });
4728 }
4729 draw(force) {
4730 if (!guardCheck(this)) {
4731 return;
4732 }
4733 let refreshTime = force;
4734 this._drawAnimationFrame = animate()(async timestamp => {
4735 if (refreshTime) {
4736 this.lastFrameTime = undefined;
4737 refreshTime = false;
4738 }
4739 await this.frameManager.nextFrame(timestamp);
4740 });
4741 }
4742 exportConfiguration() {
4743 return JSON.stringify(this.actualOptions, (key, value) => {
4744 if (key === "_engine" || key === "_container") {
4745 return;
4746 }
4747 return value;
4748 }, 2);
4749 }
4750 exportImage(callback, type, quality) {
4751 const element = this.canvas.element;
4752 if (element) {
4753 element.toBlob(callback, type !== null && type !== void 0 ? type : "image/png", quality);
4754 }
4755 }
4756 exportImg(callback) {
4757 this.exportImage(callback);
4758 }
4759 getAnimationStatus() {
4760 return !this._paused && !this.pageHidden && guardCheck(this);
4761 }
4762 handleClickMode(mode) {
4763 if (!guardCheck(this)) {
4764 return;
4765 }
4766 this.particles.handleClickMode(mode);
4767 for (const [, plugin] of this.plugins) {
4768 if (plugin.handleClickMode) {
4769 plugin.handleClickMode(mode);
4770 }
4771 }
4772 }
4773 async init() {
4774 if (!guardCheck(this)) {
4775 return;
4776 }
4777 const shapes = this._engine.plugins.getSupportedShapes();
4778 for (const type of shapes) {
4779 const drawer = this._engine.plugins.getShapeDrawer(type);
4780 if (drawer) {
4781 this.drawers.set(type, drawer);
4782 }
4783 }
4784 this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
4785 this.actualOptions = loadContainerOptions(this._engine, this, this._options);
4786 const availablePlugins = this._engine.plugins.getAvailablePlugins(this);
4787 for (const [id, plugin] of availablePlugins) {
4788 this.plugins.set(id, plugin);
4789 }
4790 this.retina.init();
4791 await this.canvas.init();
4792 this.updateActualOptions();
4793 this.canvas.initBackground();
4794 this.canvas.resize();
4795 this.zLayers = this.actualOptions.zLayers;
4796 this.duration = getRangeValue(this.actualOptions.duration) * 1000;
4797 this._delay = getRangeValue(this.actualOptions.delay) * 1000;
4798 this.lifeTime = 0;
4799 this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
4800 this.smooth = this.actualOptions.smooth;
4801 for (const [, drawer] of this.drawers) {
4802 if (drawer.init) {
4803 await drawer.init(this);
4804 }
4805 }
4806 for (const [, plugin] of this.plugins) {
4807 if (plugin.init) {
4808 await plugin.init();
4809 }
4810 }
4811 this._engine.dispatchEvent("containerInit", {
4812 container: this
4813 });
4814 this.particles.init();
4815 this.particles.setDensity();
4816 for (const [, plugin] of this.plugins) {
4817 if (plugin.particlesSetup) {
4818 plugin.particlesSetup();
4819 }
4820 }
4821 this._engine.dispatchEvent("particlesSetup", {
4822 container: this
4823 });
4824 }
4825 async loadTheme(name) {
4826 if (!guardCheck(this)) {
4827 return;
4828 }
4829 this._currentTheme = name;
4830 await this.refresh();
4831 }
4832 pause() {
4833 if (!guardCheck(this)) {
4834 return;
4835 }
4836 if (this._drawAnimationFrame !== undefined) {
4837 cancelAnimation()(this._drawAnimationFrame);
4838 delete this._drawAnimationFrame;
4839 }
4840 if (this._paused) {
4841 return;
4842 }
4843 for (const [, plugin] of this.plugins) {
4844 if (plugin.pause) {
4845 plugin.pause();
4846 }
4847 }
4848 if (!this.pageHidden) {
4849 this._paused = true;
4850 }
4851 this._engine.dispatchEvent("containerPaused", {
4852 container: this
4853 });
4854 }
4855 play(force) {
4856 if (!guardCheck(this)) {
4857 return;
4858 }
4859 const needsUpdate = this._paused || force;
4860 if (this._firstStart && !this.actualOptions.autoPlay) {
4861 this._firstStart = false;
4862 return;
4863 }
4864 if (this._paused) {
4865 this._paused = false;
4866 }
4867 if (needsUpdate) {
4868 for (const [, plugin] of this.plugins) {
4869 if (plugin.play) {
4870 plugin.play();
4871 }
4872 }
4873 }
4874 this._engine.dispatchEvent("containerPlay", {
4875 container: this
4876 });
4877 this.draw(needsUpdate || false);
4878 }
4879 async refresh() {
4880 if (!guardCheck(this)) {
4881 return;
4882 }
4883 this.stop();
4884 return this.start();
4885 }
4886 async reset() {
4887 if (!guardCheck(this)) {
4888 return;
4889 }
4890 this._options = loadContainerOptions(this._engine, this);
4891 return this.refresh();
4892 }
4893 setNoise(noiseOrGenerator, init, update) {
4894 if (!guardCheck(this)) {
4895 return;
4896 }
4897 this.setPath(noiseOrGenerator, init, update);
4898 }
4899 setPath(pathOrGenerator, init, update) {
4900 if (!pathOrGenerator || !guardCheck(this)) {
4901 return;
4902 }
4903 const pathGenerator = Object.assign({}, defaultPathGenerator);
4904 if (typeof pathOrGenerator === "function") {
4905 pathGenerator.generate = pathOrGenerator;
4906 if (init) {
4907 pathGenerator.init = init;
4908 }
4909 if (update) {
4910 pathGenerator.update = update;
4911 }
4912 } else {
4913 const oldGenerator = pathGenerator;
4914 pathGenerator.generate = pathOrGenerator.generate || oldGenerator.generate;
4915 pathGenerator.init = pathOrGenerator.init || oldGenerator.init;
4916 pathGenerator.update = pathOrGenerator.update || oldGenerator.update;
4917 }
4918 this.addPath(defaultPathGeneratorKey, pathGenerator, true);
4919 }
4920 async start() {
4921 if (!guardCheck(this) || this.started) {
4922 return;
4923 }
4924 await this.init();
4925 this.started = true;
4926 await new Promise(resolve => {
4927 this._delayTimeout = setTimeout(async () => {
4928 this._eventListeners.addListeners();
4929 if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
4930 this._intersectionObserver.observe(this.interactivity.element);
4931 }
4932 for (const [, plugin] of this.plugins) {
4933 if (plugin.start) {
4934 await plugin.start();
4935 }
4936 }
4937 this._engine.dispatchEvent("containerStarted", {
4938 container: this
4939 });
4940 this.play();
4941 resolve();
4942 }, this._delay);
4943 });
4944 }
4945 stop() {
4946 if (!guardCheck(this) || !this.started) {
4947 return;
4948 }
4949 if (this._delayTimeout) {
4950 clearTimeout(this._delayTimeout);
4951 delete this._delayTimeout;
4952 }
4953 this._firstStart = true;
4954 this.started = false;
4955 this._eventListeners.removeListeners();
4956 this.pause();
4957 this.particles.clear();
4958 this.canvas.stop();
4959 if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
4960 this._intersectionObserver.unobserve(this.interactivity.element);
4961 }
4962 for (const [, plugin] of this.plugins) {
4963 if (plugin.stop) {
4964 plugin.stop();
4965 }
4966 }
4967 for (const key of this.plugins.keys()) {
4968 this.plugins.delete(key);
4969 }
4970 this._sourceOptions = this._options;
4971 this._engine.dispatchEvent("containerStopped", {
4972 container: this
4973 });
4974 }
4975 updateActualOptions() {
4976 this.actualOptions.responsive = [];
4977 const newMaxWidth = this.actualOptions.setResponsive(this.canvas.size.width, this.retina.pixelRatio, this._options);
4978 this.actualOptions.setTheme(this._currentTheme);
4979 if (this.responsiveMaxWidth === newMaxWidth) {
4980 return false;
4981 }
4982 this.responsiveMaxWidth = newMaxWidth;
4983 return true;
4984 }
4985 _intersectionManager(entries) {
4986 if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
4987 return;
4988 }
4989 for (const entry of entries) {
4990 if (entry.target !== this.interactivity.element) {
4991 continue;
4992 }
4993 (entry.isIntersecting ? this.play : this.pause)();
4994 }
4995 }
4996}
4997;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Loader.js
4998
4999
5000
5001
5002async function getDataFromUrl(jsonUrl, index) {
5003 const url = itemFromSingleOrMultiple(jsonUrl, index);
5004 if (!url) {
5005 return;
5006 }
5007 const response = await fetch(url);
5008 if (response.ok) {
5009 return response.json();
5010 }
5011 console.error(`tsParticles - Error ${response.status} while retrieving config file`);
5012}
5013class Loader {
5014 constructor(engine) {
5015 this._engine = engine;
5016 }
5017 load(tagId, options, index) {
5018 const params = {
5019 index,
5020 remote: false
5021 };
5022 if (typeof tagId === "string") {
5023 params.tagId = tagId;
5024 } else {
5025 params.options = tagId;
5026 }
5027 if (typeof options === "number") {
5028 params.index = options;
5029 } else {
5030 params.options = options !== null && options !== void 0 ? options : params.options;
5031 }
5032 return this.loadOptions(params);
5033 }
5034 async loadJSON(tagId, jsonUrl, index) {
5035 let url, id;
5036 if (typeof jsonUrl === "number" || jsonUrl === undefined) {
5037 url = tagId;
5038 } else {
5039 id = tagId;
5040 url = jsonUrl;
5041 }
5042 return this.loadRemoteOptions({
5043 tagId: id,
5044 url,
5045 index,
5046 remote: true
5047 });
5048 }
5049 async loadOptions(params) {
5050 var _a, _b, _c;
5051 const tagId = (_a = params.tagId) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(getRandom() * 10000)}`,
5052 {
5053 index,
5054 url: jsonUrl,
5055 remote
5056 } = params,
5057 options = remote ? await getDataFromUrl(jsonUrl, index) : params.options;
5058 let domContainer = (_b = params.element) !== null && _b !== void 0 ? _b : document.getElementById(tagId);
5059 if (!domContainer) {
5060 domContainer = document.createElement("div");
5061 domContainer.id = tagId;
5062 (_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
5063 }
5064 const currentOptions = itemFromSingleOrMultiple(options, index),
5065 dom = this._engine.dom(),
5066 oldIndex = dom.findIndex(v => v.id === tagId);
5067 if (oldIndex >= 0) {
5068 const old = this._engine.domItem(oldIndex);
5069 if (old && !old.destroyed) {
5070 old.destroy();
5071 dom.splice(oldIndex, 1);
5072 }
5073 }
5074 let canvasEl;
5075 if (domContainer.tagName.toLowerCase() === "canvas") {
5076 canvasEl = domContainer;
5077 canvasEl.dataset[generatedAttribute] = "false";
5078 } else {
5079 const existingCanvases = domContainer.getElementsByTagName("canvas");
5080 if (existingCanvases.length) {
5081 canvasEl = existingCanvases[0];
5082 canvasEl.dataset[generatedAttribute] = "false";
5083 } else {
5084 canvasEl = document.createElement("canvas");
5085 canvasEl.dataset[generatedAttribute] = "true";
5086 domContainer.appendChild(canvasEl);
5087 }
5088 }
5089 if (!canvasEl.style.width) {
5090 canvasEl.style.width = "100%";
5091 }
5092 if (!canvasEl.style.height) {
5093 canvasEl.style.height = "100%";
5094 }
5095 const newItem = new Container(this._engine, tagId, currentOptions);
5096 if (oldIndex >= 0) {
5097 dom.splice(oldIndex, 0, newItem);
5098 } else {
5099 dom.push(newItem);
5100 }
5101 newItem.canvas.loadCanvas(canvasEl);
5102 await newItem.start();
5103 return newItem;
5104 }
5105 async loadRemoteOptions(params) {
5106 return this.loadOptions(params);
5107 }
5108 async set(id, domContainer, options, index) {
5109 const params = {
5110 index,
5111 remote: false
5112 };
5113 if (typeof id === "string") {
5114 params.tagId = id;
5115 } else {
5116 params.element = id;
5117 }
5118 if (domContainer instanceof HTMLElement) {
5119 params.element = domContainer;
5120 } else {
5121 params.options = domContainer;
5122 }
5123 if (typeof options === "number") {
5124 params.index = options;
5125 } else {
5126 params.options = options !== null && options !== void 0 ? options : params.options;
5127 }
5128 return this.loadOptions(params);
5129 }
5130 async setJSON(id, domContainer, jsonUrl, index) {
5131 let url, newId, newIndex, element;
5132 if (id instanceof HTMLElement) {
5133 element = id;
5134 url = domContainer;
5135 newIndex = jsonUrl;
5136 } else {
5137 newId = id;
5138 element = domContainer;
5139 url = jsonUrl;
5140 newIndex = index;
5141 }
5142 return this.loadRemoteOptions({
5143 tagId: newId,
5144 url,
5145 index: newIndex,
5146 element,
5147 remote: true
5148 });
5149 }
5150}
5151;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Plugins.js
5152
5153function getItemsFromInitializer(container, map, initializers, force = false) {
5154 let res = map.get(container);
5155 if (!res || force) {
5156 res = [...initializers.values()].map(t => t(container));
5157 map.set(container, res);
5158 }
5159 return res;
5160}
5161class Plugins {
5162 constructor(engine) {
5163 this._engine = engine;
5164 this.plugins = [];
5165 this._initializers = {
5166 interactors: new Map(),
5167 movers: new Map(),
5168 updaters: new Map()
5169 };
5170 this.interactors = new Map();
5171 this.movers = new Map();
5172 this.updaters = new Map();
5173 this.presets = new Map();
5174 this.drawers = new Map();
5175 this.pathGenerators = new Map();
5176 }
5177 addInteractor(name, initInteractor) {
5178 this._initializers.interactors.set(name, initInteractor);
5179 }
5180 addParticleMover(name, initMover) {
5181 this._initializers.movers.set(name, initMover);
5182 }
5183 addParticleUpdater(name, initUpdater) {
5184 this._initializers.updaters.set(name, initUpdater);
5185 }
5186 addPathGenerator(type, pathGenerator) {
5187 if (!this.getPathGenerator(type)) {
5188 this.pathGenerators.set(type, pathGenerator);
5189 }
5190 }
5191 addPlugin(plugin) {
5192 if (!this.getPlugin(plugin.id)) {
5193 this.plugins.push(plugin);
5194 }
5195 }
5196 addPreset(presetKey, options, override = false) {
5197 if (override || !this.getPreset(presetKey)) {
5198 this.presets.set(presetKey, options);
5199 }
5200 }
5201 addShapeDrawer(types, drawer) {
5202 executeOnSingleOrMultiple(types, type => {
5203 if (!this.getShapeDrawer(type)) {
5204 this.drawers.set(type, drawer);
5205 }
5206 });
5207 }
5208 destroy(container) {
5209 this.updaters.delete(container);
5210 this.movers.delete(container);
5211 this.interactors.delete(container);
5212 }
5213 getAvailablePlugins(container) {
5214 const res = new Map();
5215 for (const plugin of this.plugins) {
5216 if (!plugin.needsPlugin(container.actualOptions)) {
5217 continue;
5218 }
5219 res.set(plugin.id, plugin.getPlugin(container));
5220 }
5221 return res;
5222 }
5223 getInteractors(container, force = false) {
5224 return getItemsFromInitializer(container, this.interactors, this._initializers.interactors, force);
5225 }
5226 getMovers(container, force = false) {
5227 return getItemsFromInitializer(container, this.movers, this._initializers.movers, force);
5228 }
5229 getPathGenerator(type) {
5230 return this.pathGenerators.get(type);
5231 }
5232 getPlugin(plugin) {
5233 return this.plugins.find(t => t.id === plugin);
5234 }
5235 getPreset(preset) {
5236 return this.presets.get(preset);
5237 }
5238 getShapeDrawer(type) {
5239 return this.drawers.get(type);
5240 }
5241 getSupportedShapes() {
5242 return this.drawers.keys();
5243 }
5244 getUpdaters(container, force = false) {
5245 return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);
5246 }
5247 loadOptions(options, sourceOptions) {
5248 for (const plugin of this.plugins) {
5249 plugin.loadOptions(options, sourceOptions);
5250 }
5251 }
5252 loadParticlesOptions(container, options, ...sourceOptions) {
5253 const updaters = this.updaters.get(container);
5254 if (!updaters) {
5255 return;
5256 }
5257 for (const updater of updaters) {
5258 if (updater.loadOptions) {
5259 updater.loadOptions(options, ...sourceOptions);
5260 }
5261 }
5262 }
5263}
5264;// CONCATENATED MODULE: ../../engine/dist/esm/engine.js
5265
5266
5267
5268class Engine {
5269 constructor() {
5270 this._domArray = [];
5271 this._eventDispatcher = new EventDispatcher();
5272 this._initialized = false;
5273 this._loader = new Loader(this);
5274 this.plugins = new Plugins(this);
5275 }
5276 get version() {
5277 return "2.9.3";
5278 }
5279 addEventListener(type, listener) {
5280 this._eventDispatcher.addEventListener(type, listener);
5281 }
5282 async addInteractor(name, interactorInitializer) {
5283 this.plugins.addInteractor(name, interactorInitializer);
5284 await this.refresh();
5285 }
5286 async addMover(name, moverInitializer) {
5287 this.plugins.addParticleMover(name, moverInitializer);
5288 await this.refresh();
5289 }
5290 async addParticleUpdater(name, updaterInitializer) {
5291 this.plugins.addParticleUpdater(name, updaterInitializer);
5292 await this.refresh();
5293 }
5294 async addPathGenerator(name, generator) {
5295 this.plugins.addPathGenerator(name, generator);
5296 await this.refresh();
5297 }
5298 async addPlugin(plugin) {
5299 this.plugins.addPlugin(plugin);
5300 await this.refresh();
5301 }
5302 async addPreset(preset, options, override = false) {
5303 this.plugins.addPreset(preset, options, override);
5304 await this.refresh();
5305 }
5306 async addShape(shape, drawer, init, afterEffect, destroy) {
5307 let customDrawer;
5308 if (typeof drawer === "function") {
5309 customDrawer = {
5310 afterEffect: afterEffect,
5311 destroy: destroy,
5312 draw: drawer,
5313 init: init
5314 };
5315 } else {
5316 customDrawer = drawer;
5317 }
5318 this.plugins.addShapeDrawer(shape, customDrawer);
5319 await this.refresh();
5320 }
5321 dispatchEvent(type, args) {
5322 this._eventDispatcher.dispatchEvent(type, args);
5323 }
5324 dom() {
5325 return this._domArray;
5326 }
5327 domItem(index) {
5328 const dom = this.dom(),
5329 item = dom[index];
5330 if (item && !item.destroyed) {
5331 return item;
5332 }
5333 dom.splice(index, 1);
5334 }
5335 init() {
5336 if (!this._initialized) {
5337 this._initialized = true;
5338 }
5339 }
5340 async load(tagId, options) {
5341 return this._loader.load(tagId, options);
5342 }
5343 async loadFromArray(tagId, options, index) {
5344 return this._loader.load(tagId, options, index);
5345 }
5346 async loadJSON(tagId, pathConfigJson, index) {
5347 return this._loader.loadJSON(tagId, pathConfigJson, index);
5348 }
5349 async refresh() {
5350 for (const instance of this.dom()) {
5351 await instance.refresh();
5352 }
5353 }
5354 removeEventListener(type, listener) {
5355 this._eventDispatcher.removeEventListener(type, listener);
5356 }
5357 async set(id, element, options) {
5358 return this._loader.set(id, element, options);
5359 }
5360 async setJSON(id, element, pathConfigJson, index) {
5361 return this._loader.setJSON(id, element, pathConfigJson, index);
5362 }
5363 setOnClickHandler(callback) {
5364 const dom = this.dom();
5365 if (!dom.length) {
5366 throw new Error("Can only set click handlers after calling tsParticles.load() or tsParticles.loadJSON()");
5367 }
5368 for (const domItem of dom) {
5369 domItem.addClickHandler(callback);
5370 }
5371 }
5372}
5373;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/HslColorManager.js
5374
5375
5376class HslColorManager {
5377 constructor() {
5378 this.key = "hsl";
5379 this.stringPrefix = "hsl";
5380 }
5381 handleColor(color) {
5382 var _a;
5383 const colorValue = color.value,
5384 hslColor = (_a = colorValue.hsl) !== null && _a !== void 0 ? _a : color.value;
5385 if (hslColor.h !== undefined && hslColor.s !== undefined && hslColor.l !== undefined) {
5386 return hslToRgb(hslColor);
5387 }
5388 }
5389 handleRangeColor(color) {
5390 var _a;
5391 const colorValue = color.value,
5392 hslColor = (_a = colorValue.hsl) !== null && _a !== void 0 ? _a : color.value;
5393 if (hslColor.h !== undefined && hslColor.l !== undefined) {
5394 return hslToRgb({
5395 h: getRangeValue(hslColor.h),
5396 l: getRangeValue(hslColor.l),
5397 s: getRangeValue(hslColor.s)
5398 });
5399 }
5400 }
5401 parseString(input) {
5402 if (!input.startsWith("hsl")) {
5403 return;
5404 }
5405 const regex = /hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.%]+)\s*)?\)/i,
5406 result = regex.exec(input);
5407 return result ? hslaToRgba({
5408 a: result.length > 4 ? parseAlpha(result[5]) : 1,
5409 h: parseInt(result[1], 10),
5410 l: parseInt(result[3], 10),
5411 s: parseInt(result[2], 10)
5412 }) : undefined;
5413 }
5414}
5415;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/RgbColorManager.js
5416
5417class RgbColorManager {
5418 constructor() {
5419 this.key = "rgb";
5420 this.stringPrefix = "rgb";
5421 }
5422 handleColor(color) {
5423 var _a;
5424 const colorValue = color.value,
5425 rgbColor = (_a = colorValue.rgb) !== null && _a !== void 0 ? _a : color.value;
5426 if (rgbColor.r !== undefined) {
5427 return rgbColor;
5428 }
5429 }
5430 handleRangeColor(color) {
5431 var _a;
5432 const colorValue = color.value,
5433 rgbColor = (_a = colorValue.rgb) !== null && _a !== void 0 ? _a : color.value;
5434 if (rgbColor.r !== undefined) {
5435 return {
5436 r: getRangeValue(rgbColor.r),
5437 g: getRangeValue(rgbColor.g),
5438 b: getRangeValue(rgbColor.b)
5439 };
5440 }
5441 }
5442 parseString(input) {
5443 if (!input.startsWith(this.stringPrefix)) {
5444 return;
5445 }
5446 const regex = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([\d.%]+)\s*)?\)/i,
5447 result = regex.exec(input);
5448 return result ? {
5449 a: result.length > 4 ? parseAlpha(result[5]) : 1,
5450 b: parseInt(result[3], 10),
5451 g: parseInt(result[2], 10),
5452 r: parseInt(result[1], 10)
5453 } : undefined;
5454 }
5455}
5456;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/ExternalInteractorBase.js
5457class ExternalInteractorBase {
5458 constructor(container) {
5459 this.container = container;
5460 this.type = "external";
5461 }
5462}
5463;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/ParticlesInteractorBase.js
5464class ParticlesInteractorBase {
5465 constructor(container) {
5466 this.container = container;
5467 this.type = "particles";
5468 }
5469}
5470;// CONCATENATED MODULE: ../../engine/dist/esm/index.js
5471
5472
5473
5474
5475const rgbColorManager = new RgbColorManager(),
5476 hslColorManager = new HslColorManager();
5477addColorManager(rgbColorManager);
5478addColorManager(hslColorManager);
5479const tsParticles = new Engine();
5480tsParticles.init();
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664;// CONCATENATED MODULE: ./dist/browser/ConfettiOptions.js
5665
5666class ConfettiOptions {
5667 constructor() {
5668 this.angle = 90;
5669 this.count = 50;
5670 this.spread = 45;
5671 this.startVelocity = 45;
5672 this.decay = 0.9;
5673 this.gravity = 1;
5674 this.drift = 0;
5675 this.ticks = 200;
5676 this.position = {
5677 x: 50,
5678 y: 50
5679 };
5680 this.colors = ["#26ccff", "#a25afd", "#ff5e7e", "#88ff5a", "#fcff42", "#ffa62d", "#ff36ff"];
5681 this.shapes = ["square", "circle"];
5682 this.scalar = 1;
5683 this.zIndex = 100;
5684 this.disableForReducedMotion = true;
5685 this.shapeOptions = {};
5686 }
5687 get origin() {
5688 return {
5689 x: this.position.x / 100,
5690 y: this.position.y / 100
5691 };
5692 }
5693 set origin(value) {
5694 this.position.x = value.x * 100;
5695 this.position.y = value.y * 100;
5696 }
5697 get particleCount() {
5698 return this.count;
5699 }
5700 set particleCount(value) {
5701 this.count = value;
5702 }
5703 load(data) {
5704 var _a, _b;
5705 if (!data) {
5706 return;
5707 }
5708 if (data.angle !== undefined) {
5709 this.angle = data.angle;
5710 }
5711 const count = (_a = data.count) !== null && _a !== void 0 ? _a : data.particleCount;
5712 if (count !== undefined) {
5713 this.count = count;
5714 }
5715 if (data.spread !== undefined) {
5716 this.spread = data.spread;
5717 }
5718 if (data.startVelocity !== undefined) {
5719 this.startVelocity = data.startVelocity;
5720 }
5721 if (data.decay !== undefined) {
5722 this.decay = data.decay;
5723 }
5724 if (data.gravity !== undefined) {
5725 this.gravity = data.gravity;
5726 }
5727 if (data.drift !== undefined) {
5728 this.drift = data.drift;
5729 }
5730 if (data.ticks !== undefined) {
5731 this.ticks = data.ticks;
5732 }
5733 const origin = data.origin;
5734 if (origin && !data.position) {
5735 data.position = {
5736 x: origin.x !== undefined ? origin.x * 100 : undefined,
5737 y: origin.y !== undefined ? origin.y * 100 : undefined
5738 };
5739 }
5740 const position = data.position;
5741 if (position) {
5742 if (position.x !== undefined) {
5743 this.position.x = position.x;
5744 }
5745 if (position.y !== undefined) {
5746 this.position.y = position.y;
5747 }
5748 }
5749 if (data.colors !== undefined) {
5750 if (data.colors instanceof Array) {
5751 this.colors = [...data.colors];
5752 } else {
5753 this.colors = data.colors;
5754 }
5755 }
5756 const options = data.shapeOptions;
5757 if (options !== undefined) {
5758 for (const shape in options) {
5759 const item = options[shape];
5760 if (item) {
5761 this.shapeOptions[shape] = deepExtend((_b = this.shapeOptions[shape]) !== null && _b !== void 0 ? _b : {}, item);
5762 }
5763 }
5764 }
5765 if (data.shapes !== undefined) {
5766 if (data.shapes instanceof Array) {
5767 this.shapes = [...data.shapes];
5768 } else {
5769 this.shapes = data.shapes;
5770 }
5771 }
5772 if (data.scalar !== undefined) {
5773 this.scalar = data.scalar;
5774 }
5775 if (data.zIndex !== undefined) {
5776 this.zIndex = data.zIndex;
5777 }
5778 if (data.disableForReducedMotion !== undefined) {
5779 this.disableForReducedMotion = data.disableForReducedMotion;
5780 }
5781 }
5782}
5783;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/Options/Classes/RotateAnimation.js
5784
5785class RotateAnimation {
5786 constructor() {
5787 this.enable = false;
5788 this.speed = 0;
5789 this.decay = 0;
5790 this.sync = false;
5791 }
5792 load(data) {
5793 if (!data) {
5794 return;
5795 }
5796 if (data.enable !== undefined) {
5797 this.enable = data.enable;
5798 }
5799 if (data.speed !== undefined) {
5800 this.speed = setRangeValue(data.speed);
5801 }
5802 if (data.decay !== undefined) {
5803 this.decay = setRangeValue(data.decay);
5804 }
5805 if (data.sync !== undefined) {
5806 this.sync = data.sync;
5807 }
5808 }
5809}
5810;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/Options/Classes/Rotate.js
5811
5812
5813class Rotate extends ValueWithRandom {
5814 constructor() {
5815 super();
5816 this.animation = new RotateAnimation();
5817 this.direction = "clockwise";
5818 this.path = false;
5819 this.value = 0;
5820 }
5821 load(data) {
5822 if (!data) {
5823 return;
5824 }
5825 super.load(data);
5826 if (data.direction !== undefined) {
5827 this.direction = data.direction;
5828 }
5829 this.animation.load(data.animation);
5830 if (data.path !== undefined) {
5831 this.path = data.path;
5832 }
5833 }
5834}
5835;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/RotateUpdater.js
5836
5837
5838function updateAngle(particle, delta) {
5839 var _a, _b;
5840 const rotate = particle.rotate,
5841 rotateOptions = particle.options.rotate;
5842 if (!rotate || !rotateOptions) {
5843 return;
5844 }
5845 const rotateAnimation = rotateOptions.animation,
5846 speed = ((_a = rotate.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor,
5847 max = 2 * Math.PI,
5848 decay = (_b = rotate.decay) !== null && _b !== void 0 ? _b : 1;
5849 if (!rotateAnimation.enable) {
5850 return;
5851 }
5852 switch (rotate.status) {
5853 case "increasing":
5854 rotate.value += speed;
5855 if (rotate.value > max) {
5856 rotate.value -= max;
5857 }
5858 break;
5859 case "decreasing":
5860 default:
5861 rotate.value -= speed;
5862 if (rotate.value < 0) {
5863 rotate.value += max;
5864 }
5865 break;
5866 }
5867 if (rotate.velocity && decay !== 1) {
5868 rotate.velocity *= decay;
5869 }
5870}
5871class RotateUpdater {
5872 constructor(container) {
5873 this.container = container;
5874 }
5875 init(particle) {
5876 const rotateOptions = particle.options.rotate;
5877 if (!rotateOptions) {
5878 return;
5879 }
5880 particle.rotate = {
5881 enable: rotateOptions.animation.enable,
5882 value: getRangeValue(rotateOptions.value) * Math.PI / 180
5883 };
5884 particle.pathRotation = rotateOptions.path;
5885 let rotateDirection = rotateOptions.direction;
5886 if (rotateDirection === "random") {
5887 const index = Math.floor(getRandom() * 2);
5888 rotateDirection = index > 0 ? "counter-clockwise" : "clockwise";
5889 }
5890 switch (rotateDirection) {
5891 case "counter-clockwise":
5892 case "counterClockwise":
5893 particle.rotate.status = "decreasing";
5894 break;
5895 case "clockwise":
5896 particle.rotate.status = "increasing";
5897 break;
5898 }
5899 const rotateAnimation = rotateOptions.animation;
5900 if (rotateAnimation.enable) {
5901 particle.rotate.decay = 1 - getRangeValue(rotateAnimation.decay);
5902 particle.rotate.velocity = getRangeValue(rotateAnimation.speed) / 360 * this.container.retina.reduceFactor;
5903 if (!rotateAnimation.sync) {
5904 particle.rotate.velocity *= getRandom();
5905 }
5906 }
5907 particle.rotation = particle.rotate.value;
5908 }
5909 isEnabled(particle) {
5910 const rotate = particle.options.rotate;
5911 if (!rotate) {
5912 return false;
5913 }
5914 return !particle.destroyed && !particle.spawning && rotate.animation.enable && !rotate.path;
5915 }
5916 loadOptions(options, ...sources) {
5917 if (!options.rotate) {
5918 options.rotate = new Rotate();
5919 }
5920 for (const source of sources) {
5921 options.rotate.load(source === null || source === void 0 ? void 0 : source.rotate);
5922 }
5923 }
5924 update(particle, delta) {
5925 var _a, _b;
5926 if (!this.isEnabled(particle)) {
5927 return;
5928 }
5929 updateAngle(particle, delta);
5930 particle.rotation = (_b = (_a = particle.rotate) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
5931 }
5932}
5933;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/index.js
5934
5935async function loadAngleUpdater(engine) {
5936 await engine.addParticleUpdater("rotate", container => new RotateUpdater(container));
5937}
5938;// CONCATENATED MODULE: ../../move/base/dist/esm/Utils.js
5939
5940function applyDistance(particle) {
5941 const initialPosition = particle.initialPosition,
5942 {
5943 dx,
5944 dy
5945 } = getDistances(initialPosition, particle.position),
5946 dxFixed = Math.abs(dx),
5947 dyFixed = Math.abs(dy),
5948 hDistance = particle.retina.maxDistance.horizontal,
5949 vDistance = particle.retina.maxDistance.vertical;
5950 if (!hDistance && !vDistance) {
5951 return;
5952 }
5953 if ((hDistance && dxFixed >= hDistance || vDistance && dyFixed >= vDistance) && !particle.misplaced) {
5954 particle.misplaced = !!hDistance && dxFixed > hDistance || !!vDistance && dyFixed > vDistance;
5955 if (hDistance) {
5956 particle.velocity.x = particle.velocity.y / 2 - particle.velocity.x;
5957 }
5958 if (vDistance) {
5959 particle.velocity.y = particle.velocity.x / 2 - particle.velocity.y;
5960 }
5961 } else if ((!hDistance || dxFixed < hDistance) && (!vDistance || dyFixed < vDistance) && particle.misplaced) {
5962 particle.misplaced = false;
5963 } else if (particle.misplaced) {
5964 const pos = particle.position,
5965 vel = particle.velocity;
5966 if (hDistance && (pos.x < initialPosition.x && vel.x < 0 || pos.x > initialPosition.x && vel.x > 0)) {
5967 vel.x *= -getRandom();
5968 }
5969 if (vDistance && (pos.y < initialPosition.y && vel.y < 0 || pos.y > initialPosition.y && vel.y > 0)) {
5970 vel.y *= -getRandom();
5971 }
5972 }
5973}
5974function spin(particle, moveSpeed) {
5975 const container = particle.container;
5976 if (!particle.spin) {
5977 return;
5978 }
5979 const updateFunc = {
5980 x: particle.spin.direction === "clockwise" ? Math.cos : Math.sin,
5981 y: particle.spin.direction === "clockwise" ? Math.sin : Math.cos
5982 };
5983 particle.position.x = particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle);
5984 particle.position.y = particle.spin.center.y + particle.spin.radius * updateFunc.y(particle.spin.angle);
5985 particle.spin.radius += particle.spin.acceleration;
5986 const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height);
5987 if (particle.spin.radius > maxCanvasSize / 2) {
5988 particle.spin.radius = maxCanvasSize / 2;
5989 particle.spin.acceleration *= -1;
5990 } else if (particle.spin.radius < 0) {
5991 particle.spin.radius = 0;
5992 particle.spin.acceleration *= -1;
5993 }
5994 particle.spin.angle += moveSpeed / 100 * (1 - particle.spin.radius / maxCanvasSize);
5995}
5996function applyPath(particle, delta) {
5997 var _a;
5998 const particlesOptions = particle.options,
5999 pathOptions = particlesOptions.move.path,
6000 pathEnabled = pathOptions.enable;
6001 if (!pathEnabled) {
6002 return;
6003 }
6004 if (particle.lastPathTime <= particle.pathDelay) {
6005 particle.lastPathTime += delta.value;
6006 return;
6007 }
6008 const path = (_a = particle.pathGenerator) === null || _a === void 0 ? void 0 : _a.generate(particle);
6009 if (path) {
6010 particle.velocity.addTo(path);
6011 }
6012 if (pathOptions.clamp) {
6013 particle.velocity.x = clamp(particle.velocity.x, -1, 1);
6014 particle.velocity.y = clamp(particle.velocity.y, -1, 1);
6015 }
6016 particle.lastPathTime -= particle.pathDelay;
6017}
6018function getProximitySpeedFactor(particle) {
6019 return particle.slow.inRange ? particle.slow.factor : 1;
6020}
6021;// CONCATENATED MODULE: ../../move/base/dist/esm/BaseMover.js
6022
6023
6024class BaseMover {
6025 init(particle) {
6026 var _a;
6027 const container = particle.container,
6028 options = particle.options,
6029 gravityOptions = options.move.gravity,
6030 spinOptions = options.move.spin;
6031 particle.gravity = {
6032 enable: gravityOptions.enable,
6033 acceleration: getRangeValue(gravityOptions.acceleration),
6034 inverse: gravityOptions.inverse
6035 };
6036 if (spinOptions.enable) {
6037 const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : {
6038 x: 50,
6039 y: 50
6040 },
6041 spinCenter = {
6042 x: spinPos.x / 100 * container.canvas.size.width,
6043 y: spinPos.y / 100 * container.canvas.size.height
6044 },
6045 pos = particle.getPosition(),
6046 distance = getDistance(pos, spinCenter),
6047 spinAcceleration = getRangeValue(spinOptions.acceleration);
6048 particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio;
6049 particle.spin = {
6050 center: spinCenter,
6051 direction: particle.velocity.x >= 0 ? "clockwise" : "counter-clockwise",
6052 angle: particle.velocity.angle,
6053 radius: distance,
6054 acceleration: particle.retina.spinAcceleration
6055 };
6056 }
6057 }
6058 isEnabled(particle) {
6059 return !particle.destroyed && particle.options.move.enable;
6060 }
6061 move(particle, delta) {
6062 var _a, _b, _c;
6063 var _d, _e;
6064 const particleOptions = particle.options,
6065 moveOptions = particleOptions.move;
6066 if (!moveOptions.enable) {
6067 return;
6068 }
6069 const container = particle.container,
6070 slowFactor = getProximitySpeedFactor(particle),
6071 baseSpeed = ((_a = (_d = particle.retina).moveSpeed) !== null && _a !== void 0 ? _a : _d.moveSpeed = getRangeValue(moveOptions.speed) * container.retina.pixelRatio) * container.retina.reduceFactor,
6072 moveDrift = (_b = (_e = particle.retina).moveDrift) !== null && _b !== void 0 ? _b : _e.moveDrift = getRangeValue(particle.options.move.drift) * container.retina.pixelRatio,
6073 maxSize = getRangeMax(particleOptions.size.value) * container.retina.pixelRatio,
6074 sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : 1,
6075 speedFactor = sizeFactor * slowFactor * (delta.factor || 1),
6076 diffFactor = 2,
6077 moveSpeed = baseSpeed * speedFactor / diffFactor;
6078 if (moveOptions.spin.enable) {
6079 spin(particle, moveSpeed);
6080 } else {
6081 applyPath(particle, delta);
6082 const gravityOptions = particle.gravity,
6083 gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1;
6084 if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) {
6085 particle.velocity.y += gravityFactor * (gravityOptions.acceleration * delta.factor) / (60 * moveSpeed);
6086 }
6087 if (moveDrift && moveSpeed) {
6088 particle.velocity.x += moveDrift * delta.factor / (60 * moveSpeed);
6089 }
6090 const decay = particle.moveDecay;
6091 if (decay != 1) {
6092 particle.velocity.multTo(decay);
6093 }
6094 const velocity = particle.velocity.mult(moveSpeed),
6095 maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed;
6096 if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && maxSpeed > 0 && (!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed || gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed)) {
6097 velocity.y = gravityFactor * maxSpeed;
6098 if (moveSpeed) {
6099 particle.velocity.y = velocity.y / moveSpeed;
6100 }
6101 }
6102 const zIndexOptions = particle.options.zIndex,
6103 zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate;
6104 if (zVelocityFactor != 1) {
6105 velocity.multTo(zVelocityFactor);
6106 }
6107 particle.position.addTo(velocity);
6108 if (moveOptions.vibrate) {
6109 particle.position.x += Math.sin(particle.position.x * Math.cos(particle.position.y));
6110 particle.position.y += Math.cos(particle.position.y * Math.sin(particle.position.x));
6111 }
6112 }
6113 applyDistance(particle);
6114 }
6115}
6116;// CONCATENATED MODULE: ../../move/base/dist/esm/index.js
6117
6118async function loadBaseMover(engine) {
6119 engine.addMover("base", () => new BaseMover());
6120}
6121;// CONCATENATED MODULE: ../../shapes/cards/dist/esm/Utils.js
6122function drawPath(ctx, radius, path) {
6123 if (!path.segments.length || !path.segments[0].values.length) {
6124 return;
6125 }
6126 ctx.moveTo(path.segments[0].values[0].x * radius, path.segments[0].values[0].y * radius);
6127 for (let i = 0; i < path.segments.length; i++) {
6128 const segment = path.segments[i];
6129 ctx.bezierCurveTo(segment.values[1].x * radius, segment.values[1].y * radius, segment.values[2].x * radius, segment.values[2].y * radius, segment.values[3].x * radius, segment.values[3].y * radius);
6130 }
6131 for (let i = path.segments.length - 1; i >= 0; i--) {
6132 const segment = path.segments[i];
6133 ctx.bezierCurveTo(-segment.values[2].x * radius, segment.values[2].y * radius, -segment.values[1].x * radius, segment.values[1].y * radius, -segment.values[0].x * radius, segment.values[0].y * radius);
6134 }
6135}
6136const n = 1.0 / 2;
6137const paths = {
6138 heart: {
6139 segments: [{
6140 values: [{
6141 x: 0,
6142 y: n
6143 }, {
6144 x: 0,
6145 y: n
6146 }, {
6147 x: n,
6148 y: 0
6149 }, {
6150 x: n,
6151 y: -n / 2
6152 }]
6153 }, {
6154 values: [{
6155 x: n,
6156 y: -n / 2
6157 }, {
6158 x: n,
6159 y: -n / 2
6160 }, {
6161 x: n,
6162 y: -n
6163 }, {
6164 x: n / 2,
6165 y: -n
6166 }]
6167 }, {
6168 values: [{
6169 x: n / 2,
6170 y: -n
6171 }, {
6172 x: n / 2,
6173 y: -n
6174 }, {
6175 x: 0,
6176 y: -n
6177 }, {
6178 x: 0,
6179 y: -n / 2
6180 }]
6181 }]
6182 },
6183 diamond: {
6184 segments: [{
6185 values: [{
6186 x: 0,
6187 y: n
6188 }, {
6189 x: 0,
6190 y: n
6191 }, {
6192 x: 3 * n / 4,
6193 y: 0
6194 }, {
6195 x: 3 * n / 4,
6196 y: 0
6197 }]
6198 }, {
6199 values: [{
6200 x: 3 * n / 4,
6201 y: 0
6202 }, {
6203 x: 3 * n / 4,
6204 y: 0
6205 }, {
6206 x: 0,
6207 y: -n
6208 }, {
6209 x: 0,
6210 y: -n
6211 }]
6212 }]
6213 },
6214 club: {
6215 segments: [{
6216 values: [{
6217 x: 0,
6218 y: -n
6219 }, {
6220 x: 0,
6221 y: -n
6222 }, {
6223 x: n / 2,
6224 y: -n
6225 }, {
6226 x: n / 2,
6227 y: -n / 2
6228 }]
6229 }, {
6230 values: [{
6231 x: n / 2,
6232 y: -n / 2
6233 }, {
6234 x: n / 2,
6235 y: -n / 2
6236 }, {
6237 x: n,
6238 y: -n / 2
6239 }, {
6240 x: n,
6241 y: 0
6242 }]
6243 }, {
6244 values: [{
6245 x: n,
6246 y: 0
6247 }, {
6248 x: n,
6249 y: 0
6250 }, {
6251 x: n,
6252 y: n / 2
6253 }, {
6254 x: n / 2,
6255 y: n / 2
6256 }]
6257 }, {
6258 values: [{
6259 x: n / 2,
6260 y: n / 2
6261 }, {
6262 x: n / 2,
6263 y: n / 2
6264 }, {
6265 x: n / 8,
6266 y: n / 2
6267 }, {
6268 x: n / 8,
6269 y: n / 8
6270 }]
6271 }, {
6272 values: [{
6273 x: n / 8,
6274 y: n / 8
6275 }, {
6276 x: n / 8,
6277 y: n / 2
6278 }, {
6279 x: n / 2,
6280 y: n
6281 }, {
6282 x: n / 2,
6283 y: n
6284 }]
6285 }, {
6286 values: [{
6287 x: n / 2,
6288 y: n
6289 }, {
6290 x: n / 2,
6291 y: n
6292 }, {
6293 x: 0,
6294 y: n
6295 }, {
6296 x: 0,
6297 y: n
6298 }]
6299 }]
6300 },
6301 spade: {
6302 segments: [{
6303 values: [{
6304 x: 0,
6305 y: -n
6306 }, {
6307 x: 0,
6308 y: -n
6309 }, {
6310 x: n,
6311 y: -n / 2
6312 }, {
6313 x: n,
6314 y: 0
6315 }]
6316 }, {
6317 values: [{
6318 x: n,
6319 y: 0
6320 }, {
6321 x: n,
6322 y: 0
6323 }, {
6324 x: n,
6325 y: n / 2
6326 }, {
6327 x: n / 2,
6328 y: n / 2
6329 }]
6330 }, {
6331 values: [{
6332 x: n / 2,
6333 y: n / 2
6334 }, {
6335 x: n / 2,
6336 y: n / 2
6337 }, {
6338 x: n / 8,
6339 y: n / 2
6340 }, {
6341 x: n / 8,
6342 y: n / 8
6343 }]
6344 }, {
6345 values: [{
6346 x: n / 8,
6347 y: n / 8
6348 }, {
6349 x: n / 8,
6350 y: n / 2
6351 }, {
6352 x: n / 2,
6353 y: n
6354 }, {
6355 x: n / 2,
6356 y: n
6357 }]
6358 }, {
6359 values: [{
6360 x: n / 2,
6361 y: n
6362 }, {
6363 x: n / 2,
6364 y: n
6365 }, {
6366 x: 0,
6367 y: n
6368 }, {
6369 x: 0,
6370 y: n
6371 }]
6372 }]
6373 }
6374};
6375;// CONCATENATED MODULE: ../../shapes/cards/dist/esm/CardsSuitsDrawers.js
6376
6377class SpadeDrawer {
6378 draw(context, particle, radius) {
6379 drawPath(context, radius, paths.spade);
6380 }
6381}
6382class HeartDrawer {
6383 draw(context, particle, radius) {
6384 drawPath(context, radius, paths.heart);
6385 }
6386}
6387class DiamondDrawer {
6388 draw(context, particle, radius) {
6389 drawPath(context, radius, paths.diamond);
6390 }
6391}
6392class ClubDrawer {
6393 draw(context, particle, radius) {
6394 drawPath(context, radius, paths.club);
6395 }
6396}
6397;// CONCATENATED MODULE: ../../shapes/cards/dist/esm/index.js
6398
6399async function loadCardsShape(engine) {
6400 await engine.addShape(["spade", "spades"], new SpadeDrawer());
6401 await engine.addShape(["heart", "hearts"], new HeartDrawer());
6402 await engine.addShape(["diamond", "diamonds"], new DiamondDrawer());
6403 await engine.addShape(["club", "clubs"], new ClubDrawer());
6404}
6405;// CONCATENATED MODULE: ../../shapes/circle/dist/esm/CircleDrawer.js
6406class CircleDrawer {
6407 draw(context, particle, radius) {
6408 if (!particle.circleRange) {
6409 particle.circleRange = {
6410 min: 0,
6411 max: Math.PI * 2
6412 };
6413 }
6414 const circleRange = particle.circleRange;
6415 context.arc(0, 0, radius, circleRange.min, circleRange.max, false);
6416 }
6417 getSidesCount() {
6418 return 12;
6419 }
6420 particleInit(container, particle) {
6421 var _a;
6422 const shapeData = particle.shapeData,
6423 angle = (_a = shapeData === null || shapeData === void 0 ? void 0 : shapeData.angle) !== null && _a !== void 0 ? _a : {
6424 max: 360,
6425 min: 0
6426 };
6427 particle.circleRange = typeof angle !== "object" ? {
6428 min: 0,
6429 max: angle * Math.PI / 180
6430 } : {
6431 min: angle.min * Math.PI / 180,
6432 max: angle.max * Math.PI / 180
6433 };
6434 }
6435}
6436;// CONCATENATED MODULE: ../../shapes/circle/dist/esm/index.js
6437
6438async function loadCircleShape(engine) {
6439 await engine.addShape("circle", new CircleDrawer());
6440}
6441;// CONCATENATED MODULE: ../../updaters/color/dist/esm/ColorUpdater.js
6442
6443function updateColorValue(delta, value, valueAnimation, max, decrease) {
6444 var _a, _b;
6445 const colorValue = value;
6446 if (!colorValue || !valueAnimation.enable || colorValue.loops !== undefined && colorValue.maxLoops !== undefined && colorValue.maxLoops > 0 && colorValue.loops >= colorValue.maxLoops) {
6447 return;
6448 }
6449 const offset = randomInRange(valueAnimation.offset),
6450 velocity = ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6,
6451 decay = (_b = value.decay) !== null && _b !== void 0 ? _b : 1;
6452 if (!decrease || colorValue.status === "increasing") {
6453 colorValue.value += velocity;
6454 if (colorValue.value > max) {
6455 if (!colorValue.loops) {
6456 colorValue.loops = 0;
6457 }
6458 colorValue.loops++;
6459 if (decrease) {
6460 colorValue.status = "decreasing";
6461 colorValue.value -= colorValue.value % max;
6462 }
6463 }
6464 } else {
6465 colorValue.value -= velocity;
6466 if (colorValue.value < 0) {
6467 if (!colorValue.loops) {
6468 colorValue.loops = 0;
6469 }
6470 colorValue.loops++;
6471 colorValue.status = "increasing";
6472 colorValue.value += colorValue.value;
6473 }
6474 }
6475 if (colorValue.velocity && decay !== 1) {
6476 colorValue.velocity *= decay;
6477 }
6478 if (colorValue.value > max) {
6479 colorValue.value %= max;
6480 }
6481}
6482function updateColor(particle, delta) {
6483 var _a, _b, _c;
6484 const animationOptions = particle.options.color.animation;
6485 const h = (_a = particle.color) === null || _a === void 0 ? void 0 : _a.h,
6486 s = (_b = particle.color) === null || _b === void 0 ? void 0 : _b.s,
6487 l = (_c = particle.color) === null || _c === void 0 ? void 0 : _c.l;
6488 if (h) {
6489 updateColorValue(delta, h, animationOptions.h, 360, false);
6490 }
6491 if (s) {
6492 updateColorValue(delta, s, animationOptions.s, 100, true);
6493 }
6494 if (l) {
6495 updateColorValue(delta, l, animationOptions.l, 100, true);
6496 }
6497}
6498class ColorUpdater {
6499 constructor(container) {
6500 this.container = container;
6501 }
6502 init(particle) {
6503 const hslColor = rangeColorToHsl(particle.options.color, particle.id, particle.options.reduceDuplicates);
6504 if (hslColor) {
6505 particle.color = getHslAnimationFromHsl(hslColor, particle.options.color.animation, this.container.retina.reduceFactor);
6506 }
6507 }
6508 isEnabled(particle) {
6509 var _a, _b, _c;
6510 const animationOptions = particle.options.color.animation;
6511 return !particle.destroyed && !particle.spawning && (((_a = particle.color) === null || _a === void 0 ? void 0 : _a.h.value) !== undefined && animationOptions.h.enable || ((_b = particle.color) === null || _b === void 0 ? void 0 : _b.s.value) !== undefined && animationOptions.s.enable || ((_c = particle.color) === null || _c === void 0 ? void 0 : _c.l.value) !== undefined && animationOptions.l.enable);
6512 }
6513 update(particle, delta) {
6514 updateColor(particle, delta);
6515 }
6516}
6517;// CONCATENATED MODULE: ../../updaters/color/dist/esm/index.js
6518
6519async function loadColorUpdater(engine) {
6520 await engine.addParticleUpdater("color", container => new ColorUpdater(container));
6521}
6522;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/Shapes/Circle/CircleShape.js
6523
6524class CircleShape {
6525 randomPosition(position, size, fill) {
6526 const generateTheta = (x, y) => {
6527 const u = getRandom() / 4.0,
6528 theta = Math.atan(y / x * Math.tan(2 * Math.PI * u)),
6529 v = getRandom();
6530 if (v < 0.25) {
6531 return theta;
6532 } else if (v < 0.5) {
6533 return Math.PI - theta;
6534 } else if (v < 0.75) {
6535 return Math.PI + theta;
6536 } else {
6537 return -theta;
6538 }
6539 },
6540 radius = (x, y, theta) => x * y / Math.sqrt((y * Math.cos(theta)) ** 2 + (x * Math.sin(theta)) ** 2),
6541 [a, b] = [size.width / 2, size.height / 2],
6542 randomTheta = generateTheta(a, b),
6543 maxRadius = radius(a, b, randomTheta),
6544 randomRadius = fill ? maxRadius * Math.sqrt(getRandom()) : maxRadius;
6545 return {
6546 x: position.x + randomRadius * Math.cos(randomTheta),
6547 y: position.y + randomRadius * Math.sin(randomTheta)
6548 };
6549 }
6550}
6551;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/Options/Classes/EmitterLife.js
6552class EmitterLife {
6553 constructor() {
6554 this.wait = false;
6555 }
6556 load(data) {
6557 if (!data) {
6558 return;
6559 }
6560 if (data.count !== undefined) {
6561 this.count = data.count;
6562 }
6563 if (data.delay !== undefined) {
6564 this.delay = data.delay;
6565 }
6566 if (data.duration !== undefined) {
6567 this.duration = data.duration;
6568 }
6569 if (data.wait !== undefined) {
6570 this.wait = data.wait;
6571 }
6572 }
6573}
6574;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/Options/Classes/EmitterRate.js
6575
6576class EmitterRate {
6577 constructor() {
6578 this.quantity = 1;
6579 this.delay = 0.1;
6580 }
6581 load(data) {
6582 if (data === undefined) {
6583 return;
6584 }
6585 if (data.quantity !== undefined) {
6586 this.quantity = setRangeValue(data.quantity);
6587 }
6588 if (data.delay !== undefined) {
6589 this.delay = setRangeValue(data.delay);
6590 }
6591 }
6592}
6593;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/Options/Classes/EmitterSize.js
6594class EmitterSize {
6595 constructor() {
6596 this.mode = "percent";
6597 this.height = 0;
6598 this.width = 0;
6599 }
6600 load(data) {
6601 if (data === undefined) {
6602 return;
6603 }
6604 if (data.mode !== undefined) {
6605 this.mode = data.mode;
6606 }
6607 if (data.height !== undefined) {
6608 this.height = data.height;
6609 }
6610 if (data.width !== undefined) {
6611 this.width = data.width;
6612 }
6613 }
6614}
6615;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/Options/Classes/Emitter.js
6616
6617
6618
6619
6620class Emitter {
6621 constructor() {
6622 this.autoPlay = true;
6623 this.fill = true;
6624 this.life = new EmitterLife();
6625 this.rate = new EmitterRate();
6626 this.shape = "square";
6627 this.startCount = 0;
6628 }
6629 load(data) {
6630 if (!data) {
6631 return;
6632 }
6633 if (data.autoPlay !== undefined) {
6634 this.autoPlay = data.autoPlay;
6635 }
6636 if (data.size !== undefined) {
6637 if (!this.size) {
6638 this.size = new EmitterSize();
6639 }
6640 this.size.load(data.size);
6641 }
6642 if (data.direction !== undefined) {
6643 this.direction = data.direction;
6644 }
6645 this.domId = data.domId;
6646 if (data.fill !== undefined) {
6647 this.fill = data.fill;
6648 }
6649 this.life.load(data.life);
6650 this.name = data.name;
6651 this.particles = executeOnSingleOrMultiple(data.particles, particles => {
6652 return deepExtend({}, particles);
6653 });
6654 this.rate.load(data.rate);
6655 if (data.shape !== undefined) {
6656 this.shape = data.shape;
6657 }
6658 if (data.position !== undefined) {
6659 this.position = {};
6660 if (data.position.x !== undefined) {
6661 this.position.x = setRangeValue(data.position.x);
6662 }
6663 if (data.position.y !== undefined) {
6664 this.position.y = setRangeValue(data.position.y);
6665 }
6666 }
6667 if (data.spawnColor !== undefined) {
6668 if (this.spawnColor === undefined) {
6669 this.spawnColor = new AnimatableColor();
6670 }
6671 this.spawnColor.load(data.spawnColor);
6672 }
6673 if (data.startCount !== undefined) {
6674 this.startCount = data.startCount;
6675 }
6676 }
6677}
6678;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/EmitterInstance.js
6679
6680
6681
6682class EmitterInstance {
6683 constructor(engine, emitters, container, options, position) {
6684 var _a, _b, _c, _d, _e, _f, _g;
6685 var _h;
6686 this.emitters = emitters;
6687 this.container = container;
6688 this._engine = engine;
6689 this._currentDuration = 0;
6690 this._currentEmitDelay = 0;
6691 this._currentSpawnDelay = 0;
6692 this._initialPosition = position;
6693 if (options instanceof Emitter) {
6694 this.options = options;
6695 } else {
6696 this.options = new Emitter();
6697 this.options.load(options);
6698 }
6699 this._spawnDelay = ((_a = this.options.life.delay) !== null && _a !== void 0 ? _a : 0) * 1000 / this.container.retina.reduceFactor;
6700 this.position = (_b = this._initialPosition) !== null && _b !== void 0 ? _b : this.calcPosition();
6701 this.name = this.options.name;
6702 this._shape = (_c = this._engine.emitterShapeManager) === null || _c === void 0 ? void 0 : _c.getShape(this.options.shape);
6703 this.fill = this.options.fill;
6704 this._firstSpawn = !this.options.life.wait;
6705 this._startParticlesAdded = false;
6706 let particlesOptions = deepExtend({}, this.options.particles);
6707 particlesOptions !== null && particlesOptions !== void 0 ? particlesOptions : particlesOptions = {};
6708 (_d = particlesOptions.move) !== null && _d !== void 0 ? _d : particlesOptions.move = {};
6709 (_e = (_h = particlesOptions.move).direction) !== null && _e !== void 0 ? _e : _h.direction = this.options.direction;
6710 if (this.options.spawnColor) {
6711 this.spawnColor = rangeColorToHsl(this.options.spawnColor);
6712 }
6713 this._paused = !this.options.autoPlay;
6714 this._particlesOptions = particlesOptions;
6715 this.size = (_f = this.options.size) !== null && _f !== void 0 ? _f : (() => {
6716 const size = new EmitterSize();
6717 size.load({
6718 height: 0,
6719 mode: "percent",
6720 width: 0
6721 });
6722 return size;
6723 })();
6724 this._lifeCount = (_g = this.options.life.count) !== null && _g !== void 0 ? _g : -1;
6725 this._immortal = this._lifeCount <= 0;
6726 this._engine.dispatchEvent("emitterCreated", {
6727 container,
6728 data: {
6729 emitter: this
6730 }
6731 });
6732 this.play();
6733 }
6734 externalPause() {
6735 this._paused = true;
6736 this.pause();
6737 }
6738 externalPlay() {
6739 this._paused = false;
6740 this.play();
6741 }
6742 getPosition() {
6743 if (this.options.domId) {
6744 const container = this.container,
6745 element = document.getElementById(this.options.domId);
6746 if (element) {
6747 const elRect = element.getBoundingClientRect();
6748 return {
6749 x: (elRect.x + elRect.width / 2) * container.retina.pixelRatio,
6750 y: (elRect.y + elRect.height / 2) * container.retina.pixelRatio
6751 };
6752 }
6753 }
6754 return this.position;
6755 }
6756 getSize() {
6757 const container = this.container;
6758 if (this.options.domId) {
6759 const element = document.getElementById(this.options.domId);
6760 if (element) {
6761 const elRect = element.getBoundingClientRect();
6762 return {
6763 width: elRect.width * container.retina.pixelRatio,
6764 height: elRect.height * container.retina.pixelRatio
6765 };
6766 }
6767 }
6768 return {
6769 width: this.size.mode === "percent" ? container.canvas.size.width * this.size.width / 100 : this.size.width,
6770 height: this.size.mode === "percent" ? container.canvas.size.height * this.size.height / 100 : this.size.height
6771 };
6772 }
6773 pause() {
6774 if (this._paused) {
6775 return;
6776 }
6777 delete this._emitDelay;
6778 }
6779 play() {
6780 var _a;
6781 if (this._paused) {
6782 return;
6783 }
6784 if (!(this.container.retina.reduceFactor && (this._lifeCount > 0 || this._immortal || !this.options.life.count) && (this._firstSpawn || this._currentSpawnDelay >= ((_a = this._spawnDelay) !== null && _a !== void 0 ? _a : 0)))) {
6785 return;
6786 }
6787 if (this._emitDelay === undefined) {
6788 const delay = getRangeValue(this.options.rate.delay);
6789 this._emitDelay = 1000 * delay / this.container.retina.reduceFactor;
6790 }
6791 if (this._lifeCount > 0 || this._immortal) {
6792 this.prepareToDie();
6793 }
6794 }
6795 resize() {
6796 const initialPosition = this._initialPosition;
6797 this.position = initialPosition && isPointInside(initialPosition, this.container.canvas.size, Vector.origin) ? initialPosition : this.calcPosition();
6798 }
6799 update(delta) {
6800 var _a, _b, _c;
6801 if (this._paused) {
6802 return;
6803 }
6804 if (this._firstSpawn) {
6805 this._firstSpawn = false;
6806 this._currentSpawnDelay = (_a = this._spawnDelay) !== null && _a !== void 0 ? _a : 0;
6807 this._currentEmitDelay = (_b = this._emitDelay) !== null && _b !== void 0 ? _b : 0;
6808 }
6809 if (!this._startParticlesAdded) {
6810 this._startParticlesAdded = true;
6811 this.emitParticles(this.options.startCount);
6812 }
6813 if (this._duration !== undefined) {
6814 this._currentDuration += delta.value;
6815 if (this._currentDuration >= this._duration) {
6816 this.pause();
6817 if (this._spawnDelay !== undefined) {
6818 delete this._spawnDelay;
6819 }
6820 if (!this._immortal) {
6821 this._lifeCount--;
6822 }
6823 if (this._lifeCount > 0 || this._immortal) {
6824 this.position = this.calcPosition();
6825 this._spawnDelay = ((_c = this.options.life.delay) !== null && _c !== void 0 ? _c : 0) * 1000 / this.container.retina.reduceFactor;
6826 } else {
6827 this.destroy();
6828 }
6829 this._currentDuration -= this._duration;
6830 delete this._duration;
6831 }
6832 }
6833 if (this._spawnDelay !== undefined) {
6834 this._currentSpawnDelay += delta.value;
6835 if (this._currentSpawnDelay >= this._spawnDelay) {
6836 this._engine.dispatchEvent("emitterPlay", {
6837 container: this.container
6838 });
6839 this.play();
6840 this._currentSpawnDelay -= this._currentSpawnDelay;
6841 delete this._spawnDelay;
6842 }
6843 }
6844 if (this._emitDelay !== undefined) {
6845 this._currentEmitDelay += delta.value;
6846 if (this._currentEmitDelay >= this._emitDelay) {
6847 this.emit();
6848 this._currentEmitDelay -= this._emitDelay;
6849 }
6850 }
6851 }
6852 calcPosition() {
6853 return calcPositionOrRandomFromSizeRanged({
6854 size: this.container.canvas.size,
6855 position: this.options.position
6856 });
6857 }
6858 destroy() {
6859 this.emitters.removeEmitter(this);
6860 this._engine.dispatchEvent("emitterDestroyed", {
6861 container: this.container,
6862 data: {
6863 emitter: this
6864 }
6865 });
6866 }
6867 emit() {
6868 if (this._paused) {
6869 return;
6870 }
6871 const quantity = getRangeValue(this.options.rate.quantity);
6872 this.emitParticles(quantity);
6873 }
6874 emitParticles(quantity) {
6875 var _a, _b, _c;
6876 const position = this.getPosition(),
6877 size = this.getSize(),
6878 singleParticlesOptions = itemFromSingleOrMultiple(this._particlesOptions);
6879 for (let i = 0; i < quantity; i++) {
6880 const particlesOptions = deepExtend({}, singleParticlesOptions);
6881 if (this.spawnColor) {
6882 const hslAnimation = (_a = this.options.spawnColor) === null || _a === void 0 ? void 0 : _a.animation;
6883 if (hslAnimation) {
6884 this.spawnColor.h = this.setColorAnimation(hslAnimation.h, this.spawnColor.h, 360);
6885 this.spawnColor.s = this.setColorAnimation(hslAnimation.s, this.spawnColor.s, 100);
6886 this.spawnColor.l = this.setColorAnimation(hslAnimation.l, this.spawnColor.l, 100);
6887 }
6888 if (!particlesOptions.color) {
6889 particlesOptions.color = {
6890 value: this.spawnColor
6891 };
6892 } else {
6893 particlesOptions.color.value = this.spawnColor;
6894 }
6895 }
6896 if (!position) {
6897 return;
6898 }
6899 const pPosition = (_c = (_b = this._shape) === null || _b === void 0 ? void 0 : _b.randomPosition(position, size, this.fill)) !== null && _c !== void 0 ? _c : position;
6900 this.container.particles.addParticle(pPosition, particlesOptions);
6901 }
6902 }
6903 prepareToDie() {
6904 var _a;
6905 if (this._paused) {
6906 return;
6907 }
6908 const duration = (_a = this.options.life) === null || _a === void 0 ? void 0 : _a.duration;
6909 if (this.container.retina.reduceFactor && (this._lifeCount > 0 || this._immortal) && duration !== undefined && duration > 0) {
6910 this._duration = duration * 1000;
6911 }
6912 }
6913 setColorAnimation(animation, initValue, maxValue) {
6914 var _a;
6915 const container = this.container;
6916 if (!animation.enable) {
6917 return initValue;
6918 }
6919 const colorOffset = randomInRange(animation.offset),
6920 delay = getRangeValue(this.options.rate.delay),
6921 emitFactor = 1000 * delay / container.retina.reduceFactor,
6922 colorSpeed = getRangeValue((_a = animation.speed) !== null && _a !== void 0 ? _a : 0);
6923 return (initValue + colorSpeed * container.fpsLimit / emitFactor + colorOffset * 3.6) % maxValue;
6924 }
6925}
6926;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/Emitters.js
6927
6928
6929
6930class Emitters {
6931 constructor(engine, container) {
6932 this.container = container;
6933 this._engine = engine;
6934 this.array = [];
6935 this.emitters = [];
6936 this.interactivityEmitters = {
6937 random: {
6938 count: 1,
6939 enable: false
6940 },
6941 value: []
6942 };
6943 container.getEmitter = idxOrName => idxOrName === undefined || typeof idxOrName === "number" ? this.array[idxOrName || 0] : this.array.find(t => t.name === idxOrName);
6944 container.addEmitter = (options, position) => this.addEmitter(options, position);
6945 container.removeEmitter = idxOrName => {
6946 const emitter = container.getEmitter(idxOrName);
6947 if (emitter) {
6948 this.removeEmitter(emitter);
6949 }
6950 };
6951 container.playEmitter = idxOrName => {
6952 const emitter = container.getEmitter(idxOrName);
6953 if (emitter) {
6954 emitter.externalPlay();
6955 }
6956 };
6957 container.pauseEmitter = idxOrName => {
6958 const emitter = container.getEmitter(idxOrName);
6959 if (emitter) {
6960 emitter.externalPause();
6961 }
6962 };
6963 }
6964 addEmitter(options, position) {
6965 const emitterOptions = new Emitter();
6966 emitterOptions.load(options);
6967 const emitter = new EmitterInstance(this._engine, this, this.container, emitterOptions, position);
6968 this.array.push(emitter);
6969 return emitter;
6970 }
6971 handleClickMode(mode) {
6972 const emitterOptions = this.emitters,
6973 modeEmitters = this.interactivityEmitters;
6974 if (mode !== "emitter") {
6975 return;
6976 }
6977 let emittersModeOptions;
6978 if (modeEmitters && modeEmitters.value instanceof Array) {
6979 if (modeEmitters.value.length > 0 && modeEmitters.random.enable) {
6980 emittersModeOptions = [];
6981 const usedIndexes = [];
6982 for (let i = 0; i < modeEmitters.random.count; i++) {
6983 const idx = arrayRandomIndex(modeEmitters.value);
6984 if (usedIndexes.includes(idx) && usedIndexes.length < modeEmitters.value.length) {
6985 i--;
6986 continue;
6987 }
6988 usedIndexes.push(idx);
6989 emittersModeOptions.push(itemFromArray(modeEmitters.value, idx));
6990 }
6991 } else {
6992 emittersModeOptions = modeEmitters.value;
6993 }
6994 } else {
6995 emittersModeOptions = modeEmitters === null || modeEmitters === void 0 ? void 0 : modeEmitters.value;
6996 }
6997 const emittersOptions = emittersModeOptions !== null && emittersModeOptions !== void 0 ? emittersModeOptions : emitterOptions,
6998 ePosition = this.container.interactivity.mouse.clickPosition;
6999 executeOnSingleOrMultiple(emittersOptions, emitter => {
7000 this.addEmitter(emitter, ePosition);
7001 });
7002 }
7003 async init() {
7004 this.emitters = this.container.actualOptions.emitters;
7005 this.interactivityEmitters = this.container.actualOptions.interactivity.modes.emitters;
7006 if (!this.emitters) {
7007 return;
7008 }
7009 if (this.emitters instanceof Array) {
7010 for (const emitterOptions of this.emitters) {
7011 this.addEmitter(emitterOptions);
7012 }
7013 } else {
7014 this.addEmitter(this.emitters);
7015 }
7016 }
7017 pause() {
7018 for (const emitter of this.array) {
7019 emitter.pause();
7020 }
7021 }
7022 play() {
7023 for (const emitter of this.array) {
7024 emitter.play();
7025 }
7026 }
7027 removeEmitter(emitter) {
7028 const index = this.array.indexOf(emitter);
7029 if (index >= 0) {
7030 this.array.splice(index, 1);
7031 }
7032 }
7033 resize() {
7034 for (const emitter of this.array) {
7035 emitter.resize();
7036 }
7037 }
7038 stop() {
7039 this.array = [];
7040 }
7041 update(delta) {
7042 for (const emitter of this.array) {
7043 emitter.update(delta);
7044 }
7045 }
7046}
7047;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/ShapeManager.js
7048const shapes = new Map();
7049class ShapeManager {
7050 constructor(engine) {
7051 this._engine = engine;
7052 }
7053 addShape(name, drawer) {
7054 if (!this.getShape(name)) {
7055 shapes.set(name, drawer);
7056 }
7057 }
7058 getShape(name) {
7059 return shapes.get(name);
7060 }
7061 getSupportedShapes() {
7062 return shapes.keys();
7063 }
7064}
7065;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/Shapes/Square/SquareShape.js
7066
7067function randomSquareCoordinate(position, offset) {
7068 return position + offset * (getRandom() - 0.5);
7069}
7070class SquareShape {
7071 randomPosition(position, size, fill) {
7072 if (fill) {
7073 return {
7074 x: randomSquareCoordinate(position.x, size.width),
7075 y: randomSquareCoordinate(position.y, size.height)
7076 };
7077 } else {
7078 const halfW = size.width / 2,
7079 halfH = size.height / 2,
7080 side = Math.floor(getRandom() * 4),
7081 v = (getRandom() - 0.5) * 2;
7082 switch (side) {
7083 case 0:
7084 return {
7085 x: position.x + v * halfW,
7086 y: position.y - halfH
7087 };
7088 case 1:
7089 return {
7090 x: position.x - halfW,
7091 y: position.y + v * halfH
7092 };
7093 case 2:
7094 return {
7095 x: position.x + v * halfW,
7096 y: position.y + halfH
7097 };
7098 case 3:
7099 default:
7100 return {
7101 x: position.x + halfW,
7102 y: position.y + v * halfH
7103 };
7104 }
7105 }
7106 }
7107}
7108;// CONCATENATED MODULE: ../../plugins/emitters/dist/esm/index.js
7109
7110
7111
7112
7113
7114
7115class EmittersPlugin {
7116 constructor(engine) {
7117 this._engine = engine;
7118 this.id = "emitters";
7119 }
7120 getPlugin(container) {
7121 return new Emitters(this._engine, container);
7122 }
7123 loadOptions(options, source) {
7124 var _a, _b, _c, _d, _e, _f;
7125 if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
7126 return;
7127 }
7128 if (source === null || source === void 0 ? void 0 : source.emitters) {
7129 options.emitters = executeOnSingleOrMultiple(source.emitters, emitter => {
7130 const tmp = new Emitter();
7131 tmp.load(emitter);
7132 return tmp;
7133 });
7134 }
7135 const interactivityEmitters = (_b = (_a = source === null || source === void 0 ? void 0 : source.interactivity) === null || _a === void 0 ? void 0 : _a.modes) === null || _b === void 0 ? void 0 : _b.emitters;
7136 if (interactivityEmitters) {
7137 if (interactivityEmitters instanceof Array) {
7138 options.interactivity.modes.emitters = {
7139 random: {
7140 count: 1,
7141 enable: true
7142 },
7143 value: interactivityEmitters.map(s => {
7144 const tmp = new Emitter();
7145 tmp.load(s);
7146 return tmp;
7147 })
7148 };
7149 } else {
7150 const emitterMode = interactivityEmitters;
7151 if (emitterMode.value !== undefined) {
7152 if (emitterMode.value instanceof Array) {
7153 options.interactivity.modes.emitters = {
7154 random: {
7155 count: (_c = emitterMode.random.count) !== null && _c !== void 0 ? _c : 1,
7156 enable: (_d = emitterMode.random.enable) !== null && _d !== void 0 ? _d : false
7157 },
7158 value: emitterMode.value.map(s => {
7159 const tmp = new Emitter();
7160 tmp.load(s);
7161 return tmp;
7162 })
7163 };
7164 } else {
7165 const tmp = new Emitter();
7166 tmp.load(emitterMode.value);
7167 options.interactivity.modes.emitters = {
7168 random: {
7169 count: (_e = emitterMode.random.count) !== null && _e !== void 0 ? _e : 1,
7170 enable: (_f = emitterMode.random.enable) !== null && _f !== void 0 ? _f : false
7171 },
7172 value: tmp
7173 };
7174 }
7175 } else {
7176 const emitterOptions = options.interactivity.modes.emitters = {
7177 random: {
7178 count: 1,
7179 enable: false
7180 },
7181 value: new Emitter()
7182 };
7183 emitterOptions.value.load(interactivityEmitters);
7184 }
7185 }
7186 }
7187 }
7188 needsPlugin(options) {
7189 var _a, _b, _c;
7190 if (!options) {
7191 return false;
7192 }
7193 const emitters = options.emitters;
7194 return emitters instanceof Array && !!emitters.length || emitters !== undefined || !!((_c = (_b = (_a = options.interactivity) === null || _a === void 0 ? void 0 : _a.events) === null || _b === void 0 ? void 0 : _b.onClick) === null || _c === void 0 ? void 0 : _c.mode) && isInArray("emitter", options.interactivity.events.onClick.mode);
7195 }
7196}
7197async function loadEmittersPlugin(engine) {
7198 if (!engine.emitterShapeManager) {
7199 engine.emitterShapeManager = new ShapeManager(engine);
7200 }
7201 if (!engine.addEmitterShape) {
7202 engine.addEmitterShape = (name, shape) => {
7203 var _a;
7204 (_a = engine.emitterShapeManager) === null || _a === void 0 ? void 0 : _a.addShape(name, shape);
7205 };
7206 }
7207 const plugin = new EmittersPlugin(engine);
7208 await engine.addPlugin(plugin);
7209 engine.addEmitterShape("circle", new CircleShape());
7210 engine.addEmitterShape("square", new SquareShape());
7211}
7212
7213
7214
7215
7216;// CONCATENATED MODULE: ../../shapes/heart/dist/esm/HeartDrawer.js
7217class HeartDrawer_HeartDrawer {
7218 draw(context, particle, radius) {
7219 const x = -radius,
7220 y = -radius;
7221 context.moveTo(x, y + radius / 2);
7222 context.quadraticCurveTo(x, y, x + radius / 2, y);
7223 context.quadraticCurveTo(x + radius, y, x + radius, y + radius / 2);
7224 context.quadraticCurveTo(x + radius, y, x + radius * 3 / 2, y);
7225 context.quadraticCurveTo(x + radius * 2, y, x + radius * 2, y + radius / 2);
7226 context.quadraticCurveTo(x + radius * 2, y + radius, x + radius * 3 / 2, y + radius * 3 / 2);
7227 context.lineTo(x + radius, y + radius * 2);
7228 context.lineTo(x + radius / 2, y + radius * 3 / 2);
7229 context.quadraticCurveTo(x, y + radius, x, y + radius / 2);
7230 }
7231}
7232;// CONCATENATED MODULE: ../../shapes/heart/dist/esm/index.js
7233
7234async function loadHeartShape(engine) {
7235 await engine.addShape("heart", new HeartDrawer_HeartDrawer());
7236}
7237;// CONCATENATED MODULE: ../../shapes/image/dist/esm/Utils.js
7238
7239const currentColorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;
7240function replaceColorSvg(imageShape, color, opacity) {
7241 const {
7242 svgData
7243 } = imageShape;
7244 if (!svgData) {
7245 return "";
7246 }
7247 const colorStyle = getStyleFromHsl(color, opacity);
7248 if (svgData.includes("fill")) {
7249 return svgData.replace(currentColorRegex, () => colorStyle);
7250 }
7251 const preFillIndex = svgData.indexOf(">");
7252 return `${svgData.substring(0, preFillIndex)} fill="${colorStyle}"${svgData.substring(preFillIndex)}`;
7253}
7254async function loadImage(image) {
7255 return new Promise(resolve => {
7256 image.loading = true;
7257 const img = new Image();
7258 image.element = img;
7259 img.addEventListener("load", () => {
7260 image.loading = false;
7261 resolve();
7262 });
7263 img.addEventListener("error", () => {
7264 image.element = undefined;
7265 image.error = true;
7266 image.loading = false;
7267 console.error(`Error tsParticles - loading image: ${image.source}`);
7268 resolve();
7269 });
7270 img.src = image.source;
7271 });
7272}
7273async function downloadSvgImage(image) {
7274 if (image.type !== "svg") {
7275 await loadImage(image);
7276 return;
7277 }
7278 image.loading = true;
7279 const response = await fetch(image.source);
7280 if (!response.ok) {
7281 console.error("Error tsParticles - Image not found");
7282 image.error = true;
7283 }
7284 if (!image.error) {
7285 image.svgData = await response.text();
7286 }
7287 image.loading = false;
7288}
7289function replaceImageColor(image, imageData, color, particle) {
7290 var _a, _b, _c;
7291 const svgColoredData = replaceColorSvg(image, color, (_b = (_a = particle.opacity) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 1),
7292 imageRes = {
7293 color,
7294 data: Object.assign(Object.assign({}, image), {
7295 svgData: svgColoredData
7296 }),
7297 loaded: false,
7298 ratio: imageData.width / imageData.height,
7299 replaceColor: (_c = imageData.replaceColor) !== null && _c !== void 0 ? _c : imageData.replace_color,
7300 source: imageData.src
7301 };
7302 return new Promise(resolve => {
7303 const svg = new Blob([svgColoredData], {
7304 type: "image/svg+xml"
7305 }),
7306 domUrl = URL || window.URL || window.webkitURL || window,
7307 url = domUrl.createObjectURL(svg),
7308 img = new Image();
7309 img.addEventListener("load", () => {
7310 imageRes.loaded = true;
7311 imageRes.element = img;
7312 resolve(imageRes);
7313 domUrl.revokeObjectURL(url);
7314 });
7315 img.addEventListener("error", async () => {
7316 domUrl.revokeObjectURL(url);
7317 const img2 = Object.assign(Object.assign({}, image), {
7318 error: false,
7319 loading: true
7320 });
7321 await loadImage(img2);
7322 imageRes.loaded = true;
7323 imageRes.element = img2.element;
7324 resolve(imageRes);
7325 });
7326 img.src = url;
7327 });
7328}
7329;// CONCATENATED MODULE: ../../shapes/image/dist/esm/ImageDrawer.js
7330
7331class ImageDrawer {
7332 constructor() {
7333 this._images = [];
7334 }
7335 addImage(container, image) {
7336 const containerImages = this.getImages(container);
7337 containerImages === null || containerImages === void 0 ? void 0 : containerImages.images.push(image);
7338 }
7339 destroy() {
7340 this._images = [];
7341 }
7342 draw(context, particle, radius, opacity) {
7343 var _a;
7344 const image = particle.image,
7345 element = image === null || image === void 0 ? void 0 : image.element;
7346 if (!element) {
7347 return;
7348 }
7349 const ratio = (_a = image === null || image === void 0 ? void 0 : image.ratio) !== null && _a !== void 0 ? _a : 1,
7350 pos = {
7351 x: -radius,
7352 y: -radius
7353 };
7354 context.globalAlpha = opacity;
7355 context.drawImage(element, pos.x, pos.y, radius * 2, radius * 2 / ratio);
7356 context.globalAlpha = 1;
7357 }
7358 getImages(container) {
7359 const containerImages = this._images.find(t => t.id === container.id);
7360 if (!containerImages) {
7361 this._images.push({
7362 id: container.id,
7363 images: []
7364 });
7365 return this.getImages(container);
7366 } else {
7367 return containerImages;
7368 }
7369 }
7370 getSidesCount() {
7371 return 12;
7372 }
7373 loadShape(particle) {
7374 if (particle.shape !== "image" && particle.shape !== "images") {
7375 return;
7376 }
7377 const container = particle.container,
7378 images = this.getImages(container).images,
7379 imageData = particle.shapeData,
7380 image = images.find(t => t.source === imageData.src);
7381 if (!image) {
7382 this.loadImageShape(container, imageData).then(() => {
7383 this.loadShape(particle);
7384 });
7385 }
7386 }
7387 particleInit(container, particle) {
7388 var _a;
7389 if (particle.shape !== "image" && particle.shape !== "images") {
7390 return;
7391 }
7392 const images = this.getImages(container).images,
7393 imageData = particle.shapeData,
7394 color = particle.getFillColor(),
7395 replaceColor = (_a = imageData.replaceColor) !== null && _a !== void 0 ? _a : imageData.replace_color,
7396 image = images.find(t => t.source === imageData.src);
7397 if (!image) {
7398 return;
7399 }
7400 if (image.loading) {
7401 setTimeout(() => {
7402 this.particleInit(container, particle);
7403 });
7404 return;
7405 }
7406 (async () => {
7407 var _a, _b;
7408 let imageRes;
7409 if (image.svgData && color) {
7410 imageRes = await replaceImageColor(image, imageData, color, particle);
7411 } else {
7412 imageRes = {
7413 color,
7414 data: image,
7415 element: image.element,
7416 loaded: true,
7417 ratio: imageData.width / imageData.height,
7418 replaceColor: replaceColor,
7419 source: imageData.src
7420 };
7421 }
7422 if (!imageRes.ratio) {
7423 imageRes.ratio = 1;
7424 }
7425 const fill = (_a = imageData.fill) !== null && _a !== void 0 ? _a : particle.fill,
7426 close = (_b = imageData.close) !== null && _b !== void 0 ? _b : particle.close,
7427 imageShape = {
7428 image: imageRes,
7429 fill,
7430 close
7431 };
7432 particle.image = imageShape.image;
7433 particle.fill = imageShape.fill;
7434 particle.close = imageShape.close;
7435 })();
7436 }
7437 async loadImageShape(container, imageShape) {
7438 var _a;
7439 const source = imageShape.src;
7440 if (!source) {
7441 throw new Error("Error tsParticles - No image.src");
7442 }
7443 try {
7444 const image = {
7445 source: source,
7446 type: source.substring(source.length - 3),
7447 error: false,
7448 loading: true
7449 };
7450 this.addImage(container, image);
7451 const imageFunc = ((_a = imageShape.replaceColor) !== null && _a !== void 0 ? _a : imageShape.replace_color) ? downloadSvgImage : loadImage;
7452 await imageFunc(image);
7453 } catch (_b) {
7454 throw new Error(`tsParticles error - ${imageShape.src} not found`);
7455 }
7456 }
7457}
7458;// CONCATENATED MODULE: ../../shapes/image/dist/esm/index.js
7459
7460async function loadImageShape(engine) {
7461 await engine.addShape(["image", "images"], new ImageDrawer());
7462}
7463;// CONCATENATED MODULE: ../../updaters/life/dist/esm/Options/Classes/LifeDelay.js
7464
7465class LifeDelay extends ValueWithRandom {
7466 constructor() {
7467 super();
7468 this.sync = false;
7469 }
7470 load(data) {
7471 if (!data) {
7472 return;
7473 }
7474 super.load(data);
7475 if (data.sync !== undefined) {
7476 this.sync = data.sync;
7477 }
7478 }
7479}
7480;// CONCATENATED MODULE: ../../updaters/life/dist/esm/Options/Classes/LifeDuration.js
7481
7482class LifeDuration extends ValueWithRandom {
7483 constructor() {
7484 super();
7485 this.random.minimumValue = 0.0001;
7486 this.sync = false;
7487 }
7488 load(data) {
7489 if (!data) {
7490 return;
7491 }
7492 super.load(data);
7493 if (data.sync !== undefined) {
7494 this.sync = data.sync;
7495 }
7496 }
7497}
7498;// CONCATENATED MODULE: ../../updaters/life/dist/esm/Options/Classes/Life.js
7499
7500
7501class Life {
7502 constructor() {
7503 this.count = 0;
7504 this.delay = new LifeDelay();
7505 this.duration = new LifeDuration();
7506 }
7507 load(data) {
7508 if (!data) {
7509 return;
7510 }
7511 if (data.count !== undefined) {
7512 this.count = data.count;
7513 }
7514 this.delay.load(data.delay);
7515 this.duration.load(data.duration);
7516 }
7517}
7518;// CONCATENATED MODULE: ../../updaters/life/dist/esm/LifeUpdater.js
7519
7520
7521class LifeUpdater {
7522 constructor(container) {
7523 this.container = container;
7524 }
7525 init(particle) {
7526 const container = this.container,
7527 particlesOptions = particle.options,
7528 lifeOptions = particlesOptions.life;
7529 if (!lifeOptions) {
7530 return;
7531 }
7532 particle.life = {
7533 delay: container.retina.reduceFactor ? getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ? 1 : getRandom()) / container.retina.reduceFactor * 1000 : 0,
7534 delayTime: 0,
7535 duration: container.retina.reduceFactor ? getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ? 1 : getRandom()) / container.retina.reduceFactor * 1000 : 0,
7536 time: 0,
7537 count: lifeOptions.count
7538 };
7539 if (particle.life.duration <= 0) {
7540 particle.life.duration = -1;
7541 }
7542 if (particle.life.count <= 0) {
7543 particle.life.count = -1;
7544 }
7545 if (particle.life) {
7546 particle.spawning = particle.life.delay > 0;
7547 }
7548 }
7549 isEnabled(particle) {
7550 return !particle.destroyed;
7551 }
7552 loadOptions(options, ...sources) {
7553 if (!options.life) {
7554 options.life = new Life();
7555 }
7556 for (const source of sources) {
7557 options.life.load(source === null || source === void 0 ? void 0 : source.life);
7558 }
7559 }
7560 update(particle, delta) {
7561 if (!this.isEnabled(particle) || !particle.life) {
7562 return;
7563 }
7564 const life = particle.life;
7565 let justSpawned = false;
7566 if (particle.spawning) {
7567 life.delayTime += delta.value;
7568 if (life.delayTime >= particle.life.delay) {
7569 justSpawned = true;
7570 particle.spawning = false;
7571 life.delayTime = 0;
7572 life.time = 0;
7573 } else {
7574 return;
7575 }
7576 }
7577 if (life.duration === -1) {
7578 return;
7579 }
7580 if (particle.spawning) {
7581 return;
7582 }
7583 if (justSpawned) {
7584 life.time = 0;
7585 } else {
7586 life.time += delta.value;
7587 }
7588 if (life.time < life.duration) {
7589 return;
7590 }
7591 life.time = 0;
7592 if (particle.life.count > 0) {
7593 particle.life.count--;
7594 }
7595 if (particle.life.count === 0) {
7596 particle.destroy();
7597 return;
7598 }
7599 const canvasSize = this.container.canvas.size,
7600 widthRange = setRangeValue(0, canvasSize.width),
7601 heightRange = setRangeValue(0, canvasSize.width);
7602 particle.position.x = randomInRange(widthRange);
7603 particle.position.y = randomInRange(heightRange);
7604 particle.spawning = true;
7605 life.delayTime = 0;
7606 life.time = 0;
7607 particle.reset();
7608 const lifeOptions = particle.options.life;
7609 if (lifeOptions) {
7610 life.delay = getRangeValue(lifeOptions.delay.value) * 1000;
7611 life.duration = getRangeValue(lifeOptions.duration.value) * 1000;
7612 }
7613 }
7614}
7615;// CONCATENATED MODULE: ../../updaters/life/dist/esm/index.js
7616
7617async function loadLifeUpdater(engine) {
7618 await engine.addParticleUpdater("life", container => new LifeUpdater(container));
7619}
7620;// CONCATENATED MODULE: ../../plugins/motion/dist/esm/Options/Classes/MotionReduce.js
7621class MotionReduce {
7622 constructor() {
7623 this.factor = 4;
7624 this.value = true;
7625 }
7626 load(data) {
7627 if (!data) {
7628 return;
7629 }
7630 if (data.factor !== undefined) {
7631 this.factor = data.factor;
7632 }
7633 if (data.value !== undefined) {
7634 this.value = data.value;
7635 }
7636 }
7637}
7638;// CONCATENATED MODULE: ../../plugins/motion/dist/esm/Options/Classes/Motion.js
7639
7640class Motion {
7641 constructor() {
7642 this.disable = false;
7643 this.reduce = new MotionReduce();
7644 }
7645 load(data) {
7646 if (!data) {
7647 return;
7648 }
7649 if (data.disable !== undefined) {
7650 this.disable = data.disable;
7651 }
7652 this.reduce.load(data.reduce);
7653 }
7654}
7655;// CONCATENATED MODULE: ../../plugins/motion/dist/esm/MotionInstance.js
7656
7657class MotionInstance {
7658 constructor(container, engine) {
7659 this._container = container;
7660 this._engine = engine;
7661 }
7662 async init() {
7663 const container = this._container,
7664 options = container.actualOptions.motion;
7665 if (options && (options.disable || options.reduce.value)) {
7666 const mediaQuery = safeMatchMedia("(prefers-reduced-motion: reduce)");
7667 if (mediaQuery) {
7668 this._handleMotionChange(mediaQuery);
7669 const handleChange = async () => {
7670 this._handleMotionChange(mediaQuery);
7671 try {
7672 await container.refresh();
7673 } catch (_a) {}
7674 };
7675 if (mediaQuery.addEventListener !== undefined) {
7676 mediaQuery.addEventListener("change", handleChange);
7677 } else if (mediaQuery.addListener !== undefined) {
7678 mediaQuery.addListener(handleChange);
7679 }
7680 } else {
7681 container.retina.reduceFactor = 1;
7682 }
7683 } else {
7684 container.retina.reduceFactor = 1;
7685 }
7686 }
7687 _handleMotionChange(mediaQuery) {
7688 const container = this._container,
7689 motion = container.actualOptions.motion;
7690 if (!motion) {
7691 return;
7692 }
7693 container.retina.reduceFactor = mediaQuery.matches ? motion.disable ? 0 : motion.reduce.value ? 1 / motion.reduce.factor : 1 : 1;
7694 }
7695}
7696;// CONCATENATED MODULE: ../../plugins/motion/dist/esm/index.js
7697
7698
7699class MotionPlugin {
7700 constructor(engine) {
7701 this.id = "motion";
7702 this._engine = engine;
7703 }
7704 getPlugin(container) {
7705 return new MotionInstance(container, this._engine);
7706 }
7707 loadOptions(options, source) {
7708 if (!this.needsPlugin()) {
7709 return;
7710 }
7711 let motionOptions = options.motion;
7712 if ((motionOptions === null || motionOptions === void 0 ? void 0 : motionOptions.load) === undefined) {
7713 options.motion = motionOptions = new Motion();
7714 }
7715 motionOptions.load(source === null || source === void 0 ? void 0 : source.motion);
7716 }
7717 needsPlugin() {
7718 return true;
7719 }
7720}
7721async function loadMotionPlugin(engine) {
7722 const plugin = new MotionPlugin(engine);
7723 await engine.addPlugin(plugin);
7724}
7725;// CONCATENATED MODULE: ../../updaters/opacity/dist/esm/OpacityUpdater.js
7726
7727function checkDestroy(particle, value, minValue, maxValue) {
7728 switch (particle.options.opacity.animation.destroy) {
7729 case "max":
7730 if (value >= maxValue) {
7731 particle.destroy();
7732 }
7733 break;
7734 case "min":
7735 if (value <= minValue) {
7736 particle.destroy();
7737 }
7738 break;
7739 }
7740}
7741function updateOpacity(particle, delta) {
7742 var _a, _b, _c, _d, _e, _f;
7743 if (!particle.opacity) {
7744 return;
7745 }
7746 const minValue = particle.opacity.min,
7747 maxValue = particle.opacity.max,
7748 decay = (_a = particle.opacity.decay) !== null && _a !== void 0 ? _a : 1;
7749 if (particle.destroyed || !particle.opacity.enable || ((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) > ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0)) {
7750 return;
7751 }
7752 switch (particle.opacity.status) {
7753 case "increasing":
7754 if (particle.opacity.value >= maxValue) {
7755 particle.opacity.status = "decreasing";
7756 if (!particle.opacity.loops) {
7757 particle.opacity.loops = 0;
7758 }
7759 particle.opacity.loops++;
7760 } else {
7761 particle.opacity.value += ((_e = particle.opacity.velocity) !== null && _e !== void 0 ? _e : 0) * delta.factor;
7762 }
7763 break;
7764 case "decreasing":
7765 if (particle.opacity.value <= minValue) {
7766 particle.opacity.status = "increasing";
7767 if (!particle.opacity.loops) {
7768 particle.opacity.loops = 0;
7769 }
7770 particle.opacity.loops++;
7771 } else {
7772 particle.opacity.value -= ((_f = particle.opacity.velocity) !== null && _f !== void 0 ? _f : 0) * delta.factor;
7773 }
7774 break;
7775 }
7776 if (particle.opacity.velocity && particle.opacity.decay !== 1) {
7777 particle.opacity.velocity *= decay;
7778 }
7779 checkDestroy(particle, particle.opacity.value, minValue, maxValue);
7780 if (!particle.destroyed) {
7781 particle.opacity.value = clamp(particle.opacity.value, minValue, maxValue);
7782 }
7783}
7784class OpacityUpdater {
7785 constructor(container) {
7786 this.container = container;
7787 }
7788 init(particle) {
7789 const opacityOptions = particle.options.opacity;
7790 particle.opacity = {
7791 enable: opacityOptions.animation.enable,
7792 max: getRangeMax(opacityOptions.value),
7793 min: getRangeMin(opacityOptions.value),
7794 value: getRangeValue(opacityOptions.value),
7795 loops: 0,
7796 maxLoops: getRangeValue(opacityOptions.animation.count)
7797 };
7798 const opacityAnimation = opacityOptions.animation;
7799 if (opacityAnimation.enable) {
7800 particle.opacity.decay = 1 - getRangeValue(opacityAnimation.decay);
7801 particle.opacity.status = "increasing";
7802 const opacityRange = opacityOptions.value;
7803 particle.opacity.min = getRangeMin(opacityRange);
7804 particle.opacity.max = getRangeMax(opacityRange);
7805 switch (opacityAnimation.startValue) {
7806 case "min":
7807 particle.opacity.value = particle.opacity.min;
7808 particle.opacity.status = "increasing";
7809 break;
7810 case "random":
7811 particle.opacity.value = randomInRange(particle.opacity);
7812 particle.opacity.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
7813 break;
7814 case "max":
7815 default:
7816 particle.opacity.value = particle.opacity.max;
7817 particle.opacity.status = "decreasing";
7818 break;
7819 }
7820 particle.opacity.velocity = getRangeValue(opacityAnimation.speed) / 100 * this.container.retina.reduceFactor;
7821 if (!opacityAnimation.sync) {
7822 particle.opacity.velocity *= getRandom();
7823 }
7824 }
7825 particle.opacity.initialValue = particle.opacity.value;
7826 }
7827 isEnabled(particle) {
7828 var _a, _b, _c, _d;
7829 return !particle.destroyed && !particle.spawning && !!particle.opacity && particle.opacity.enable && (((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 || ((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0));
7830 }
7831 reset(particle) {
7832 if (particle.opacity) {
7833 particle.opacity.loops = 0;
7834 }
7835 }
7836 update(particle, delta) {
7837 if (!this.isEnabled(particle)) {
7838 return;
7839 }
7840 updateOpacity(particle, delta);
7841 }
7842}
7843;// CONCATENATED MODULE: ../../updaters/opacity/dist/esm/index.js
7844
7845async function loadOpacityUpdater(engine) {
7846 await engine.addParticleUpdater("opacity", container => new OpacityUpdater(container));
7847}
7848;// CONCATENATED MODULE: ../../updaters/outModes/dist/esm/Utils.js
7849
7850function bounceHorizontal(data) {
7851 if (data.outMode !== "bounce" && data.outMode !== "bounce-horizontal" && data.outMode !== "bounceHorizontal" && data.outMode !== "split") {
7852 return;
7853 }
7854 if (data.bounds.right < 0) {
7855 data.particle.position.x = data.size + data.offset.x;
7856 } else if (data.bounds.left > data.canvasSize.width) {
7857 data.particle.position.x = data.canvasSize.width - data.size - data.offset.x;
7858 }
7859 const velocity = data.particle.velocity.x;
7860 let bounced = false;
7861 if (data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0 || data.direction === "left" && data.bounds.left <= 0 && velocity < 0) {
7862 const newVelocity = getValue(data.particle.options.bounce.horizontal);
7863 data.particle.velocity.x *= -newVelocity;
7864 bounced = true;
7865 }
7866 if (!bounced) {
7867 return;
7868 }
7869 const minPos = data.offset.x + data.size;
7870 if (data.bounds.right >= data.canvasSize.width) {
7871 data.particle.position.x = data.canvasSize.width - minPos;
7872 } else if (data.bounds.left <= 0) {
7873 data.particle.position.x = minPos;
7874 }
7875 if (data.outMode === "split") {
7876 data.particle.destroy();
7877 }
7878}
7879function bounceVertical(data) {
7880 if (data.outMode !== "bounce" && data.outMode !== "bounce-vertical" && data.outMode !== "bounceVertical" && data.outMode !== "split") {
7881 return;
7882 }
7883 if (data.bounds.bottom < 0) {
7884 data.particle.position.y = data.size + data.offset.y;
7885 } else if (data.bounds.top > data.canvasSize.height) {
7886 data.particle.position.y = data.canvasSize.height - data.size - data.offset.y;
7887 }
7888 const velocity = data.particle.velocity.y;
7889 let bounced = false;
7890 if (data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0 || data.direction === "top" && data.bounds.top <= 0 && velocity < 0) {
7891 const newVelocity = getValue(data.particle.options.bounce.vertical);
7892 data.particle.velocity.y *= -newVelocity;
7893 bounced = true;
7894 }
7895 if (!bounced) {
7896 return;
7897 }
7898 const minPos = data.offset.y + data.size;
7899 if (data.bounds.bottom >= data.canvasSize.height) {
7900 data.particle.position.y = data.canvasSize.height - minPos;
7901 } else if (data.bounds.top <= 0) {
7902 data.particle.position.y = minPos;
7903 }
7904 if (data.outMode === "split") {
7905 data.particle.destroy();
7906 }
7907}
7908;// CONCATENATED MODULE: ../../updaters/outModes/dist/esm/BounceOutMode.js
7909
7910
7911class BounceOutMode {
7912 constructor(container) {
7913 this.container = container;
7914 this.modes = ["bounce", "bounce-vertical", "bounce-horizontal", "bounceVertical", "bounceHorizontal", "split"];
7915 }
7916 update(particle, direction, delta, outMode) {
7917 if (!this.modes.includes(outMode)) {
7918 return;
7919 }
7920 const container = this.container;
7921 let handled = false;
7922 for (const [, plugin] of container.plugins) {
7923 if (plugin.particleBounce !== undefined) {
7924 handled = plugin.particleBounce(particle, delta, direction);
7925 }
7926 if (handled) {
7927 break;
7928 }
7929 }
7930 if (handled) {
7931 return;
7932 }
7933 const pos = particle.getPosition(),
7934 offset = particle.offset,
7935 size = particle.getRadius(),
7936 bounds = calculateBounds(pos, size),
7937 canvasSize = container.canvas.size;
7938 bounceHorizontal({
7939 particle,
7940 outMode,
7941 direction,
7942 bounds,
7943 canvasSize,
7944 offset,
7945 size
7946 });
7947 bounceVertical({
7948 particle,
7949 outMode,
7950 direction,
7951 bounds,
7952 canvasSize,
7953 offset,
7954 size
7955 });
7956 }
7957}
7958;// CONCATENATED MODULE: ../../updaters/outModes/dist/esm/DestroyOutMode.js
7959
7960class DestroyOutMode {
7961 constructor(container) {
7962 this.container = container;
7963 this.modes = ["destroy"];
7964 }
7965 update(particle, direction, delta, outMode) {
7966 if (!this.modes.includes(outMode)) {
7967 return;
7968 }
7969 const container = this.container;
7970 switch (particle.outType) {
7971 case "normal":
7972 case "outside":
7973 if (isPointInside(particle.position, container.canvas.size, Vector.origin, particle.getRadius(), direction)) {
7974 return;
7975 }
7976 break;
7977 case "inside":
7978 {
7979 const {
7980 dx,
7981 dy
7982 } = getDistances(particle.position, particle.moveCenter);
7983 const {
7984 x: vx,
7985 y: vy
7986 } = particle.velocity;
7987 if (vx < 0 && dx > particle.moveCenter.radius || vy < 0 && dy > particle.moveCenter.radius || vx >= 0 && dx < -particle.moveCenter.radius || vy >= 0 && dy < -particle.moveCenter.radius) {
7988 return;
7989 }
7990 break;
7991 }
7992 }
7993 container.particles.remove(particle, undefined, true);
7994 }
7995}
7996;// CONCATENATED MODULE: ../../updaters/outModes/dist/esm/NoneOutMode.js
7997
7998class NoneOutMode {
7999 constructor(container) {
8000 this.container = container;
8001 this.modes = ["none"];
8002 }
8003 update(particle, direction, delta, outMode) {
8004 if (!this.modes.includes(outMode)) {
8005 return;
8006 }
8007 if (particle.options.move.distance.horizontal && (direction === "left" || direction === "right") || particle.options.move.distance.vertical && (direction === "top" || direction === "bottom")) {
8008 return;
8009 }
8010 const gravityOptions = particle.options.move.gravity,
8011 container = this.container;
8012 const canvasSize = container.canvas.size;
8013 const pRadius = particle.getRadius();
8014 if (!gravityOptions.enable) {
8015 if (particle.velocity.y > 0 && particle.position.y <= canvasSize.height + pRadius || particle.velocity.y < 0 && particle.position.y >= -pRadius || particle.velocity.x > 0 && particle.position.x <= canvasSize.width + pRadius || particle.velocity.x < 0 && particle.position.x >= -pRadius) {
8016 return;
8017 }
8018 if (!isPointInside(particle.position, container.canvas.size, Vector.origin, pRadius, direction)) {
8019 container.particles.remove(particle);
8020 }
8021 } else {
8022 const position = particle.position;
8023 if (!gravityOptions.inverse && position.y > canvasSize.height + pRadius && direction === "bottom" || gravityOptions.inverse && position.y < -pRadius && direction === "top") {
8024 container.particles.remove(particle);
8025 }
8026 }
8027 }
8028}
8029;// CONCATENATED MODULE: ../../updaters/outModes/dist/esm/OutOutMode.js
8030
8031class OutOutMode {
8032 constructor(container) {
8033 this.container = container;
8034 this.modes = ["out"];
8035 }
8036 update(particle, direction, delta, outMode) {
8037 if (!this.modes.includes(outMode)) {
8038 return;
8039 }
8040 const container = this.container;
8041 switch (particle.outType) {
8042 case "inside":
8043 {
8044 const {
8045 x: vx,
8046 y: vy
8047 } = particle.velocity;
8048 const circVec = Vector.origin;
8049 circVec.length = particle.moveCenter.radius;
8050 circVec.angle = particle.velocity.angle + Math.PI;
8051 circVec.addTo(Vector.create(particle.moveCenter));
8052 const {
8053 dx,
8054 dy
8055 } = getDistances(particle.position, circVec);
8056 if (vx <= 0 && dx >= 0 || vy <= 0 && dy >= 0 || vx >= 0 && dx <= 0 || vy >= 0 && dy <= 0) {
8057 return;
8058 }
8059 particle.position.x = Math.floor(randomInRange({
8060 min: 0,
8061 max: container.canvas.size.width
8062 }));
8063 particle.position.y = Math.floor(randomInRange({
8064 min: 0,
8065 max: container.canvas.size.height
8066 }));
8067 const {
8068 dx: newDx,
8069 dy: newDy
8070 } = getDistances(particle.position, particle.moveCenter);
8071 particle.direction = Math.atan2(-newDy, -newDx);
8072 particle.velocity.angle = particle.direction;
8073 break;
8074 }
8075 default:
8076 {
8077 if (isPointInside(particle.position, container.canvas.size, Vector.origin, particle.getRadius(), direction)) {
8078 return;
8079 }
8080 switch (particle.outType) {
8081 case "outside":
8082 {
8083 particle.position.x = Math.floor(randomInRange({
8084 min: -particle.moveCenter.radius,
8085 max: particle.moveCenter.radius
8086 })) + particle.moveCenter.x;
8087 particle.position.y = Math.floor(randomInRange({
8088 min: -particle.moveCenter.radius,
8089 max: particle.moveCenter.radius
8090 })) + particle.moveCenter.y;
8091 const {
8092 dx,
8093 dy
8094 } = getDistances(particle.position, particle.moveCenter);
8095 if (particle.moveCenter.radius) {
8096 particle.direction = Math.atan2(dy, dx);
8097 particle.velocity.angle = particle.direction;
8098 }
8099 break;
8100 }
8101 case "normal":
8102 {
8103 const wrap = particle.options.move.warp,
8104 canvasSize = container.canvas.size,
8105 newPos = {
8106 bottom: canvasSize.height + particle.getRadius() + particle.offset.y,
8107 left: -particle.getRadius() - particle.offset.x,
8108 right: canvasSize.width + particle.getRadius() + particle.offset.x,
8109 top: -particle.getRadius() - particle.offset.y
8110 },
8111 sizeValue = particle.getRadius(),
8112 nextBounds = calculateBounds(particle.position, sizeValue);
8113 if (direction === "right" && nextBounds.left > canvasSize.width + particle.offset.x) {
8114 particle.position.x = newPos.left;
8115 particle.initialPosition.x = particle.position.x;
8116 if (!wrap) {
8117 particle.position.y = getRandom() * canvasSize.height;
8118 particle.initialPosition.y = particle.position.y;
8119 }
8120 } else if (direction === "left" && nextBounds.right < -particle.offset.x) {
8121 particle.position.x = newPos.right;
8122 particle.initialPosition.x = particle.position.x;
8123 if (!wrap) {
8124 particle.position.y = getRandom() * canvasSize.height;
8125 particle.initialPosition.y = particle.position.y;
8126 }
8127 }
8128 if (direction === "bottom" && nextBounds.top > canvasSize.height + particle.offset.y) {
8129 if (!wrap) {
8130 particle.position.x = getRandom() * canvasSize.width;
8131 particle.initialPosition.x = particle.position.x;
8132 }
8133 particle.position.y = newPos.top;
8134 particle.initialPosition.y = particle.position.y;
8135 } else if (direction === "top" && nextBounds.bottom < -particle.offset.y) {
8136 if (!wrap) {
8137 particle.position.x = getRandom() * canvasSize.width;
8138 particle.initialPosition.x = particle.position.x;
8139 }
8140 particle.position.y = newPos.bottom;
8141 particle.initialPosition.y = particle.position.y;
8142 }
8143 break;
8144 }
8145 }
8146 break;
8147 }
8148 }
8149 }
8150}
8151;// CONCATENATED MODULE: ../../updaters/outModes/dist/esm/OutOfCanvasUpdater.js
8152
8153
8154
8155
8156class OutOfCanvasUpdater {
8157 constructor(container) {
8158 this.container = container;
8159 this.updaters = [new BounceOutMode(container), new DestroyOutMode(container), new OutOutMode(container), new NoneOutMode(container)];
8160 }
8161 init() {}
8162 isEnabled(particle) {
8163 return !particle.destroyed && !particle.spawning;
8164 }
8165 update(particle, delta) {
8166 var _a, _b, _c, _d;
8167 const outModes = particle.options.move.outModes;
8168 this.updateOutMode(particle, delta, (_a = outModes.bottom) !== null && _a !== void 0 ? _a : outModes.default, "bottom");
8169 this.updateOutMode(particle, delta, (_b = outModes.left) !== null && _b !== void 0 ? _b : outModes.default, "left");
8170 this.updateOutMode(particle, delta, (_c = outModes.right) !== null && _c !== void 0 ? _c : outModes.default, "right");
8171 this.updateOutMode(particle, delta, (_d = outModes.top) !== null && _d !== void 0 ? _d : outModes.default, "top");
8172 }
8173 updateOutMode(particle, delta, outMode, direction) {
8174 for (const updater of this.updaters) {
8175 updater.update(particle, direction, delta, outMode);
8176 }
8177 }
8178}
8179;// CONCATENATED MODULE: ../../updaters/outModes/dist/esm/index.js
8180
8181async function loadOutModesUpdater(engine) {
8182 await engine.addParticleUpdater("outModes", container => new OutOfCanvasUpdater(container));
8183}
8184;// CONCATENATED MODULE: ../../shapes/polygon/dist/esm/PolygonDrawerBase.js
8185
8186class PolygonDrawerBase {
8187 draw(context, particle, radius) {
8188 const start = this.getCenter(particle, radius),
8189 side = this.getSidesData(particle, radius),
8190 sideCount = side.count.numerator * side.count.denominator,
8191 decimalSides = side.count.numerator / side.count.denominator,
8192 interiorAngleDegrees = 180 * (decimalSides - 2) / decimalSides,
8193 interiorAngle = Math.PI - Math.PI * interiorAngleDegrees / 180;
8194 if (!context) {
8195 return;
8196 }
8197 context.beginPath();
8198 context.translate(start.x, start.y);
8199 context.moveTo(0, 0);
8200 for (let i = 0; i < sideCount; i++) {
8201 context.lineTo(side.length, 0);
8202 context.translate(side.length, 0);
8203 context.rotate(interiorAngle);
8204 }
8205 }
8206 getSidesCount(particle) {
8207 var _a, _b;
8208 const polygon = particle.shapeData,
8209 sides = Math.round(getRangeValue((_b = (_a = polygon === null || polygon === void 0 ? void 0 : polygon.sides) !== null && _a !== void 0 ? _a : polygon === null || polygon === void 0 ? void 0 : polygon.nb_sides) !== null && _b !== void 0 ? _b : 5));
8210 return sides;
8211 }
8212}
8213;// CONCATENATED MODULE: ../../shapes/polygon/dist/esm/PolygonDrawer.js
8214
8215class PolygonDrawer extends PolygonDrawerBase {
8216 getCenter(particle, radius) {
8217 return {
8218 x: -radius / (particle.sides / 3.5),
8219 y: -radius / (2.66 / 3.5)
8220 };
8221 }
8222 getSidesData(particle, radius) {
8223 const sides = particle.sides;
8224 return {
8225 count: {
8226 denominator: 1,
8227 numerator: sides
8228 },
8229 length: radius * 2.66 / (sides / 3)
8230 };
8231 }
8232}
8233;// CONCATENATED MODULE: ../../shapes/polygon/dist/esm/TriangleDrawer.js
8234
8235class TriangleDrawer extends PolygonDrawerBase {
8236 getCenter(particle, radius) {
8237 return {
8238 x: -radius,
8239 y: radius / 1.66
8240 };
8241 }
8242 getSidesCount() {
8243 return 3;
8244 }
8245 getSidesData(particle, radius) {
8246 return {
8247 count: {
8248 denominator: 2,
8249 numerator: 3
8250 },
8251 length: radius * 2
8252 };
8253 }
8254}
8255;// CONCATENATED MODULE: ../../shapes/polygon/dist/esm/index.js
8256
8257
8258async function loadGenericPolygonShape(engine) {
8259 await engine.addShape("polygon", new PolygonDrawer());
8260}
8261async function loadTriangleShape(engine) {
8262 await engine.addShape("triangle", new TriangleDrawer());
8263}
8264async function loadPolygonShape(engine) {
8265 await loadGenericPolygonShape(engine);
8266 await loadTriangleShape(engine);
8267}
8268;// CONCATENATED MODULE: ../../updaters/roll/dist/esm/Options/Classes/RollLight.js
8269
8270class RollLight {
8271 constructor() {
8272 this.enable = false;
8273 this.value = 0;
8274 }
8275 load(data) {
8276 if (!data) {
8277 return;
8278 }
8279 if (data.enable !== undefined) {
8280 this.enable = data.enable;
8281 }
8282 if (data.value !== undefined) {
8283 this.value = setRangeValue(data.value);
8284 }
8285 }
8286}
8287;// CONCATENATED MODULE: ../../updaters/roll/dist/esm/Options/Classes/Roll.js
8288
8289
8290class Roll {
8291 constructor() {
8292 this.darken = new RollLight();
8293 this.enable = false;
8294 this.enlighten = new RollLight();
8295 this.mode = "vertical";
8296 this.speed = 25;
8297 }
8298 load(data) {
8299 if (!data) {
8300 return;
8301 }
8302 if (data.backColor !== undefined) {
8303 this.backColor = OptionsColor.create(this.backColor, data.backColor);
8304 }
8305 this.darken.load(data.darken);
8306 if (data.enable !== undefined) {
8307 this.enable = data.enable;
8308 }
8309 this.enlighten.load(data.enlighten);
8310 if (data.mode !== undefined) {
8311 this.mode = data.mode;
8312 }
8313 if (data.speed !== undefined) {
8314 this.speed = setRangeValue(data.speed);
8315 }
8316 }
8317}
8318;// CONCATENATED MODULE: ../../updaters/roll/dist/esm/RollUpdater.js
8319
8320
8321function updateRoll(particle, delta) {
8322 const roll = particle.options.roll;
8323 if (!particle.roll || !(roll === null || roll === void 0 ? void 0 : roll.enable)) {
8324 return;
8325 }
8326 const speed = particle.roll.speed * delta.factor,
8327 max = 2 * Math.PI;
8328 particle.roll.angle += speed;
8329 if (particle.roll.angle > max) {
8330 particle.roll.angle -= max;
8331 }
8332}
8333class RollUpdater {
8334 getTransformValues(particle) {
8335 var _a;
8336 const roll = ((_a = particle.roll) === null || _a === void 0 ? void 0 : _a.enable) && particle.roll,
8337 rollHorizontal = roll && roll.horizontal,
8338 rollVertical = roll && roll.vertical;
8339 return {
8340 a: rollHorizontal ? Math.cos(roll.angle) : undefined,
8341 d: rollVertical ? Math.sin(roll.angle) : undefined
8342 };
8343 }
8344 init(particle) {
8345 const rollOpt = particle.options.roll;
8346 if (rollOpt === null || rollOpt === void 0 ? void 0 : rollOpt.enable) {
8347 particle.roll = {
8348 enable: rollOpt.enable,
8349 horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
8350 vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
8351 angle: getRandom() * Math.PI * 2,
8352 speed: getRangeValue(rollOpt.speed) / 360
8353 };
8354 if (rollOpt.backColor) {
8355 particle.backColor = rangeColorToHsl(rollOpt.backColor);
8356 } else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
8357 const alterType = getRandom() >= 0.5 ? "darken" : "enlighten";
8358 particle.roll.alter = {
8359 type: alterType,
8360 value: getRangeValue(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value)
8361 };
8362 } else if (rollOpt.darken.enable) {
8363 particle.roll.alter = {
8364 type: "darken",
8365 value: getRangeValue(rollOpt.darken.value)
8366 };
8367 } else if (rollOpt.enlighten.enable) {
8368 particle.roll.alter = {
8369 type: "enlighten",
8370 value: getRangeValue(rollOpt.enlighten.value)
8371 };
8372 }
8373 } else {
8374 particle.roll = {
8375 enable: false,
8376 horizontal: false,
8377 vertical: false,
8378 angle: 0,
8379 speed: 0
8380 };
8381 }
8382 }
8383 isEnabled(particle) {
8384 const roll = particle.options.roll;
8385 return !particle.destroyed && !particle.spawning && !!(roll === null || roll === void 0 ? void 0 : roll.enable);
8386 }
8387 loadOptions(options, ...sources) {
8388 if (!options.roll) {
8389 options.roll = new Roll();
8390 }
8391 for (const source of sources) {
8392 options.roll.load(source === null || source === void 0 ? void 0 : source.roll);
8393 }
8394 }
8395 update(particle, delta) {
8396 if (!this.isEnabled(particle)) {
8397 return;
8398 }
8399 updateRoll(particle, delta);
8400 }
8401}
8402;// CONCATENATED MODULE: ../../updaters/roll/dist/esm/index.js
8403
8404async function loadRollUpdater(engine) {
8405 await engine.addParticleUpdater("roll", () => new RollUpdater());
8406}
8407;// CONCATENATED MODULE: ../../updaters/size/dist/esm/SizeUpdater.js
8408
8409function SizeUpdater_checkDestroy(particle, value, minValue, maxValue) {
8410 switch (particle.options.size.animation.destroy) {
8411 case "max":
8412 if (value >= maxValue) {
8413 particle.destroy();
8414 }
8415 break;
8416 case "min":
8417 if (value <= minValue) {
8418 particle.destroy();
8419 }
8420 break;
8421 }
8422}
8423function updateSize(particle, delta) {
8424 var _a, _b, _c, _d, _e;
8425 const sizeVelocity = ((_a = particle.size.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor,
8426 minValue = particle.size.min,
8427 maxValue = particle.size.max,
8428 decay = (_b = particle.size.decay) !== null && _b !== void 0 ? _b : 1;
8429 if (particle.destroyed || !particle.size.enable || ((_c = particle.size.maxLoops) !== null && _c !== void 0 ? _c : 0) > 0 && ((_d = particle.size.loops) !== null && _d !== void 0 ? _d : 0) > ((_e = particle.size.maxLoops) !== null && _e !== void 0 ? _e : 0)) {
8430 return;
8431 }
8432 switch (particle.size.status) {
8433 case "increasing":
8434 if (particle.size.value >= maxValue) {
8435 particle.size.status = "decreasing";
8436 if (!particle.size.loops) {
8437 particle.size.loops = 0;
8438 }
8439 particle.size.loops++;
8440 } else {
8441 particle.size.value += sizeVelocity;
8442 }
8443 break;
8444 case "decreasing":
8445 if (particle.size.value <= minValue) {
8446 particle.size.status = "increasing";
8447 if (!particle.size.loops) {
8448 particle.size.loops = 0;
8449 }
8450 particle.size.loops++;
8451 } else {
8452 particle.size.value -= sizeVelocity;
8453 }
8454 }
8455 if (particle.size.velocity && decay !== 1) {
8456 particle.size.velocity *= decay;
8457 }
8458 SizeUpdater_checkDestroy(particle, particle.size.value, minValue, maxValue);
8459 if (!particle.destroyed) {
8460 particle.size.value = clamp(particle.size.value, minValue, maxValue);
8461 }
8462}
8463class SizeUpdater {
8464 init(particle) {
8465 var _a;
8466 const container = particle.container,
8467 sizeOptions = particle.options.size,
8468 sizeAnimation = sizeOptions.animation;
8469 if (sizeAnimation.enable) {
8470 particle.size.velocity = ((_a = particle.retina.sizeAnimationSpeed) !== null && _a !== void 0 ? _a : container.retina.sizeAnimationSpeed) / 100 * container.retina.reduceFactor;
8471 if (!sizeAnimation.sync) {
8472 particle.size.velocity *= getRandom();
8473 }
8474 }
8475 }
8476 isEnabled(particle) {
8477 var _a, _b, _c, _d;
8478 return !particle.destroyed && !particle.spawning && particle.size.enable && (((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 || ((_b = particle.size.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.size.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.size.maxLoops) !== null && _d !== void 0 ? _d : 0));
8479 }
8480 reset(particle) {
8481 particle.size.loops = 0;
8482 }
8483 update(particle, delta) {
8484 if (!this.isEnabled(particle)) {
8485 return;
8486 }
8487 updateSize(particle, delta);
8488 }
8489}
8490;// CONCATENATED MODULE: ../../updaters/size/dist/esm/index.js
8491
8492async function loadSizeUpdater(engine) {
8493 await engine.addParticleUpdater("size", () => new SizeUpdater());
8494}
8495;// CONCATENATED MODULE: ../../shapes/square/dist/esm/SquareDrawer.js
8496const fixFactor = Math.sqrt(2);
8497class SquareDrawer {
8498 draw(context, particle, radius) {
8499 context.rect(-radius / fixFactor, -radius / fixFactor, radius * 2 / fixFactor, radius * 2 / fixFactor);
8500 }
8501 getSidesCount() {
8502 return 4;
8503 }
8504}
8505;// CONCATENATED MODULE: ../../shapes/square/dist/esm/index.js
8506
8507async function loadSquareShape(engine) {
8508 const drawer = new SquareDrawer();
8509 await engine.addShape(["edge", "square"], drawer);
8510}
8511;// CONCATENATED MODULE: ../../shapes/star/dist/esm/StarDrawer.js
8512
8513class StarDrawer {
8514 draw(context, particle, radius) {
8515 var _a;
8516 const sides = particle.sides,
8517 inset = (_a = particle.starInset) !== null && _a !== void 0 ? _a : 2;
8518 context.moveTo(0, 0 - radius);
8519 for (let i = 0; i < sides; i++) {
8520 context.rotate(Math.PI / sides);
8521 context.lineTo(0, 0 - radius * inset);
8522 context.rotate(Math.PI / sides);
8523 context.lineTo(0, 0 - radius);
8524 }
8525 }
8526 getSidesCount(particle) {
8527 var _a, _b;
8528 const star = particle.shapeData;
8529 return Math.round(getRangeValue((_b = (_a = star === null || star === void 0 ? void 0 : star.sides) !== null && _a !== void 0 ? _a : star === null || star === void 0 ? void 0 : star.nb_sides) !== null && _b !== void 0 ? _b : 5));
8530 }
8531 particleInit(container, particle) {
8532 var _a;
8533 const star = particle.shapeData,
8534 inset = getRangeValue((_a = star === null || star === void 0 ? void 0 : star.inset) !== null && _a !== void 0 ? _a : 2);
8535 particle.starInset = inset;
8536 }
8537}
8538;// CONCATENATED MODULE: ../../shapes/star/dist/esm/index.js
8539
8540async function loadStarShape(engine) {
8541 await engine.addShape("star", new StarDrawer());
8542}
8543;// CONCATENATED MODULE: ../../shapes/text/dist/esm/TextDrawer.js
8544
8545const validTypes = ["text", "character", "char"];
8546class TextDrawer {
8547 draw(context, particle, radius, opacity) {
8548 var _a, _b, _c;
8549 const character = particle.shapeData;
8550 if (character === undefined) {
8551 return;
8552 }
8553 const textData = character.value;
8554 if (textData === undefined) {
8555 return;
8556 }
8557 const textParticle = particle;
8558 if (textParticle.text === undefined) {
8559 textParticle.text = itemFromSingleOrMultiple(textData, particle.randomIndexData);
8560 }
8561 const text = textParticle.text,
8562 style = (_a = character.style) !== null && _a !== void 0 ? _a : "",
8563 weight = (_b = character.weight) !== null && _b !== void 0 ? _b : "400",
8564 size = Math.round(radius) * 2,
8565 font = (_c = character.font) !== null && _c !== void 0 ? _c : "Verdana",
8566 fill = particle.fill,
8567 offsetX = text.length * radius / 2;
8568 context.font = `${style} ${weight} ${size}px "${font}"`;
8569 const pos = {
8570 x: -offsetX,
8571 y: radius / 2
8572 };
8573 context.globalAlpha = opacity;
8574 if (fill) {
8575 context.fillText(text, pos.x, pos.y);
8576 } else {
8577 context.strokeText(text, pos.x, pos.y);
8578 }
8579 context.globalAlpha = 1;
8580 }
8581 getSidesCount() {
8582 return 12;
8583 }
8584 async init(container) {
8585 const options = container.actualOptions;
8586 if (validTypes.find(t => isInArray(t, options.particles.shape.type))) {
8587 const shapeOptions = validTypes.map(t => options.particles.shape.options[t]).find(t => !!t),
8588 promises = [];
8589 executeOnSingleOrMultiple(shapeOptions, shape => {
8590 promises.push(loadFont(shape.font, shape.weight));
8591 });
8592 await Promise.all(promises);
8593 }
8594 }
8595}
8596;// CONCATENATED MODULE: ../../shapes/text/dist/esm/index.js
8597
8598async function loadTextShape(engine) {
8599 await engine.addShape(validTypes, new TextDrawer());
8600}
8601;// CONCATENATED MODULE: ../../updaters/tilt/dist/esm/Options/Classes/TiltAnimation.js
8602
8603class TiltAnimation {
8604 constructor() {
8605 this.enable = false;
8606 this.speed = 0;
8607 this.decay = 0;
8608 this.sync = false;
8609 }
8610 load(data) {
8611 if (!data) {
8612 return;
8613 }
8614 if (data.enable !== undefined) {
8615 this.enable = data.enable;
8616 }
8617 if (data.speed !== undefined) {
8618 this.speed = setRangeValue(data.speed);
8619 }
8620 if (data.decay !== undefined) {
8621 this.decay = setRangeValue(data.decay);
8622 }
8623 if (data.sync !== undefined) {
8624 this.sync = data.sync;
8625 }
8626 }
8627}
8628;// CONCATENATED MODULE: ../../updaters/tilt/dist/esm/Options/Classes/Tilt.js
8629
8630
8631class Tilt extends ValueWithRandom {
8632 constructor() {
8633 super();
8634 this.animation = new TiltAnimation();
8635 this.direction = "clockwise";
8636 this.enable = false;
8637 this.value = 0;
8638 }
8639 load(data) {
8640 super.load(data);
8641 if (!data) {
8642 return;
8643 }
8644 this.animation.load(data.animation);
8645 if (data.direction !== undefined) {
8646 this.direction = data.direction;
8647 }
8648 if (data.enable !== undefined) {
8649 this.enable = data.enable;
8650 }
8651 }
8652}
8653;// CONCATENATED MODULE: ../../updaters/tilt/dist/esm/TiltUpdater.js
8654
8655
8656function updateTilt(particle, delta) {
8657 var _a, _b;
8658 if (!particle.tilt || !particle.options.tilt) {
8659 return;
8660 }
8661 const tilt = particle.options.tilt,
8662 tiltAnimation = tilt.animation,
8663 speed = ((_a = particle.tilt.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor,
8664 max = 2 * Math.PI,
8665 decay = (_b = particle.tilt.decay) !== null && _b !== void 0 ? _b : 1;
8666 if (!tiltAnimation.enable) {
8667 return;
8668 }
8669 switch (particle.tilt.status) {
8670 case "increasing":
8671 particle.tilt.value += speed;
8672 if (particle.tilt.value > max) {
8673 particle.tilt.value -= max;
8674 }
8675 break;
8676 case "decreasing":
8677 default:
8678 particle.tilt.value -= speed;
8679 if (particle.tilt.value < 0) {
8680 particle.tilt.value += max;
8681 }
8682 break;
8683 }
8684 if (particle.tilt.velocity && decay !== 1) {
8685 particle.tilt.velocity *= decay;
8686 }
8687}
8688class TiltUpdater {
8689 constructor(container) {
8690 this.container = container;
8691 }
8692 getTransformValues(particle) {
8693 var _a;
8694 const tilt = ((_a = particle.tilt) === null || _a === void 0 ? void 0 : _a.enable) && particle.tilt;
8695 return {
8696 b: tilt ? Math.cos(tilt.value) * tilt.cosDirection : undefined,
8697 c: tilt ? Math.sin(tilt.value) * tilt.sinDirection : undefined
8698 };
8699 }
8700 init(particle) {
8701 var _a;
8702 const tiltOptions = particle.options.tilt;
8703 if (!tiltOptions) {
8704 return;
8705 }
8706 particle.tilt = {
8707 enable: tiltOptions.enable,
8708 value: getRangeValue(tiltOptions.value) * Math.PI / 180,
8709 sinDirection: getRandom() >= 0.5 ? 1 : -1,
8710 cosDirection: getRandom() >= 0.5 ? 1 : -1
8711 };
8712 let tiltDirection = tiltOptions.direction;
8713 if (tiltDirection === "random") {
8714 const index = Math.floor(getRandom() * 2);
8715 tiltDirection = index > 0 ? "counter-clockwise" : "clockwise";
8716 }
8717 switch (tiltDirection) {
8718 case "counter-clockwise":
8719 case "counterClockwise":
8720 particle.tilt.status = "decreasing";
8721 break;
8722 case "clockwise":
8723 particle.tilt.status = "increasing";
8724 break;
8725 }
8726 const tiltAnimation = (_a = particle.options.tilt) === null || _a === void 0 ? void 0 : _a.animation;
8727 if (tiltAnimation === null || tiltAnimation === void 0 ? void 0 : tiltAnimation.enable) {
8728 particle.tilt.decay = 1 - getRangeValue(tiltAnimation.decay);
8729 particle.tilt.velocity = getRangeValue(tiltAnimation.speed) / 360 * this.container.retina.reduceFactor;
8730 if (!tiltAnimation.sync) {
8731 particle.tilt.velocity *= getRandom();
8732 }
8733 }
8734 }
8735 isEnabled(particle) {
8736 var _a;
8737 const tiltAnimation = (_a = particle.options.tilt) === null || _a === void 0 ? void 0 : _a.animation;
8738 return !particle.destroyed && !particle.spawning && !!(tiltAnimation === null || tiltAnimation === void 0 ? void 0 : tiltAnimation.enable);
8739 }
8740 loadOptions(options, ...sources) {
8741 if (!options.tilt) {
8742 options.tilt = new Tilt();
8743 }
8744 for (const source of sources) {
8745 options.tilt.load(source === null || source === void 0 ? void 0 : source.tilt);
8746 }
8747 }
8748 update(particle, delta) {
8749 if (!this.isEnabled(particle)) {
8750 return;
8751 }
8752 updateTilt(particle, delta);
8753 }
8754}
8755;// CONCATENATED MODULE: ../../updaters/tilt/dist/esm/index.js
8756
8757async function loadTiltUpdater(engine) {
8758 await engine.addParticleUpdater("tilt", container => new TiltUpdater(container));
8759}
8760;// CONCATENATED MODULE: ../../updaters/wobble/dist/esm/Options/Classes/WobbleSpeed.js
8761
8762class WobbleSpeed {
8763 constructor() {
8764 this.angle = 50;
8765 this.move = 10;
8766 }
8767 load(data) {
8768 if (!data) {
8769 return;
8770 }
8771 if (data.angle !== undefined) {
8772 this.angle = setRangeValue(data.angle);
8773 }
8774 if (data.move !== undefined) {
8775 this.move = setRangeValue(data.move);
8776 }
8777 }
8778}
8779;// CONCATENATED MODULE: ../../updaters/wobble/dist/esm/Options/Classes/Wobble.js
8780
8781
8782class Wobble {
8783 constructor() {
8784 this.distance = 5;
8785 this.enable = false;
8786 this.speed = new WobbleSpeed();
8787 }
8788 load(data) {
8789 if (!data) {
8790 return;
8791 }
8792 if (data.distance !== undefined) {
8793 this.distance = setRangeValue(data.distance);
8794 }
8795 if (data.enable !== undefined) {
8796 this.enable = data.enable;
8797 }
8798 if (data.speed !== undefined) {
8799 if (typeof data.speed === "number") {
8800 this.speed.load({
8801 angle: data.speed
8802 });
8803 } else {
8804 const rangeSpeed = data.speed;
8805 if (rangeSpeed.min !== undefined) {
8806 this.speed.load({
8807 angle: rangeSpeed
8808 });
8809 } else {
8810 this.speed.load(data.speed);
8811 }
8812 }
8813 }
8814 }
8815}
8816;// CONCATENATED MODULE: ../../updaters/wobble/dist/esm/WobbleUpdater.js
8817
8818
8819function updateWobble(particle, delta) {
8820 var _a;
8821 const wobble = particle.options.wobble;
8822 if (!(wobble === null || wobble === void 0 ? void 0 : wobble.enable) || !particle.wobble) {
8823 return;
8824 }
8825 const angleSpeed = particle.wobble.angleSpeed * delta.factor,
8826 moveSpeed = particle.wobble.moveSpeed * delta.factor,
8827 distance = moveSpeed * (((_a = particle.retina.wobbleDistance) !== null && _a !== void 0 ? _a : 0) * delta.factor) / (1000 / 60),
8828 max = 2 * Math.PI;
8829 particle.wobble.angle += angleSpeed;
8830 if (particle.wobble.angle > max) {
8831 particle.wobble.angle -= max;
8832 }
8833 particle.position.x += distance * Math.cos(particle.wobble.angle);
8834 particle.position.y += distance * Math.abs(Math.sin(particle.wobble.angle));
8835}
8836class WobbleUpdater {
8837 constructor(container) {
8838 this.container = container;
8839 }
8840 init(particle) {
8841 var _a;
8842 const wobbleOpt = particle.options.wobble;
8843 if (wobbleOpt === null || wobbleOpt === void 0 ? void 0 : wobbleOpt.enable) {
8844 particle.wobble = {
8845 angle: getRandom() * Math.PI * 2,
8846 angleSpeed: getRangeValue(wobbleOpt.speed.angle) / 360,
8847 moveSpeed: getRangeValue(wobbleOpt.speed.move) / 10
8848 };
8849 } else {
8850 particle.wobble = {
8851 angle: 0,
8852 angleSpeed: 0,
8853 moveSpeed: 0
8854 };
8855 }
8856 particle.retina.wobbleDistance = getRangeValue((_a = wobbleOpt === null || wobbleOpt === void 0 ? void 0 : wobbleOpt.distance) !== null && _a !== void 0 ? _a : 0) * this.container.retina.pixelRatio;
8857 }
8858 isEnabled(particle) {
8859 var _a;
8860 return !particle.destroyed && !particle.spawning && !!((_a = particle.options.wobble) === null || _a === void 0 ? void 0 : _a.enable);
8861 }
8862 loadOptions(options, ...sources) {
8863 if (!options.wobble) {
8864 options.wobble = new Wobble();
8865 }
8866 for (const source of sources) {
8867 options.wobble.load(source === null || source === void 0 ? void 0 : source.wobble);
8868 }
8869 }
8870 update(particle, delta) {
8871 if (!this.isEnabled(particle)) {
8872 return;
8873 }
8874 updateWobble(particle, delta);
8875 }
8876}
8877;// CONCATENATED MODULE: ../../updaters/wobble/dist/esm/index.js
8878
8879async function loadWobbleUpdater(engine) {
8880 await engine.addParticleUpdater("wobble", container => new WobbleUpdater(container));
8881}
8882;// CONCATENATED MODULE: ./dist/browser/confetti.js
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905let initialized = false;
8906let initializing = false;
8907const ids = new Map();
8908async function initPlugins() {
8909 if (initialized) {
8910 return;
8911 }
8912 if (initializing) {
8913 return new Promise(resolve => {
8914 const interval = setInterval(() => {
8915 if (initialized) {
8916 clearInterval(interval);
8917 resolve();
8918 }
8919 }, 100);
8920 });
8921 }
8922 initializing = true;
8923 await loadBaseMover(tsParticles);
8924 await loadEmittersPlugin(tsParticles);
8925 await loadMotionPlugin(tsParticles);
8926 await loadCardsShape(tsParticles);
8927 await loadCircleShape(tsParticles);
8928 await loadHeartShape(tsParticles);
8929 await loadImageShape(tsParticles);
8930 await loadPolygonShape(tsParticles);
8931 await loadSquareShape(tsParticles);
8932 await loadStarShape(tsParticles);
8933 await loadTextShape(tsParticles);
8934 await loadAngleUpdater(tsParticles);
8935 await loadColorUpdater(tsParticles);
8936 await loadLifeUpdater(tsParticles);
8937 await loadOpacityUpdater(tsParticles);
8938 await loadOutModesUpdater(tsParticles);
8939 await loadRollUpdater(tsParticles);
8940 await loadSizeUpdater(tsParticles);
8941 await loadTiltUpdater(tsParticles);
8942 await loadWobbleUpdater(tsParticles);
8943 initializing = false;
8944 initialized = true;
8945}
8946async function setConfetti(params) {
8947 const actualOptions = new ConfettiOptions();
8948 actualOptions.load(params.options);
8949 let container;
8950 if (ids.has(params.id)) {
8951 container = ids.get(params.id);
8952 if (container && !container.destroyed) {
8953 const alias = container;
8954 if (alias.addEmitter) {
8955 alias.addEmitter({
8956 startCount: actualOptions.count,
8957 position: actualOptions.position,
8958 size: {
8959 width: 0,
8960 height: 0
8961 },
8962 rate: {
8963 delay: 0,
8964 quantity: 0
8965 },
8966 life: {
8967 duration: 0.1,
8968 count: 1
8969 },
8970 particles: {
8971 color: {
8972 value: actualOptions.colors
8973 },
8974 shape: {
8975 type: actualOptions.shapes,
8976 options: actualOptions.shapeOptions
8977 },
8978 size: {
8979 value: 5 * actualOptions.scalar
8980 },
8981 life: {
8982 duration: {
8983 value: actualOptions.ticks / 60
8984 }
8985 },
8986 move: {
8987 angle: {
8988 value: actualOptions.spread,
8989 offset: 0
8990 },
8991 drift: {
8992 min: -actualOptions.drift,
8993 max: actualOptions.drift
8994 },
8995 gravity: {
8996 acceleration: actualOptions.gravity * 9.81
8997 },
8998 speed: actualOptions.startVelocity * 3,
8999 decay: 1 - actualOptions.decay,
9000 direction: -actualOptions.angle
9001 }
9002 }
9003 });
9004 return;
9005 }
9006 }
9007 }
9008 const particlesOptions = {
9009 fullScreen: {
9010 enable: !params.canvas,
9011 zIndex: actualOptions.zIndex
9012 },
9013 fpsLimit: 120,
9014 particles: {
9015 number: {
9016 value: 0
9017 },
9018 color: {
9019 value: actualOptions.colors
9020 },
9021 shape: {
9022 type: actualOptions.shapes,
9023 options: actualOptions.shapeOptions
9024 },
9025 opacity: {
9026 value: {
9027 min: 0,
9028 max: 1
9029 },
9030 animation: {
9031 enable: true,
9032 speed: 0.5,
9033 startValue: "max",
9034 destroy: "min"
9035 }
9036 },
9037 size: {
9038 value: 5 * actualOptions.scalar
9039 },
9040 links: {
9041 enable: false
9042 },
9043 life: {
9044 duration: {
9045 sync: true,
9046 value: actualOptions.ticks / 60
9047 },
9048 count: 1
9049 },
9050 move: {
9051 angle: {
9052 value: actualOptions.spread,
9053 offset: 0
9054 },
9055 drift: {
9056 min: -actualOptions.drift,
9057 max: actualOptions.drift
9058 },
9059 enable: true,
9060 gravity: {
9061 enable: true,
9062 acceleration: actualOptions.gravity * 9.81
9063 },
9064 speed: actualOptions.startVelocity * 3,
9065 decay: 1 - actualOptions.decay,
9066 direction: -actualOptions.angle,
9067 random: true,
9068 straight: false,
9069 outModes: {
9070 default: "none",
9071 bottom: "destroy"
9072 }
9073 },
9074 rotate: {
9075 value: {
9076 min: 0,
9077 max: 360
9078 },
9079 direction: "random",
9080 animation: {
9081 enable: true,
9082 speed: 60
9083 }
9084 },
9085 tilt: {
9086 direction: "random",
9087 enable: true,
9088 value: {
9089 min: 0,
9090 max: 360
9091 },
9092 animation: {
9093 enable: true,
9094 speed: 60
9095 }
9096 },
9097 roll: {
9098 darken: {
9099 enable: true,
9100 value: 25
9101 },
9102 enable: true,
9103 speed: {
9104 min: 15,
9105 max: 25
9106 }
9107 },
9108 wobble: {
9109 distance: 30,
9110 enable: true,
9111 speed: {
9112 min: -15,
9113 max: 15
9114 }
9115 }
9116 },
9117 detectRetina: true,
9118 motion: {
9119 disable: actualOptions.disableForReducedMotion
9120 },
9121 emitters: {
9122 name: "confetti",
9123 startCount: actualOptions.count,
9124 position: actualOptions.position,
9125 size: {
9126 width: 0,
9127 height: 0
9128 },
9129 rate: {
9130 delay: 0,
9131 quantity: 0
9132 },
9133 life: {
9134 duration: 0.1,
9135 count: 1
9136 }
9137 }
9138 };
9139 if (params.id) {
9140 container = await tsParticles.load(params.id, particlesOptions);
9141 } else if (params.canvas) {
9142 container = await tsParticles.set(params.id, params.canvas, particlesOptions);
9143 }
9144 ids.set(params.id, container);
9145 return container;
9146}
9147async function confetti(idOrOptions, confettiOptions) {
9148 await initPlugins();
9149 let options;
9150 let id;
9151 if (typeof idOrOptions === "string") {
9152 id = idOrOptions;
9153 options = confettiOptions !== null && confettiOptions !== void 0 ? confettiOptions : {};
9154 } else {
9155 id = "confetti";
9156 options = idOrOptions;
9157 }
9158 return setConfetti({
9159 id,
9160 options
9161 });
9162}
9163confetti.create = async (canvas, options) => {
9164 if (!canvas) {
9165 return confetti;
9166 }
9167 await initPlugins();
9168 const id = canvas.getAttribute("id") || "confetti";
9169 canvas.setAttribute("id", id);
9170 return async (idOrOptions, confettiOptions) => {
9171 let subOptions;
9172 let subId;
9173 if (typeof idOrOptions === "string") {
9174 subId = idOrOptions;
9175 subOptions = confettiOptions !== null && confettiOptions !== void 0 ? confettiOptions : options;
9176 } else {
9177 subId = id;
9178 subOptions = idOrOptions;
9179 }
9180 return setConfetti({
9181 id: subId,
9182 canvas,
9183 options: subOptions
9184 });
9185 };
9186};
9187;// CONCATENATED MODULE: ./dist/browser/index.js
9188
9189;// CONCATENATED MODULE: ./dist/browser/bundle.js
9190
9191
9192/******/ return __webpack_exports__;
9193/******/ })()
9194;
9195});
\No newline at end of file