UNPKG

165 kBJavaScriptView Raw
1/*!
2 * tsParticles Engine v2.8.0
3 * Author: Matteo Bruni
4 * MIT license: https://opensource.org/licenses/MIT
5 * Website: https://particles.js.org/
6 * Confetti Website: https://confetti.js.org
7 * GitHub: https://www.github.com/matteobruni/tsparticles
8 * How to use?: Check the GitHub README
9 * ------------------------------------------------------
10 */
11(function webpackUniversalModuleDefinition(root, factory) {
12 if(typeof exports === 'object' && typeof module === 'object')
13 module.exports = factory();
14 else if(typeof define === 'function' && define.amd)
15 define([], factory);
16 else {
17 var a = factory();
18 for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
19 }
20})(this, () => {
21return /******/ (() => { // webpackBootstrap
22/******/ "use strict";
23/******/ // The require scope
24/******/ var __webpack_require__ = {};
25/******/
26/************************************************************************/
27/******/ /* webpack/runtime/define property getters */
28/******/ (() => {
29/******/ // define getter functions for harmony exports
30/******/ __webpack_require__.d = (exports, definition) => {
31/******/ for(var key in definition) {
32/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
33/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
34/******/ }
35/******/ }
36/******/ };
37/******/ })();
38/******/
39/******/ /* webpack/runtime/hasOwnProperty shorthand */
40/******/ (() => {
41/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
42/******/ })();
43/******/
44/******/ /* webpack/runtime/make namespace object */
45/******/ (() => {
46/******/ // define __esModule on exports
47/******/ __webpack_require__.r = (exports) => {
48/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
49/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
50/******/ }
51/******/ Object.defineProperty(exports, '__esModule', { value: true });
52/******/ };
53/******/ })();
54/******/
55/************************************************************************/
56var __webpack_exports__ = {};
57// ESM COMPAT FLAG
58__webpack_require__.r(__webpack_exports__);
59
60// EXPORTS
61__webpack_require__.d(__webpack_exports__, {
62 "AnimatableColor": () => (/* reexport */ AnimatableColor),
63 "AnimationOptions": () => (/* reexport */ AnimationOptions),
64 "Background": () => (/* reexport */ Background),
65 "BackgroundMask": () => (/* reexport */ BackgroundMask),
66 "BackgroundMaskCover": () => (/* reexport */ BackgroundMaskCover),
67 "Circle": () => (/* reexport */ Circle),
68 "ClickEvent": () => (/* reexport */ ClickEvent),
69 "Collisions": () => (/* reexport */ Collisions),
70 "CollisionsAbsorb": () => (/* reexport */ CollisionsAbsorb),
71 "CollisionsOverlap": () => (/* reexport */ CollisionsOverlap),
72 "ColorAnimation": () => (/* reexport */ ColorAnimation),
73 "DivEvent": () => (/* reexport */ DivEvent),
74 "Events": () => (/* reexport */ Events),
75 "ExternalInteractorBase": () => (/* reexport */ ExternalInteractorBase),
76 "FullScreen": () => (/* reexport */ FullScreen),
77 "HoverEvent": () => (/* reexport */ HoverEvent),
78 "HslAnimation": () => (/* reexport */ HslAnimation),
79 "HslColorManager": () => (/* reexport */ HslColorManager),
80 "Interactivity": () => (/* reexport */ Interactivity),
81 "ManualParticle": () => (/* reexport */ ManualParticle),
82 "Modes": () => (/* reexport */ Modes),
83 "Move": () => (/* reexport */ Move),
84 "MoveAngle": () => (/* reexport */ MoveAngle),
85 "MoveAttract": () => (/* reexport */ MoveAttract),
86 "MoveCenter": () => (/* reexport */ MoveCenter),
87 "MoveGravity": () => (/* reexport */ MoveGravity),
88 "MovePath": () => (/* reexport */ MovePath),
89 "MoveTrail": () => (/* reexport */ MoveTrail),
90 "Opacity": () => (/* reexport */ Opacity),
91 "OpacityAnimation": () => (/* reexport */ OpacityAnimation),
92 "Options": () => (/* reexport */ Options),
93 "OptionsColor": () => (/* reexport */ OptionsColor),
94 "OutModes": () => (/* reexport */ OutModes),
95 "Parallax": () => (/* reexport */ Parallax),
96 "ParticlesBounce": () => (/* reexport */ ParticlesBounce),
97 "ParticlesBounceFactor": () => (/* reexport */ ParticlesBounceFactor),
98 "ParticlesDensity": () => (/* reexport */ ParticlesDensity),
99 "ParticlesInteractorBase": () => (/* reexport */ ParticlesInteractorBase),
100 "ParticlesNumber": () => (/* reexport */ ParticlesNumber),
101 "ParticlesOptions": () => (/* reexport */ ParticlesOptions),
102 "Point": () => (/* reexport */ Point),
103 "Range": () => (/* reexport */ Range),
104 "Rectangle": () => (/* reexport */ Rectangle),
105 "ResizeEvent": () => (/* reexport */ ResizeEvent),
106 "Responsive": () => (/* reexport */ Responsive),
107 "RgbColorManager": () => (/* reexport */ RgbColorManager),
108 "Shadow": () => (/* reexport */ Shadow),
109 "Shape": () => (/* reexport */ Shape),
110 "Size": () => (/* reexport */ Size),
111 "SizeAnimation": () => (/* reexport */ SizeAnimation),
112 "Spin": () => (/* reexport */ Spin),
113 "Stroke": () => (/* reexport */ Stroke),
114 "Theme": () => (/* reexport */ Theme),
115 "ThemeDefault": () => (/* reexport */ ThemeDefault),
116 "ValueWithRandom": () => (/* reexport */ ValueWithRandom),
117 "Vector": () => (/* reexport */ Vector),
118 "Vector3d": () => (/* reexport */ Vector3d),
119 "ZIndex": () => (/* reexport */ ZIndex),
120 "addColorManager": () => (/* reexport */ addColorManager),
121 "addEasing": () => (/* reexport */ addEasing),
122 "alterHsl": () => (/* reexport */ alterHsl),
123 "animate": () => (/* reexport */ animate),
124 "areBoundsInside": () => (/* reexport */ areBoundsInside),
125 "arrayRandomIndex": () => (/* reexport */ arrayRandomIndex),
126 "calcExactPositionOrRandomFromSize": () => (/* reexport */ calcExactPositionOrRandomFromSize),
127 "calcExactPositionOrRandomFromSizeRanged": () => (/* reexport */ calcExactPositionOrRandomFromSizeRanged),
128 "calcPositionFromSize": () => (/* reexport */ calcPositionFromSize),
129 "calcPositionOrRandomFromSize": () => (/* reexport */ calcPositionOrRandomFromSize),
130 "calcPositionOrRandomFromSizeRanged": () => (/* reexport */ calcPositionOrRandomFromSizeRanged),
131 "calculateBounds": () => (/* reexport */ calculateBounds),
132 "cancelAnimation": () => (/* reexport */ cancelAnimation),
133 "circleBounce": () => (/* reexport */ circleBounce),
134 "circleBounceDataFromParticle": () => (/* reexport */ circleBounceDataFromParticle),
135 "clamp": () => (/* reexport */ clamp),
136 "clear": () => (/* reexport */ clear),
137 "collisionVelocity": () => (/* reexport */ collisionVelocity),
138 "colorMix": () => (/* reexport */ colorMix),
139 "colorToHsl": () => (/* reexport */ colorToHsl),
140 "colorToRgb": () => (/* reexport */ colorToRgb),
141 "deepExtend": () => (/* reexport */ deepExtend),
142 "divMode": () => (/* reexport */ divMode),
143 "divModeExecute": () => (/* reexport */ divModeExecute),
144 "drawLine": () => (/* reexport */ drawLine),
145 "drawParticle": () => (/* reexport */ drawParticle),
146 "drawParticlePlugin": () => (/* reexport */ drawParticlePlugin),
147 "drawPlugin": () => (/* reexport */ drawPlugin),
148 "drawShape": () => (/* reexport */ drawShape),
149 "drawShapeAfterEffect": () => (/* reexport */ drawShapeAfterEffect),
150 "drawTriangle": () => (/* reexport */ drawTriangle),
151 "executeOnSingleOrMultiple": () => (/* reexport */ executeOnSingleOrMultiple),
152 "findItemFromSingleOrMultiple": () => (/* reexport */ findItemFromSingleOrMultiple),
153 "generatedAttribute": () => (/* reexport */ generatedAttribute),
154 "getDistance": () => (/* reexport */ getDistance),
155 "getDistances": () => (/* reexport */ getDistances),
156 "getEasing": () => (/* reexport */ getEasing),
157 "getHslAnimationFromHsl": () => (/* reexport */ getHslAnimationFromHsl),
158 "getHslFromAnimation": () => (/* reexport */ getHslFromAnimation),
159 "getLinkColor": () => (/* reexport */ getLinkColor),
160 "getLinkRandomColor": () => (/* reexport */ getLinkRandomColor),
161 "getParticleBaseVelocity": () => (/* reexport */ getParticleBaseVelocity),
162 "getParticleDirectionAngle": () => (/* reexport */ getParticleDirectionAngle),
163 "getRandom": () => (/* reexport */ getRandom),
164 "getRandomRgbColor": () => (/* reexport */ getRandomRgbColor),
165 "getRangeMax": () => (/* reexport */ getRangeMax),
166 "getRangeMin": () => (/* reexport */ getRangeMin),
167 "getRangeValue": () => (/* reexport */ getRangeValue),
168 "getStyleFromHsl": () => (/* reexport */ getStyleFromHsl),
169 "getStyleFromRgb": () => (/* reexport */ getStyleFromRgb),
170 "getValue": () => (/* reexport */ getValue),
171 "hasMatchMedia": () => (/* reexport */ hasMatchMedia),
172 "hslToRgb": () => (/* reexport */ hslToRgb),
173 "hslaToRgba": () => (/* reexport */ hslaToRgba),
174 "isDivModeEnabled": () => (/* reexport */ isDivModeEnabled),
175 "isInArray": () => (/* reexport */ isInArray),
176 "isPointInside": () => (/* reexport */ isPointInside),
177 "isSsr": () => (/* reexport */ isSsr),
178 "itemFromArray": () => (/* reexport */ itemFromArray),
179 "itemFromSingleOrMultiple": () => (/* reexport */ itemFromSingleOrMultiple),
180 "loadFont": () => (/* reexport */ loadFont),
181 "loadOptions": () => (/* reexport */ loadOptions),
182 "loadParticlesOptions": () => (/* reexport */ loadParticlesOptions),
183 "mix": () => (/* reexport */ mix),
184 "mouseDownEvent": () => (/* reexport */ mouseDownEvent),
185 "mouseLeaveEvent": () => (/* reexport */ mouseLeaveEvent),
186 "mouseMoveEvent": () => (/* reexport */ mouseMoveEvent),
187 "mouseOutEvent": () => (/* reexport */ mouseOutEvent),
188 "mouseUpEvent": () => (/* reexport */ mouseUpEvent),
189 "paintBase": () => (/* reexport */ paintBase),
190 "paintImage": () => (/* reexport */ paintImage),
191 "parseAlpha": () => (/* reexport */ parseAlpha),
192 "randomInRange": () => (/* reexport */ randomInRange),
193 "rangeColorToHsl": () => (/* reexport */ rangeColorToHsl),
194 "rangeColorToRgb": () => (/* reexport */ rangeColorToRgb),
195 "rectBounce": () => (/* reexport */ rectBounce),
196 "resizeEvent": () => (/* reexport */ resizeEvent),
197 "rgbToHsl": () => (/* reexport */ rgbToHsl),
198 "safeMatchMedia": () => (/* reexport */ safeMatchMedia),
199 "setRandom": () => (/* reexport */ setRandom),
200 "setRangeValue": () => (/* reexport */ setRangeValue),
201 "singleDivModeExecute": () => (/* reexport */ singleDivModeExecute),
202 "stringToAlpha": () => (/* reexport */ stringToAlpha),
203 "stringToRgb": () => (/* reexport */ stringToRgb),
204 "touchCancelEvent": () => (/* reexport */ touchCancelEvent),
205 "touchEndEvent": () => (/* reexport */ touchEndEvent),
206 "touchMoveEvent": () => (/* reexport */ touchMoveEvent),
207 "touchStartEvent": () => (/* reexport */ touchStartEvent),
208 "tsParticles": () => (/* binding */ tsParticles),
209 "visibilityChangeEvent": () => (/* reexport */ visibilityChangeEvent)
210});
211
212;// CONCATENATED MODULE: ./dist/browser/Utils/EventDispatcher.js
213class EventDispatcher {
214 constructor() {
215 this._listeners = new Map();
216 }
217 addEventListener(type, listener) {
218 var _a;
219 this.removeEventListener(type, listener);
220 if (!this._listeners.get(type)) {
221 this._listeners.set(type, []);
222 }
223 (_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.push(listener);
224 }
225 dispatchEvent(type, args) {
226 var _a;
227 (_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(handler => handler(args));
228 }
229 hasEventListener(type) {
230 return !!this._listeners.get(type);
231 }
232 removeAllEventListeners(type) {
233 if (!type) {
234 this._listeners = new Map();
235 } else {
236 this._listeners.delete(type);
237 }
238 }
239 removeEventListener(type, listener) {
240 const arr = this._listeners.get(type);
241 if (!arr) {
242 return;
243 }
244 const length = arr.length,
245 idx = arr.indexOf(listener);
246 if (idx < 0) {
247 return;
248 }
249 if (length === 1) {
250 this._listeners.delete(type);
251 } else {
252 arr.splice(idx, 1);
253 }
254 }
255}
256;// CONCATENATED MODULE: ./dist/browser/Core/Utils/Vector3d.js
257class Vector3d {
258 constructor(xOrCoords, y, z) {
259 if (typeof xOrCoords !== "number" && xOrCoords) {
260 this.x = xOrCoords.x;
261 this.y = xOrCoords.y;
262 const coords3d = xOrCoords;
263 this.z = coords3d.z ? coords3d.z : 0;
264 } else if (xOrCoords !== undefined && y !== undefined) {
265 this.x = xOrCoords;
266 this.y = y;
267 this.z = z !== null && z !== void 0 ? z : 0;
268 } else {
269 throw new Error("tsParticles - Vector3d not initialized correctly");
270 }
271 }
272 static get origin() {
273 return Vector3d.create(0, 0, 0);
274 }
275 get angle() {
276 return Math.atan2(this.y, this.x);
277 }
278 set angle(angle) {
279 this.updateFromAngle(angle, this.length);
280 }
281 get length() {
282 return Math.sqrt(this.getLengthSq());
283 }
284 set length(length) {
285 this.updateFromAngle(this.angle, length);
286 }
287 static clone(source) {
288 return Vector3d.create(source.x, source.y, source.z);
289 }
290 static create(x, y, z) {
291 return new Vector3d(x, y, z);
292 }
293 add(v) {
294 return Vector3d.create(this.x + v.x, this.y + v.y, this.z + v.z);
295 }
296 addTo(v) {
297 this.x += v.x;
298 this.y += v.y;
299 this.z += v.z;
300 }
301 copy() {
302 return Vector3d.clone(this);
303 }
304 distanceTo(v) {
305 return this.sub(v).length;
306 }
307 distanceToSq(v) {
308 return this.sub(v).getLengthSq();
309 }
310 div(n) {
311 return Vector3d.create(this.x / n, this.y / n, this.z / n);
312 }
313 divTo(n) {
314 this.x /= n;
315 this.y /= n;
316 this.z /= n;
317 }
318 getLengthSq() {
319 return this.x ** 2 + this.y ** 2;
320 }
321 mult(n) {
322 return Vector3d.create(this.x * n, this.y * n, this.z * n);
323 }
324 multTo(n) {
325 this.x *= n;
326 this.y *= n;
327 this.z *= n;
328 }
329 rotate(angle) {
330 return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), 0);
331 }
332 setTo(c) {
333 this.x = c.x;
334 this.y = c.y;
335 const v3d = c;
336 this.z = v3d.z ? v3d.z : 0;
337 }
338 sub(v) {
339 return Vector3d.create(this.x - v.x, this.y - v.y, this.z - v.z);
340 }
341 subFrom(v) {
342 this.x -= v.x;
343 this.y -= v.y;
344 this.z -= v.z;
345 }
346 updateFromAngle(angle, length) {
347 this.x = Math.cos(angle) * length;
348 this.y = Math.sin(angle) * length;
349 }
350}
351;// CONCATENATED MODULE: ./dist/browser/Core/Utils/Vector.js
352
353class Vector extends Vector3d {
354 constructor(xOrCoords, y) {
355 super(xOrCoords, y, 0);
356 }
357 static get origin() {
358 return Vector.create(0, 0);
359 }
360 static clone(source) {
361 return Vector.create(source.x, source.y);
362 }
363 static create(x, y) {
364 return new Vector(x, y);
365 }
366}
367;// CONCATENATED MODULE: ./dist/browser/Utils/NumberUtils.js
368
369let _random = Math.random;
370const easings = new Map();
371function addEasing(name, easing) {
372 if (!easings.get(name)) {
373 easings.set(name, easing);
374 }
375}
376function getEasing(name) {
377 return easings.get(name) || (value => value);
378}
379function setRandom(rnd = Math.random) {
380 _random = rnd;
381}
382function getRandom() {
383 return clamp(_random(), 0, 1 - 1e-16);
384}
385function clamp(num, min, max) {
386 return Math.min(Math.max(num, min), max);
387}
388function mix(comp1, comp2, weight1, weight2) {
389 return Math.floor((comp1 * weight1 + comp2 * weight2) / (weight1 + weight2));
390}
391function randomInRange(r) {
392 const max = getRangeMax(r);
393 let min = getRangeMin(r);
394 if (max === min) {
395 min = 0;
396 }
397 return getRandom() * (max - min) + min;
398}
399function getRangeValue(value) {
400 return typeof value === "number" ? value : randomInRange(value);
401}
402function getRangeMin(value) {
403 return typeof value === "number" ? value : value.min;
404}
405function getRangeMax(value) {
406 return typeof value === "number" ? value : value.max;
407}
408function setRangeValue(source, value) {
409 if (source === value || value === undefined && typeof source === "number") {
410 return source;
411 }
412 const min = getRangeMin(source),
413 max = getRangeMax(source);
414 return value !== undefined ? {
415 min: Math.min(min, value),
416 max: Math.max(max, value)
417 } : setRangeValue(min, max);
418}
419function getValue(options) {
420 const random = options.random,
421 {
422 enable,
423 minimumValue
424 } = typeof random === "boolean" ? {
425 enable: random,
426 minimumValue: 0
427 } : random;
428 return enable ? getRangeValue(setRangeValue(options.value, minimumValue)) : getRangeValue(options.value);
429}
430function getDistances(pointA, pointB) {
431 const dx = pointA.x - pointB.x,
432 dy = pointA.y - pointB.y;
433 return {
434 dx: dx,
435 dy: dy,
436 distance: Math.sqrt(dx ** 2 + dy ** 2)
437 };
438}
439function getDistance(pointA, pointB) {
440 return getDistances(pointA, pointB).distance;
441}
442function getParticleDirectionAngle(direction, position, center) {
443 if (typeof direction === "number") {
444 return direction * Math.PI / 180;
445 } else {
446 switch (direction) {
447 case "top":
448 return -Math.PI / 2;
449 case "top-right":
450 return -Math.PI / 4;
451 case "right":
452 return 0;
453 case "bottom-right":
454 return Math.PI / 4;
455 case "bottom":
456 return Math.PI / 2;
457 case "bottom-left":
458 return 3 * Math.PI / 4;
459 case "left":
460 return Math.PI;
461 case "top-left":
462 return -3 * Math.PI / 4;
463 case "inside":
464 return Math.atan2(center.y - position.y, center.x - position.x);
465 case "outside":
466 return Math.atan2(position.y - center.y, position.x - center.x);
467 default:
468 return getRandom() * Math.PI * 2;
469 }
470 }
471}
472function getParticleBaseVelocity(direction) {
473 const baseVelocity = Vector.origin;
474 baseVelocity.length = 1;
475 baseVelocity.angle = direction;
476 return baseVelocity;
477}
478function collisionVelocity(v1, v2, m1, m2) {
479 return Vector.create(v1.x * (m1 - m2) / (m1 + m2) + v2.x * 2 * m2 / (m1 + m2), v1.y);
480}
481function calcPositionFromSize(data) {
482 return data.position && data.position.x !== undefined && data.position.y !== undefined ? {
483 x: data.position.x * data.size.width / 100,
484 y: data.position.y * data.size.height / 100
485 } : undefined;
486}
487function calcPositionOrRandomFromSize(data) {
488 var _a, _b, _c, _d;
489 return {
490 x: ((_b = (_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : getRandom() * 100) * data.size.width / 100,
491 y: ((_d = (_c = data.position) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : getRandom() * 100) * data.size.height / 100
492 };
493}
494function calcPositionOrRandomFromSizeRanged(data) {
495 var _a, _b;
496 const position = {
497 x: ((_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== undefined ? getRangeValue(data.position.x) : undefined,
498 y: ((_b = data.position) === null || _b === void 0 ? void 0 : _b.y) !== undefined ? getRangeValue(data.position.y) : undefined
499 };
500 return calcPositionOrRandomFromSize({
501 size: data.size,
502 position
503 });
504}
505function calcExactPositionOrRandomFromSize(data) {
506 var _a, _b, _c, _d;
507 return {
508 x: (_b = (_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : getRandom() * data.size.width,
509 y: (_d = (_c = data.position) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : getRandom() * data.size.height
510 };
511}
512function calcExactPositionOrRandomFromSizeRanged(data) {
513 var _a, _b;
514 const position = {
515 x: ((_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== undefined ? getRangeValue(data.position.x) : undefined,
516 y: ((_b = data.position) === null || _b === void 0 ? void 0 : _b.y) !== undefined ? getRangeValue(data.position.y) : undefined
517 };
518 return calcExactPositionOrRandomFromSize({
519 size: data.size,
520 position
521 });
522}
523function parseAlpha(input) {
524 return input ? input.endsWith("%") ? parseFloat(input) / 100 : parseFloat(input) : 1;
525}
526;// CONCATENATED MODULE: ./dist/browser/Utils/Utils.js
527
528
529function rectSideBounce(pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor) {
530 const res = {
531 bounced: false
532 };
533 if (pOtherSide.min < rectOtherSide.min || pOtherSide.min > rectOtherSide.max || pOtherSide.max < rectOtherSide.min || pOtherSide.max > rectOtherSide.max) {
534 return res;
535 }
536 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) {
537 res.velocity = velocity * -factor;
538 res.bounced = true;
539 }
540 return res;
541}
542function checkSelector(element, selectors) {
543 const res = executeOnSingleOrMultiple(selectors, selector => {
544 return element.matches(selector);
545 });
546 return res instanceof Array ? res.some(t => t) : res;
547}
548function isSsr() {
549 return typeof window === "undefined" || !window || typeof window.document === "undefined" || !window.document;
550}
551function hasMatchMedia() {
552 return !isSsr() && typeof matchMedia !== "undefined";
553}
554function safeMatchMedia(query) {
555 if (!hasMatchMedia()) {
556 return;
557 }
558 return matchMedia(query);
559}
560function animate() {
561 return isSsr() ? callback => setTimeout(callback) : callback => (requestAnimationFrame || setTimeout)(callback);
562}
563function cancelAnimation() {
564 return isSsr() ? handle => clearTimeout(handle) : handle => (cancelAnimationFrame || clearTimeout)(handle);
565}
566function isInArray(value, array) {
567 return value === array || array instanceof Array && array.indexOf(value) > -1;
568}
569async function loadFont(font, weight) {
570 try {
571 await document.fonts.load(`${weight !== null && weight !== void 0 ? weight : "400"} 36px '${font !== null && font !== void 0 ? font : "Verdana"}'`);
572 } catch (_a) {}
573}
574function arrayRandomIndex(array) {
575 return Math.floor(getRandom() * array.length);
576}
577function itemFromArray(array, index, useIndex = true) {
578 return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
579}
580function isPointInside(point, size, offset, radius, direction) {
581 return areBoundsInside(calculateBounds(point, radius !== null && radius !== void 0 ? radius : 0), size, offset, direction);
582}
583function areBoundsInside(bounds, size, offset, direction) {
584 let inside = true;
585 if (!direction || direction === "bottom") {
586 inside = bounds.top < size.height + offset.x;
587 }
588 if (inside && (!direction || direction === "left")) {
589 inside = bounds.right > offset.x;
590 }
591 if (inside && (!direction || direction === "right")) {
592 inside = bounds.left < size.width + offset.y;
593 }
594 if (inside && (!direction || direction === "top")) {
595 inside = bounds.bottom > offset.y;
596 }
597 return inside;
598}
599function calculateBounds(point, radius) {
600 return {
601 bottom: point.y + radius,
602 left: point.x - radius,
603 right: point.x + radius,
604 top: point.y - radius
605 };
606}
607function deepExtend(destination, ...sources) {
608 for (const source of sources) {
609 if (source === undefined || source === null) {
610 continue;
611 }
612 if (typeof source !== "object") {
613 destination = source;
614 continue;
615 }
616 const sourceIsArray = Array.isArray(source);
617 if (sourceIsArray && (typeof destination !== "object" || !destination || !Array.isArray(destination))) {
618 destination = [];
619 } else if (!sourceIsArray && (typeof destination !== "object" || !destination || Array.isArray(destination))) {
620 destination = {};
621 }
622 for (const key in source) {
623 if (key === "__proto__") {
624 continue;
625 }
626 const sourceDict = source,
627 value = sourceDict[key],
628 isObject = typeof value === "object",
629 destDict = destination;
630 destDict[key] = isObject && Array.isArray(value) ? value.map(v => deepExtend(destDict[key], v)) : deepExtend(destDict[key], value);
631 }
632 }
633 return destination;
634}
635function isDivModeEnabled(mode, divs) {
636 return !!findItemFromSingleOrMultiple(divs, t => t.enable && isInArray(mode, t.mode));
637}
638function divModeExecute(mode, divs, callback) {
639 executeOnSingleOrMultiple(divs, div => {
640 const divMode = div.mode,
641 divEnabled = div.enable;
642 if (divEnabled && isInArray(mode, divMode)) {
643 singleDivModeExecute(div, callback);
644 }
645 });
646}
647function singleDivModeExecute(div, callback) {
648 const selectors = div.selectors;
649 executeOnSingleOrMultiple(selectors, selector => {
650 callback(selector, div);
651 });
652}
653function divMode(divs, element) {
654 if (!element || !divs) {
655 return;
656 }
657 return findItemFromSingleOrMultiple(divs, div => {
658 return checkSelector(element, div.selectors);
659 });
660}
661function circleBounceDataFromParticle(p) {
662 return {
663 position: p.getPosition(),
664 radius: p.getRadius(),
665 mass: p.getMass(),
666 velocity: p.velocity,
667 factor: Vector.create(getValue(p.options.bounce.horizontal), getValue(p.options.bounce.vertical))
668 };
669}
670function circleBounce(p1, p2) {
671 const {
672 x: xVelocityDiff,
673 y: yVelocityDiff
674 } = p1.velocity.sub(p2.velocity),
675 [pos1, pos2] = [p1.position, p2.position],
676 {
677 dx: xDist,
678 dy: yDist
679 } = getDistances(pos2, pos1);
680 if (xVelocityDiff * xDist + yVelocityDiff * yDist < 0) {
681 return;
682 }
683 const angle = -Math.atan2(yDist, xDist),
684 m1 = p1.mass,
685 m2 = p2.mass,
686 u1 = p1.velocity.rotate(angle),
687 u2 = p2.velocity.rotate(angle),
688 v1 = collisionVelocity(u1, u2, m1, m2),
689 v2 = collisionVelocity(u2, u1, m1, m2),
690 vFinal1 = v1.rotate(-angle),
691 vFinal2 = v2.rotate(-angle);
692 p1.velocity.x = vFinal1.x * p1.factor.x;
693 p1.velocity.y = vFinal1.y * p1.factor.y;
694 p2.velocity.x = vFinal2.x * p2.factor.x;
695 p2.velocity.y = vFinal2.y * p2.factor.y;
696}
697function rectBounce(particle, divBounds) {
698 const pPos = particle.getPosition(),
699 size = particle.getRadius(),
700 bounds = calculateBounds(pPos, size),
701 resH = rectSideBounce({
702 min: bounds.left,
703 max: bounds.right
704 }, {
705 min: bounds.top,
706 max: bounds.bottom
707 }, {
708 min: divBounds.left,
709 max: divBounds.right
710 }, {
711 min: divBounds.top,
712 max: divBounds.bottom
713 }, particle.velocity.x, getValue(particle.options.bounce.horizontal));
714 if (resH.bounced) {
715 if (resH.velocity !== undefined) {
716 particle.velocity.x = resH.velocity;
717 }
718 if (resH.position !== undefined) {
719 particle.position.x = resH.position;
720 }
721 }
722 const resV = rectSideBounce({
723 min: bounds.top,
724 max: bounds.bottom
725 }, {
726 min: bounds.left,
727 max: bounds.right
728 }, {
729 min: divBounds.top,
730 max: divBounds.bottom
731 }, {
732 min: divBounds.left,
733 max: divBounds.right
734 }, particle.velocity.y, getValue(particle.options.bounce.vertical));
735 if (resV.bounced) {
736 if (resV.velocity !== undefined) {
737 particle.velocity.y = resV.velocity;
738 }
739 if (resV.position !== undefined) {
740 particle.position.y = resV.position;
741 }
742 }
743}
744function executeOnSingleOrMultiple(obj, callback) {
745 return obj instanceof Array ? obj.map((item, index) => callback(item, index)) : callback(obj, 0);
746}
747function itemFromSingleOrMultiple(obj, index, useIndex) {
748 return obj instanceof Array ? itemFromArray(obj, index, useIndex) : obj;
749}
750function findItemFromSingleOrMultiple(obj, callback) {
751 return obj instanceof Array ? obj.find((t, index) => callback(t, index)) : callback(obj, 0) ? obj : undefined;
752}
753;// CONCATENATED MODULE: ./dist/browser/Utils/ColorUtils.js
754
755
756const randomColorValue = "random",
757 midColorValue = "mid",
758 colorManagers = new Map();
759function addColorManager(manager) {
760 colorManagers.set(manager.key, manager);
761}
762function hue2rgb(p, q, t) {
763 if (t < 0) {
764 t += 1;
765 }
766 if (t > 1) {
767 t -= 1;
768 }
769 if (t < 1 / 6) {
770 return p + (q - p) * 6 * t;
771 }
772 if (t < 1 / 2) {
773 return q;
774 }
775 if (t < 2 / 3) {
776 return p + (q - p) * (2 / 3 - t) * 6;
777 }
778 return p;
779}
780function stringToRgba(input) {
781 for (const [, manager] of colorManagers) {
782 if (input.startsWith(manager.stringPrefix)) {
783 return manager.parseString(input);
784 }
785 }
786 const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i,
787 hexFixed = input.replace(shorthandRegex, (_, r, g, b, a) => {
788 return r + r + g + g + b + b + (a !== undefined ? a + a : "");
789 }),
790 regex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i,
791 result = regex.exec(hexFixed);
792 return result ? {
793 a: result[4] !== undefined ? parseInt(result[4], 16) / 0xff : 1,
794 b: parseInt(result[3], 16),
795 g: parseInt(result[2], 16),
796 r: parseInt(result[1], 16)
797 } : undefined;
798}
799function rangeColorToRgb(input, index, useIndex = true) {
800 if (!input) {
801 return;
802 }
803 const color = typeof input === "string" ? {
804 value: input
805 } : input;
806 if (typeof color.value === "string") {
807 return colorToRgb(color.value, index, useIndex);
808 }
809 if (color.value instanceof Array) {
810 return rangeColorToRgb({
811 value: itemFromArray(color.value, index, useIndex)
812 });
813 }
814 for (const [, manager] of colorManagers) {
815 const res = manager.handleRangeColor(color);
816 if (res) {
817 return res;
818 }
819 }
820}
821function colorToRgb(input, index, useIndex = true) {
822 if (!input) {
823 return;
824 }
825 const color = typeof input === "string" ? {
826 value: input
827 } : input;
828 if (typeof color.value === "string") {
829 return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(color.value);
830 }
831 if (color.value instanceof Array) {
832 return colorToRgb({
833 value: itemFromArray(color.value, index, useIndex)
834 });
835 }
836 for (const [, manager] of colorManagers) {
837 const res = manager.handleColor(color);
838 if (res) {
839 return res;
840 }
841 }
842}
843function colorToHsl(color, index, useIndex = true) {
844 const rgb = colorToRgb(color, index, useIndex);
845 return rgb ? rgbToHsl(rgb) : undefined;
846}
847function rangeColorToHsl(color, index, useIndex = true) {
848 const rgb = rangeColorToRgb(color, index, useIndex);
849 return rgb ? rgbToHsl(rgb) : undefined;
850}
851function rgbToHsl(color) {
852 const r1 = color.r / 255,
853 g1 = color.g / 255,
854 b1 = color.b / 255,
855 max = Math.max(r1, g1, b1),
856 min = Math.min(r1, g1, b1),
857 res = {
858 h: 0,
859 l: (max + min) / 2,
860 s: 0
861 };
862 if (max !== min) {
863 res.s = res.l < 0.5 ? (max - min) / (max + min) : (max - min) / (2.0 - max - min);
864 res.h = r1 === max ? (g1 - b1) / (max - min) : res.h = g1 === max ? 2.0 + (b1 - r1) / (max - min) : 4.0 + (r1 - g1) / (max - min);
865 }
866 res.l *= 100;
867 res.s *= 100;
868 res.h *= 60;
869 if (res.h < 0) {
870 res.h += 360;
871 }
872 if (res.h >= 360) {
873 res.h -= 360;
874 }
875 return res;
876}
877function stringToAlpha(input) {
878 var _a;
879 return (_a = stringToRgba(input)) === null || _a === void 0 ? void 0 : _a.a;
880}
881function stringToRgb(input) {
882 return stringToRgba(input);
883}
884function hslToRgb(hsl) {
885 const result = {
886 b: 0,
887 g: 0,
888 r: 0
889 },
890 hslPercent = {
891 h: hsl.h / 360,
892 l: hsl.l / 100,
893 s: hsl.s / 100
894 };
895 if (!hslPercent.s) {
896 result.b = hslPercent.l;
897 result.g = hslPercent.l;
898 result.r = hslPercent.l;
899 } else {
900 const q = hslPercent.l < 0.5 ? hslPercent.l * (1 + hslPercent.s) : hslPercent.l + hslPercent.s - hslPercent.l * hslPercent.s,
901 p = 2 * hslPercent.l - q;
902 result.r = hue2rgb(p, q, hslPercent.h + 1 / 3);
903 result.g = hue2rgb(p, q, hslPercent.h);
904 result.b = hue2rgb(p, q, hslPercent.h - 1 / 3);
905 }
906 result.r = Math.floor(result.r * 255);
907 result.g = Math.floor(result.g * 255);
908 result.b = Math.floor(result.b * 255);
909 return result;
910}
911function hslaToRgba(hsla) {
912 const rgbResult = hslToRgb(hsla);
913 return {
914 a: hsla.a,
915 b: rgbResult.b,
916 g: rgbResult.g,
917 r: rgbResult.r
918 };
919}
920function getRandomRgbColor(min) {
921 const fixedMin = min !== null && min !== void 0 ? min : 0;
922 return {
923 b: Math.floor(randomInRange(setRangeValue(fixedMin, 256))),
924 g: Math.floor(randomInRange(setRangeValue(fixedMin, 256))),
925 r: Math.floor(randomInRange(setRangeValue(fixedMin, 256)))
926 };
927}
928function getStyleFromRgb(color, opacity) {
929 return `rgba(${color.r}, ${color.g}, ${color.b}, ${opacity !== null && opacity !== void 0 ? opacity : 1})`;
930}
931function getStyleFromHsl(color, opacity) {
932 return `hsla(${color.h}, ${color.s}%, ${color.l}%, ${opacity !== null && opacity !== void 0 ? opacity : 1})`;
933}
934function colorMix(color1, color2, size1, size2) {
935 let rgb1 = color1,
936 rgb2 = color2;
937 if (rgb1.r === undefined) {
938 rgb1 = hslToRgb(color1);
939 }
940 if (rgb2.r === undefined) {
941 rgb2 = hslToRgb(color2);
942 }
943 return {
944 b: mix(rgb1.b, rgb2.b, size1, size2),
945 g: mix(rgb1.g, rgb2.g, size1, size2),
946 r: mix(rgb1.r, rgb2.r, size1, size2)
947 };
948}
949function getLinkColor(p1, p2, linkColor) {
950 var _a, _b;
951 if (linkColor === randomColorValue) {
952 return getRandomRgbColor();
953 } else if (linkColor === midColorValue) {
954 const sourceColor = (_a = p1.getFillColor()) !== null && _a !== void 0 ? _a : p1.getStrokeColor(),
955 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();
956 if (sourceColor && destColor && p2) {
957 return colorMix(sourceColor, destColor, p1.getRadius(), p2.getRadius());
958 } else {
959 const hslColor = sourceColor !== null && sourceColor !== void 0 ? sourceColor : destColor;
960 if (hslColor) {
961 return hslToRgb(hslColor);
962 }
963 }
964 } else {
965 return linkColor;
966 }
967}
968function getLinkRandomColor(optColor, blink, consent) {
969 const color = typeof optColor === "string" ? optColor : optColor.value;
970 if (color === randomColorValue) {
971 if (consent) {
972 return rangeColorToRgb({
973 value: color
974 });
975 }
976 if (blink) {
977 return randomColorValue;
978 }
979 return midColorValue;
980 } else if (color === midColorValue) {
981 return midColorValue;
982 } else {
983 return rangeColorToRgb({
984 value: color
985 });
986 }
987}
988function getHslFromAnimation(animation) {
989 return animation !== undefined ? {
990 h: animation.h.value,
991 s: animation.s.value,
992 l: animation.l.value
993 } : undefined;
994}
995function getHslAnimationFromHsl(hsl, animationOptions, reduceFactor) {
996 const resColor = {
997 h: {
998 enable: false,
999 value: hsl.h
1000 },
1001 s: {
1002 enable: false,
1003 value: hsl.s
1004 },
1005 l: {
1006 enable: false,
1007 value: hsl.l
1008 }
1009 };
1010 if (animationOptions) {
1011 setColorAnimation(resColor.h, animationOptions.h, reduceFactor);
1012 setColorAnimation(resColor.s, animationOptions.s, reduceFactor);
1013 setColorAnimation(resColor.l, animationOptions.l, reduceFactor);
1014 }
1015 return resColor;
1016}
1017function setColorAnimation(colorValue, colorAnimation, reduceFactor) {
1018 colorValue.enable = colorAnimation.enable;
1019 if (colorValue.enable) {
1020 colorValue.velocity = getRangeValue(colorAnimation.speed) / 100 * reduceFactor;
1021 colorValue.decay = 1 - getRangeValue(colorAnimation.decay);
1022 colorValue.status = "increasing";
1023 colorValue.loops = 0;
1024 colorValue.maxLoops = getRangeValue(colorAnimation.count);
1025 if (!colorAnimation.sync) {
1026 colorValue.velocity *= getRandom();
1027 colorValue.value *= getRandom();
1028 }
1029 colorValue.initialValue = colorValue.value;
1030 } else {
1031 colorValue.velocity = 0;
1032 }
1033}
1034;// CONCATENATED MODULE: ./dist/browser/Utils/CanvasUtils.js
1035
1036function drawLine(context, begin, end) {
1037 context.beginPath();
1038 context.moveTo(begin.x, begin.y);
1039 context.lineTo(end.x, end.y);
1040 context.closePath();
1041}
1042function drawTriangle(context, p1, p2, p3) {
1043 context.beginPath();
1044 context.moveTo(p1.x, p1.y);
1045 context.lineTo(p2.x, p2.y);
1046 context.lineTo(p3.x, p3.y);
1047 context.closePath();
1048}
1049function paintBase(context, dimension, baseColor) {
1050 context.fillStyle = baseColor !== null && baseColor !== void 0 ? baseColor : "rgba(0,0,0,0)";
1051 context.fillRect(0, 0, dimension.width, dimension.height);
1052}
1053function paintImage(context, dimension, image, opacity) {
1054 if (!image) {
1055 return;
1056 }
1057 context.globalAlpha = opacity;
1058 context.drawImage(image, 0, 0, dimension.width, dimension.height);
1059 context.globalAlpha = 1;
1060}
1061function clear(context, dimension) {
1062 context.clearRect(0, 0, dimension.width, dimension.height);
1063}
1064function drawParticle(data) {
1065 var _a, _b, _c, _d, _e;
1066 const {
1067 container,
1068 context,
1069 particle,
1070 delta,
1071 colorStyles,
1072 backgroundMask,
1073 composite,
1074 radius,
1075 opacity,
1076 shadow,
1077 transform
1078 } = data;
1079 const pos = particle.getPosition(),
1080 angle = particle.rotation + (particle.pathRotation ? particle.velocity.angle : 0),
1081 rotateData = {
1082 sin: Math.sin(angle),
1083 cos: Math.cos(angle)
1084 },
1085 transformData = {
1086 a: rotateData.cos * ((_a = transform.a) !== null && _a !== void 0 ? _a : 1),
1087 b: rotateData.sin * ((_b = transform.b) !== null && _b !== void 0 ? _b : 1),
1088 c: -rotateData.sin * ((_c = transform.c) !== null && _c !== void 0 ? _c : 1),
1089 d: rotateData.cos * ((_d = transform.d) !== null && _d !== void 0 ? _d : 1)
1090 };
1091 context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
1092 context.beginPath();
1093 if (backgroundMask) {
1094 context.globalCompositeOperation = composite;
1095 }
1096 const shadowColor = particle.shadowColor;
1097 if (shadow.enable && shadowColor) {
1098 context.shadowBlur = shadow.blur;
1099 context.shadowColor = getStyleFromRgb(shadowColor);
1100 context.shadowOffsetX = shadow.offset.x;
1101 context.shadowOffsetY = shadow.offset.y;
1102 }
1103 if (colorStyles.fill) {
1104 context.fillStyle = colorStyles.fill;
1105 }
1106 const strokeWidth = (_e = particle.strokeWidth) !== null && _e !== void 0 ? _e : 0;
1107 context.lineWidth = strokeWidth;
1108 if (colorStyles.stroke) {
1109 context.strokeStyle = colorStyles.stroke;
1110 }
1111 drawShape(container, context, particle, radius, opacity, delta);
1112 if (strokeWidth > 0) {
1113 context.stroke();
1114 }
1115 if (particle.close) {
1116 context.closePath();
1117 }
1118 if (particle.fill) {
1119 context.fill();
1120 }
1121 drawShapeAfterEffect(container, context, particle, radius, opacity, delta);
1122 context.globalCompositeOperation = "source-over";
1123 context.setTransform(1, 0, 0, 1, 0, 0);
1124}
1125function drawShape(container, context, particle, radius, opacity, delta) {
1126 if (!particle.shape) {
1127 return;
1128 }
1129 const drawer = container.drawers.get(particle.shape);
1130 if (!drawer) {
1131 return;
1132 }
1133 drawer.draw(context, particle, radius, opacity, delta, container.retina.pixelRatio);
1134}
1135function drawShapeAfterEffect(container, context, particle, radius, opacity, delta) {
1136 if (!particle.shape) {
1137 return;
1138 }
1139 const drawer = container.drawers.get(particle.shape);
1140 if (!(drawer === null || drawer === void 0 ? void 0 : drawer.afterEffect)) {
1141 return;
1142 }
1143 drawer.afterEffect(context, particle, radius, opacity, delta, container.retina.pixelRatio);
1144}
1145function drawPlugin(context, plugin, delta) {
1146 if (!plugin.draw) {
1147 return;
1148 }
1149 plugin.draw(context, delta);
1150}
1151function drawParticlePlugin(context, plugin, particle, delta) {
1152 if (!plugin.drawParticle) {
1153 return;
1154 }
1155 plugin.drawParticle(context, particle, delta);
1156}
1157function alterHsl(color, type, value) {
1158 return {
1159 h: color.h,
1160 s: color.s,
1161 l: color.l + (type === "darken" ? -1 : 1) * value
1162 };
1163}
1164;// CONCATENATED MODULE: ./dist/browser/Core/Utils/Constants.js
1165const generatedAttribute = "generated";
1166const touchEndEvent = "touchend";
1167const mouseDownEvent = "pointerdown";
1168const mouseUpEvent = "pointerup";
1169const mouseMoveEvent = "pointermove";
1170const touchStartEvent = "touchstart";
1171const touchMoveEvent = "touchmove";
1172const mouseLeaveEvent = "pointerleave";
1173const mouseOutEvent = "pointerout";
1174const touchCancelEvent = "touchcancel";
1175const resizeEvent = "resize";
1176const visibilityChangeEvent = "visibilitychange";
1177;// CONCATENATED MODULE: ./dist/browser/Core/Canvas.js
1178
1179
1180
1181
1182function setTransformValue(factor, newFactor, key) {
1183 var _a;
1184 const newValue = newFactor[key];
1185 if (newValue !== undefined) {
1186 factor[key] = ((_a = factor[key]) !== null && _a !== void 0 ? _a : 1) * newValue;
1187 }
1188}
1189class Canvas {
1190 constructor(container) {
1191 this.container = container;
1192 this.size = {
1193 height: 0,
1194 width: 0
1195 };
1196 this._context = null;
1197 this._generated = false;
1198 this._preDrawUpdaters = [];
1199 this._postDrawUpdaters = [];
1200 this._resizePlugins = [];
1201 this._colorPlugins = [];
1202 this._mutationObserver = !isSsr() && typeof MutationObserver !== "undefined" ? new MutationObserver(records => {
1203 for (const record of records) {
1204 if (record.type === "attributes" && record.attributeName === "style") {
1205 this._repairStyle();
1206 }
1207 }
1208 }) : undefined;
1209 }
1210 get _fullScreen() {
1211 return this.container.actualOptions.fullScreen.enable;
1212 }
1213 clear() {
1214 const options = this.container.actualOptions,
1215 trail = options.particles.move.trail,
1216 trailFill = this._trailFill;
1217 if (options.backgroundMask.enable) {
1218 this.paint();
1219 } else if (trail.enable && trail.length > 0 && trailFill) {
1220 if (trailFill.color) {
1221 this._paintBase(getStyleFromRgb(trailFill.color, trailFill.opacity));
1222 } else if (trailFill.image) {
1223 this._paintImage(trailFill.image, trailFill.opacity);
1224 }
1225 } else {
1226 this.draw(ctx => {
1227 clear(ctx, this.size);
1228 });
1229 }
1230 }
1231 destroy() {
1232 var _a, _b;
1233 (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1234 if (this._generated) {
1235 (_b = this.element) === null || _b === void 0 ? void 0 : _b.remove();
1236 } else {
1237 this._resetOriginalStyle();
1238 }
1239 this.draw(ctx => {
1240 clear(ctx, this.size);
1241 });
1242 this._preDrawUpdaters = [];
1243 this._postDrawUpdaters = [];
1244 this._resizePlugins = [];
1245 this._colorPlugins = [];
1246 }
1247 draw(cb) {
1248 if (!this._context) {
1249 return;
1250 }
1251 return cb(this._context);
1252 }
1253 drawParticle(particle, delta) {
1254 var _a;
1255 if (particle.spawning || particle.destroyed) {
1256 return;
1257 }
1258 const radius = particle.getRadius();
1259 if (radius <= 0) {
1260 return;
1261 }
1262 const pfColor = particle.getFillColor(),
1263 psColor = (_a = particle.getStrokeColor()) !== null && _a !== void 0 ? _a : pfColor;
1264 let [fColor, sColor] = this._getPluginParticleColors(particle);
1265 if (!fColor) {
1266 fColor = pfColor;
1267 }
1268 if (!sColor) {
1269 sColor = psColor;
1270 }
1271 if (!fColor && !sColor) {
1272 return;
1273 }
1274 this.draw(ctx => {
1275 var _a, _b, _c, _d;
1276 const options = this.container.actualOptions,
1277 zIndexOptions = particle.options.zIndex,
1278 zOpacityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.opacityRate,
1279 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,
1280 strokeOpacity = (_d = particle.strokeOpacity) !== null && _d !== void 0 ? _d : opacity,
1281 zOpacity = opacity * zOpacityFactor,
1282 zStrokeOpacity = strokeOpacity * zOpacityFactor,
1283 transform = {},
1284 colorStyles = {
1285 fill: fColor ? getStyleFromHsl(fColor, zOpacity) : undefined
1286 };
1287 colorStyles.stroke = sColor ? getStyleFromHsl(sColor, zStrokeOpacity) : colorStyles.fill;
1288 this._applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform);
1289 drawParticle({
1290 container: this.container,
1291 context: ctx,
1292 particle,
1293 delta,
1294 colorStyles,
1295 backgroundMask: options.backgroundMask.enable,
1296 composite: options.backgroundMask.composite,
1297 radius: radius * (1 - particle.zIndexFactor) ** zIndexOptions.sizeRate,
1298 opacity: zOpacity,
1299 shadow: particle.options.shadow,
1300 transform
1301 });
1302 this._applyPostDrawUpdaters(particle);
1303 });
1304 }
1305 drawParticlePlugin(plugin, particle, delta) {
1306 this.draw(ctx => {
1307 drawParticlePlugin(ctx, plugin, particle, delta);
1308 });
1309 }
1310 drawPlugin(plugin, delta) {
1311 this.draw(ctx => {
1312 drawPlugin(ctx, plugin, delta);
1313 });
1314 }
1315 async init() {
1316 var _a;
1317 this.resize();
1318 this._initStyle();
1319 this._initCover();
1320 try {
1321 await this._initTrail();
1322 } catch (e) {
1323 console.error(e);
1324 }
1325 this.initBackground();
1326 if (this.element) {
1327 (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.element, {
1328 attributes: true
1329 });
1330 }
1331 this.initUpdaters();
1332 this.initPlugins();
1333 this.paint();
1334 }
1335 initBackground() {
1336 const options = this.container.actualOptions,
1337 background = options.background,
1338 element = this.element,
1339 elementStyle = element === null || element === void 0 ? void 0 : element.style;
1340 if (!elementStyle) {
1341 return;
1342 }
1343 if (background.color) {
1344 const color = rangeColorToRgb(background.color);
1345 elementStyle.backgroundColor = color ? getStyleFromRgb(color, background.opacity) : "";
1346 } else {
1347 elementStyle.backgroundColor = "";
1348 }
1349 elementStyle.backgroundImage = background.image || "";
1350 elementStyle.backgroundPosition = background.position || "";
1351 elementStyle.backgroundRepeat = background.repeat || "";
1352 elementStyle.backgroundSize = background.size || "";
1353 }
1354 initPlugins() {
1355 this._resizePlugins = [];
1356 for (const [, plugin] of this.container.plugins) {
1357 if (plugin.resize) {
1358 this._resizePlugins.push(plugin);
1359 }
1360 if (plugin.particleFillColor || plugin.particleStrokeColor) {
1361 this._colorPlugins.push(plugin);
1362 }
1363 }
1364 }
1365 initUpdaters() {
1366 this._preDrawUpdaters = [];
1367 this._postDrawUpdaters = [];
1368 for (const updater of this.container.particles.updaters) {
1369 if (updater.afterDraw) {
1370 this._postDrawUpdaters.push(updater);
1371 }
1372 if (updater.getColorStyles || updater.getTransformValues || updater.beforeDraw) {
1373 this._preDrawUpdaters.push(updater);
1374 }
1375 }
1376 }
1377 loadCanvas(canvas) {
1378 var _a, _b;
1379 if (this._generated) {
1380 (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
1381 }
1382 this._generated = canvas.dataset && generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this._generated;
1383 this.element = canvas;
1384 this.element.ariaHidden = "true";
1385 this._originalStyle = deepExtend({}, this.element.style);
1386 this.size.height = canvas.offsetHeight;
1387 this.size.width = canvas.offsetWidth;
1388 this._context = this.element.getContext("2d");
1389 (_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(this.element, {
1390 attributes: true
1391 });
1392 this.container.retina.init();
1393 this.initBackground();
1394 }
1395 paint() {
1396 const options = this.container.actualOptions;
1397 this.draw(ctx => {
1398 if (options.backgroundMask.enable && options.backgroundMask.cover) {
1399 clear(ctx, this.size);
1400 this._paintBase(this._coverColorStyle);
1401 } else {
1402 this._paintBase();
1403 }
1404 });
1405 }
1406 resize() {
1407 if (!this.element) {
1408 return;
1409 }
1410 const container = this.container,
1411 pxRatio = container.retina.pixelRatio,
1412 size = container.canvas.size,
1413 newSize = {
1414 width: this.element.offsetWidth * pxRatio,
1415 height: this.element.offsetHeight * pxRatio
1416 };
1417 if (newSize.height === size.height && newSize.width === size.width && newSize.height === this.element.height && newSize.width === this.element.width) {
1418 return;
1419 }
1420 const oldSize = Object.assign({}, size);
1421 this.element.width = size.width = this.element.offsetWidth * pxRatio;
1422 this.element.height = size.height = this.element.offsetHeight * pxRatio;
1423 if (this.container.started) {
1424 this.resizeFactor = {
1425 width: size.width / oldSize.width,
1426 height: size.height / oldSize.height
1427 };
1428 }
1429 }
1430 async windowResize() {
1431 if (!this.element) {
1432 return;
1433 }
1434 this.resize();
1435 const container = this.container,
1436 needsRefresh = container.updateActualOptions();
1437 container.particles.setDensity();
1438 this._applyResizePlugins();
1439 if (needsRefresh) {
1440 await container.refresh();
1441 }
1442 }
1443 _applyPostDrawUpdaters(particle) {
1444 var _a;
1445 for (const updater of this._postDrawUpdaters) {
1446 (_a = updater.afterDraw) === null || _a === void 0 ? void 0 : _a.call(updater, particle);
1447 }
1448 }
1449 _applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
1450 var _a;
1451 for (const updater of this._preDrawUpdaters) {
1452 if (updater.getColorStyles) {
1453 const {
1454 fill,
1455 stroke
1456 } = updater.getColorStyles(particle, ctx, radius, zOpacity);
1457 if (fill) {
1458 colorStyles.fill = fill;
1459 }
1460 if (stroke) {
1461 colorStyles.stroke = stroke;
1462 }
1463 }
1464 if (updater.getTransformValues) {
1465 const updaterTransform = updater.getTransformValues(particle);
1466 for (const key in updaterTransform) {
1467 setTransformValue(transform, updaterTransform, key);
1468 }
1469 }
1470 (_a = updater.beforeDraw) === null || _a === void 0 ? void 0 : _a.call(updater, particle);
1471 }
1472 }
1473 _applyResizePlugins() {
1474 for (const plugin of this._resizePlugins) {
1475 if (plugin.resize) {
1476 plugin.resize();
1477 }
1478 }
1479 }
1480 _getPluginParticleColors(particle) {
1481 let fColor, sColor;
1482 for (const plugin of this._colorPlugins) {
1483 if (!fColor && plugin.particleFillColor) {
1484 fColor = rangeColorToHsl(plugin.particleFillColor(particle));
1485 }
1486 if (!sColor && plugin.particleStrokeColor) {
1487 sColor = rangeColorToHsl(plugin.particleStrokeColor(particle));
1488 }
1489 if (fColor && sColor) {
1490 break;
1491 }
1492 }
1493 return [fColor, sColor];
1494 }
1495 _initCover() {
1496 const options = this.container.actualOptions,
1497 cover = options.backgroundMask.cover,
1498 color = cover.color,
1499 coverRgb = rangeColorToRgb(color);
1500 if (coverRgb) {
1501 const coverColor = {
1502 r: coverRgb.r,
1503 g: coverRgb.g,
1504 b: coverRgb.b,
1505 a: cover.opacity
1506 };
1507 this._coverColorStyle = getStyleFromRgb(coverColor, coverColor.a);
1508 }
1509 }
1510 _initStyle() {
1511 const element = this.element,
1512 options = this.container.actualOptions;
1513 if (!element) {
1514 return;
1515 }
1516 if (this._fullScreen) {
1517 this._originalStyle = deepExtend({}, element.style);
1518 this._setFullScreenStyle();
1519 } else {
1520 this._resetOriginalStyle();
1521 }
1522 for (const key in options.style) {
1523 if (!key || !options.style) {
1524 continue;
1525 }
1526 const value = options.style[key];
1527 if (!value) {
1528 continue;
1529 }
1530 element.style.setProperty(key, value, "important");
1531 }
1532 }
1533 async _initTrail() {
1534 const options = this.container.actualOptions,
1535 trail = options.particles.move.trail,
1536 trailFill = trail.fill;
1537 if (!trail.enable) {
1538 return;
1539 }
1540 if (trailFill.color) {
1541 const fillColor = rangeColorToRgb(trailFill.color);
1542 if (!fillColor) {
1543 return;
1544 }
1545 const trail = options.particles.move.trail;
1546 this._trailFill = {
1547 color: Object.assign({}, fillColor),
1548 opacity: 1 / trail.length
1549 };
1550 } else {
1551 await new Promise((resolve, reject) => {
1552 if (!trailFill.image) {
1553 return;
1554 }
1555 const img = document.createElement("img");
1556 img.addEventListener("load", () => {
1557 this._trailFill = {
1558 image: img,
1559 opacity: 1 / trail.length
1560 };
1561 resolve();
1562 });
1563 img.addEventListener("error", evt => {
1564 reject(evt.error);
1565 });
1566 img.src = trailFill.image;
1567 });
1568 }
1569 }
1570 _paintBase(baseColor) {
1571 this.draw(ctx => {
1572 paintBase(ctx, this.size, baseColor);
1573 });
1574 }
1575 _paintImage(image, opacity) {
1576 this.draw(ctx => {
1577 paintImage(ctx, this.size, image, opacity);
1578 });
1579 }
1580 _repairStyle() {
1581 var _a, _b;
1582 const element = this.element;
1583 if (!element) {
1584 return;
1585 }
1586 (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1587 this._initStyle();
1588 this.initBackground();
1589 (_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(element, {
1590 attributes: true
1591 });
1592 }
1593 _resetOriginalStyle() {
1594 const element = this.element,
1595 originalStyle = this._originalStyle;
1596 if (!(element && originalStyle)) {
1597 return;
1598 }
1599 element.style.position = originalStyle.position;
1600 element.style.zIndex = originalStyle.zIndex;
1601 element.style.top = originalStyle.top;
1602 element.style.left = originalStyle.left;
1603 element.style.width = originalStyle.width;
1604 element.style.height = originalStyle.height;
1605 }
1606 _setFullScreenStyle() {
1607 const element = this.element;
1608 if (!element) {
1609 return;
1610 }
1611 const priority = "important";
1612 element.style.setProperty("position", "fixed", priority);
1613 element.style.setProperty("z-index", this.container.actualOptions.fullScreen.zIndex.toString(10), priority);
1614 element.style.setProperty("top", "0", priority);
1615 element.style.setProperty("left", "0", priority);
1616 element.style.setProperty("width", "100%", priority);
1617 element.style.setProperty("height", "100%", priority);
1618 }
1619}
1620;// CONCATENATED MODULE: ./dist/browser/Core/Utils/EventListeners.js
1621
1622
1623function manageListener(element, event, handler, add, options) {
1624 if (add) {
1625 let addOptions = {
1626 passive: true
1627 };
1628 if (typeof options === "boolean") {
1629 addOptions.capture = options;
1630 } else if (options !== undefined) {
1631 addOptions = options;
1632 }
1633 element.addEventListener(event, handler, addOptions);
1634 } else {
1635 const removeOptions = options;
1636 element.removeEventListener(event, handler, removeOptions);
1637 }
1638}
1639class EventListeners {
1640 constructor(container) {
1641 this.container = container;
1642 this.canPush = true;
1643 this.handlers = {
1644 mouseMove: e => this.mouseTouchMove(e),
1645 touchStart: e => this.mouseTouchMove(e),
1646 touchMove: e => this.mouseTouchMove(e),
1647 touchEnd: () => this.mouseTouchFinish(),
1648 mouseLeave: () => this.mouseTouchFinish(),
1649 touchCancel: () => this.mouseTouchFinish(),
1650 touchEndClick: e => this.mouseTouchClick(e),
1651 mouseUp: e => this.mouseTouchClick(e),
1652 mouseDown: () => this.mouseDown(),
1653 visibilityChange: () => this.handleVisibilityChange(),
1654 themeChange: e => this.handleThemeChange(e),
1655 oldThemeChange: e => this.handleThemeChange(e),
1656 resize: () => this.handleWindowResize()
1657 };
1658 }
1659 addListeners() {
1660 this.manageListeners(true);
1661 }
1662 removeListeners() {
1663 this.manageListeners(false);
1664 }
1665 doMouseTouchClick(e) {
1666 const container = this.container,
1667 options = container.actualOptions;
1668 if (this.canPush) {
1669 const mouseInteractivity = container.interactivity.mouse,
1670 mousePos = mouseInteractivity.position;
1671 if (!mousePos) {
1672 return;
1673 }
1674 mouseInteractivity.clickPosition = Object.assign({}, mousePos);
1675 mouseInteractivity.clickTime = new Date().getTime();
1676 const onClick = options.interactivity.events.onClick;
1677 executeOnSingleOrMultiple(onClick.mode, mode => this.handleClickMode(mode));
1678 }
1679 if (e.type === "touchend") {
1680 setTimeout(() => this.mouseTouchFinish(), 500);
1681 }
1682 }
1683 handleClickMode(mode) {
1684 this.container.handleClickMode(mode);
1685 }
1686 handleThemeChange(e) {
1687 const mediaEvent = e,
1688 container = this.container,
1689 options = container.options,
1690 defaultThemes = options.defaultThemes,
1691 themeName = mediaEvent.matches ? defaultThemes.dark : defaultThemes.light,
1692 theme = options.themes.find(theme => theme.name === themeName);
1693 if (theme && theme.default.auto) {
1694 container.loadTheme(themeName);
1695 }
1696 }
1697 handleVisibilityChange() {
1698 const container = this.container,
1699 options = container.actualOptions;
1700 this.mouseTouchFinish();
1701 if (!options.pauseOnBlur) {
1702 return;
1703 }
1704 if (document === null || document === void 0 ? void 0 : document.hidden) {
1705 container.pageHidden = true;
1706 container.pause();
1707 } else {
1708 container.pageHidden = false;
1709 if (container.getAnimationStatus()) {
1710 container.play(true);
1711 } else {
1712 container.draw(true);
1713 }
1714 }
1715 }
1716 handleWindowResize() {
1717 if (this.resizeTimeout) {
1718 clearTimeout(this.resizeTimeout);
1719 delete this.resizeTimeout;
1720 }
1721 this.resizeTimeout = setTimeout(async () => {
1722 var _a;
1723 return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize();
1724 }, this.container.actualOptions.interactivity.events.resize.delay * 1000);
1725 }
1726 manageListeners(add) {
1727 var _a;
1728 const handlers = this.handlers,
1729 container = this.container,
1730 options = container.actualOptions,
1731 detectType = options.interactivity.detectsOn;
1732 let mouseLeaveTmpEvent = mouseLeaveEvent;
1733 if (detectType === "window") {
1734 container.interactivity.element = window;
1735 mouseLeaveTmpEvent = mouseOutEvent;
1736 } else if (detectType === "parent" && container.canvas.element) {
1737 const canvasEl = container.canvas.element;
1738 container.interactivity.element = (_a = canvasEl.parentElement) !== null && _a !== void 0 ? _a : canvasEl.parentNode;
1739 } else {
1740 container.interactivity.element = container.canvas.element;
1741 }
1742 const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
1743 if (mediaMatch) {
1744 if (mediaMatch.addEventListener !== undefined) {
1745 manageListener(mediaMatch, "change", handlers.themeChange, add);
1746 } else if (mediaMatch.addListener !== undefined) {
1747 if (add) {
1748 mediaMatch.addListener(handlers.oldThemeChange);
1749 } else {
1750 mediaMatch.removeListener(handlers.oldThemeChange);
1751 }
1752 }
1753 }
1754 const interactivityEl = container.interactivity.element;
1755 if (!interactivityEl) {
1756 return;
1757 }
1758 const html = interactivityEl;
1759 if (options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable) {
1760 manageListener(interactivityEl, mouseMoveEvent, handlers.mouseMove, add);
1761 manageListener(interactivityEl, touchStartEvent, handlers.touchStart, add);
1762 manageListener(interactivityEl, touchMoveEvent, handlers.touchMove, add);
1763 if (!options.interactivity.events.onClick.enable) {
1764 manageListener(interactivityEl, touchEndEvent, handlers.touchEnd, add);
1765 } else {
1766 manageListener(interactivityEl, touchEndEvent, handlers.touchEndClick, add);
1767 manageListener(interactivityEl, mouseUpEvent, handlers.mouseUp, add);
1768 manageListener(interactivityEl, mouseDownEvent, handlers.mouseDown, add);
1769 }
1770 manageListener(interactivityEl, mouseLeaveTmpEvent, handlers.mouseLeave, add);
1771 manageListener(interactivityEl, touchCancelEvent, handlers.touchCancel, add);
1772 }
1773 if (container.canvas.element) {
1774 container.canvas.element.style.pointerEvents = html === container.canvas.element ? "initial" : "none";
1775 }
1776 if (options.interactivity.events.resize) {
1777 if (typeof ResizeObserver !== "undefined") {
1778 if (this.resizeObserver && !add) {
1779 if (container.canvas.element) {
1780 this.resizeObserver.unobserve(container.canvas.element);
1781 }
1782 this.resizeObserver.disconnect();
1783 delete this.resizeObserver;
1784 } else if (!this.resizeObserver && add && container.canvas.element) {
1785 this.resizeObserver = new ResizeObserver(entries => {
1786 const entry = entries.find(e => e.target === container.canvas.element);
1787 if (!entry) {
1788 return;
1789 }
1790 this.handleWindowResize();
1791 });
1792 this.resizeObserver.observe(container.canvas.element);
1793 }
1794 } else {
1795 manageListener(window, resizeEvent, handlers.resize, add);
1796 }
1797 }
1798 if (document) {
1799 manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
1800 }
1801 }
1802 mouseDown() {
1803 const interactivity = this.container.interactivity;
1804 if (interactivity) {
1805 const mouse = interactivity.mouse;
1806 mouse.clicking = true;
1807 mouse.downPosition = mouse.position;
1808 }
1809 }
1810 mouseTouchClick(e) {
1811 const container = this.container,
1812 options = container.actualOptions,
1813 mouse = container.interactivity.mouse;
1814 mouse.inside = true;
1815 let handled = false;
1816 const mousePosition = mouse.position;
1817 if (!mousePosition || !options.interactivity.events.onClick.enable) {
1818 return;
1819 }
1820 for (const [, plugin] of container.plugins) {
1821 if (!plugin.clickPositionValid) {
1822 continue;
1823 }
1824 handled = plugin.clickPositionValid(mousePosition);
1825 if (handled) {
1826 break;
1827 }
1828 }
1829 if (!handled) {
1830 this.doMouseTouchClick(e);
1831 }
1832 mouse.clicking = false;
1833 }
1834 mouseTouchFinish() {
1835 const interactivity = this.container.interactivity;
1836 if (!interactivity) {
1837 return;
1838 }
1839 const mouse = interactivity.mouse;
1840 delete mouse.position;
1841 delete mouse.clickPosition;
1842 delete mouse.downPosition;
1843 interactivity.status = mouseLeaveEvent;
1844 mouse.inside = false;
1845 mouse.clicking = false;
1846 }
1847 mouseTouchMove(e) {
1848 var _a, _b, _c, _d, _e, _f, _g;
1849 const container = this.container,
1850 options = container.actualOptions;
1851 if (!((_a = container.interactivity) === null || _a === void 0 ? void 0 : _a.element)) {
1852 return;
1853 }
1854 container.interactivity.mouse.inside = true;
1855 let pos;
1856 const canvas = container.canvas.element;
1857 if (e.type.startsWith("pointer")) {
1858 this.canPush = true;
1859 const mouseEvent = e;
1860 if (container.interactivity.element === window) {
1861 if (canvas) {
1862 const clientRect = canvas.getBoundingClientRect();
1863 pos = {
1864 x: mouseEvent.clientX - clientRect.left,
1865 y: mouseEvent.clientY - clientRect.top
1866 };
1867 }
1868 } else if (options.interactivity.detectsOn === "parent") {
1869 const source = mouseEvent.target,
1870 target = mouseEvent.currentTarget,
1871 canvasEl = container.canvas.element;
1872 if (source && target && canvasEl) {
1873 const sourceRect = source.getBoundingClientRect(),
1874 targetRect = target.getBoundingClientRect(),
1875 canvasRect = canvasEl.getBoundingClientRect();
1876 pos = {
1877 x: mouseEvent.offsetX + 2 * sourceRect.left - (targetRect.left + canvasRect.left),
1878 y: mouseEvent.offsetY + 2 * sourceRect.top - (targetRect.top + canvasRect.top)
1879 };
1880 } else {
1881 pos = {
1882 x: (_b = mouseEvent.offsetX) !== null && _b !== void 0 ? _b : mouseEvent.clientX,
1883 y: (_c = mouseEvent.offsetY) !== null && _c !== void 0 ? _c : mouseEvent.clientY
1884 };
1885 }
1886 } else if (mouseEvent.target === container.canvas.element) {
1887 pos = {
1888 x: (_d = mouseEvent.offsetX) !== null && _d !== void 0 ? _d : mouseEvent.clientX,
1889 y: (_e = mouseEvent.offsetY) !== null && _e !== void 0 ? _e : mouseEvent.clientY
1890 };
1891 }
1892 } else {
1893 this.canPush = e.type !== "touchmove";
1894 const touchEvent = e,
1895 lastTouch = touchEvent.touches[touchEvent.touches.length - 1],
1896 canvasRect = canvas === null || canvas === void 0 ? void 0 : canvas.getBoundingClientRect();
1897 pos = {
1898 x: lastTouch.clientX - ((_f = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.left) !== null && _f !== void 0 ? _f : 0),
1899 y: lastTouch.clientY - ((_g = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.top) !== null && _g !== void 0 ? _g : 0)
1900 };
1901 }
1902 const pxRatio = container.retina.pixelRatio;
1903 if (pos) {
1904 pos.x *= pxRatio;
1905 pos.y *= pxRatio;
1906 }
1907 container.interactivity.mouse.position = pos;
1908 container.interactivity.status = mouseMoveEvent;
1909 }
1910}
1911;// CONCATENATED MODULE: ./dist/browser/Core/Utils/FrameManager.js
1912function initDelta(value, fpsLimit = 60, smooth = false) {
1913 return {
1914 value,
1915 factor: smooth ? 60 / fpsLimit : 60 * value / 1000
1916 };
1917}
1918class FrameManager {
1919 constructor(container) {
1920 this.container = container;
1921 }
1922 async nextFrame(timestamp) {
1923 var _a;
1924 try {
1925 const container = this.container;
1926 if (!container.smooth && container.lastFrameTime !== undefined && timestamp < container.lastFrameTime + 1000 / container.fpsLimit) {
1927 container.draw(false);
1928 return;
1929 }
1930 (_a = container.lastFrameTime) !== null && _a !== void 0 ? _a : container.lastFrameTime = timestamp;
1931 const delta = initDelta(timestamp - container.lastFrameTime, container.fpsLimit, container.smooth);
1932 container.lifeTime += delta.value;
1933 container.lastFrameTime = timestamp;
1934 if (delta.value > 1000) {
1935 container.draw(false);
1936 return;
1937 }
1938 await container.particles.draw(delta);
1939 if (container.duration > 0 && container.lifeTime > container.duration) {
1940 container.destroy();
1941 return;
1942 }
1943 if (container.getAnimationStatus()) {
1944 container.draw(false);
1945 }
1946 } catch (e) {
1947 console.error("tsParticles error in animation loop", e);
1948 }
1949 }
1950}
1951;// CONCATENATED MODULE: ./dist/browser/Options/Classes/OptionsColor.js
1952class OptionsColor {
1953 constructor() {
1954 this.value = "";
1955 }
1956 static create(source, data) {
1957 const color = new OptionsColor();
1958 color.load(source);
1959 if (data !== undefined) {
1960 if (typeof data === "string" || data instanceof Array) {
1961 color.load({
1962 value: data
1963 });
1964 } else {
1965 color.load(data);
1966 }
1967 }
1968 return color;
1969 }
1970 load(data) {
1971 if ((data === null || data === void 0 ? void 0 : data.value) === undefined) {
1972 return;
1973 }
1974 this.value = data.value;
1975 }
1976}
1977;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Background/Background.js
1978
1979class Background {
1980 constructor() {
1981 this.color = new OptionsColor();
1982 this.color.value = "";
1983 this.image = "";
1984 this.position = "";
1985 this.repeat = "";
1986 this.size = "";
1987 this.opacity = 1;
1988 }
1989 load(data) {
1990 if (!data) {
1991 return;
1992 }
1993 if (data.color !== undefined) {
1994 this.color = OptionsColor.create(this.color, data.color);
1995 }
1996 if (data.image !== undefined) {
1997 this.image = data.image;
1998 }
1999 if (data.position !== undefined) {
2000 this.position = data.position;
2001 }
2002 if (data.repeat !== undefined) {
2003 this.repeat = data.repeat;
2004 }
2005 if (data.size !== undefined) {
2006 this.size = data.size;
2007 }
2008 if (data.opacity !== undefined) {
2009 this.opacity = data.opacity;
2010 }
2011 }
2012}
2013;// CONCATENATED MODULE: ./dist/browser/Options/Classes/BackgroundMask/BackgroundMaskCover.js
2014
2015class BackgroundMaskCover {
2016 constructor() {
2017 this.color = new OptionsColor();
2018 this.color.value = "#fff";
2019 this.opacity = 1;
2020 }
2021 load(data) {
2022 if (!data) {
2023 return;
2024 }
2025 if (data.color !== undefined) {
2026 this.color = OptionsColor.create(this.color, data.color);
2027 }
2028 if (data.opacity !== undefined) {
2029 this.opacity = data.opacity;
2030 }
2031 }
2032}
2033;// CONCATENATED MODULE: ./dist/browser/Options/Classes/BackgroundMask/BackgroundMask.js
2034
2035class BackgroundMask {
2036 constructor() {
2037 this.composite = "destination-out";
2038 this.cover = new BackgroundMaskCover();
2039 this.enable = false;
2040 }
2041 load(data) {
2042 if (!data) {
2043 return;
2044 }
2045 if (data.composite !== undefined) {
2046 this.composite = data.composite;
2047 }
2048 if (data.cover !== undefined) {
2049 const cover = data.cover;
2050 const color = typeof data.cover === "string" ? {
2051 color: data.cover
2052 } : data.cover;
2053 this.cover.load(cover.color !== undefined ? cover : {
2054 color: color
2055 });
2056 }
2057 if (data.enable !== undefined) {
2058 this.enable = data.enable;
2059 }
2060 }
2061}
2062;// CONCATENATED MODULE: ./dist/browser/Options/Classes/FullScreen/FullScreen.js
2063class FullScreen {
2064 constructor() {
2065 this.enable = true;
2066 this.zIndex = 0;
2067 }
2068 load(data) {
2069 if (!data) {
2070 return;
2071 }
2072 if (data.enable !== undefined) {
2073 this.enable = data.enable;
2074 }
2075 if (data.zIndex !== undefined) {
2076 this.zIndex = data.zIndex;
2077 }
2078 }
2079}
2080;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/ClickEvent.js
2081class ClickEvent {
2082 constructor() {
2083 this.enable = false;
2084 this.mode = [];
2085 }
2086 load(data) {
2087 if (!data) {
2088 return;
2089 }
2090 if (data.enable !== undefined) {
2091 this.enable = data.enable;
2092 }
2093 if (data.mode !== undefined) {
2094 this.mode = data.mode;
2095 }
2096 }
2097}
2098;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/DivEvent.js
2099
2100class DivEvent {
2101 constructor() {
2102 this.selectors = [];
2103 this.enable = false;
2104 this.mode = [];
2105 this.type = "circle";
2106 }
2107 get el() {
2108 return this.elementId;
2109 }
2110 set el(value) {
2111 this.elementId = value;
2112 }
2113 get elementId() {
2114 return this.ids;
2115 }
2116 set elementId(value) {
2117 this.ids = value;
2118 }
2119 get ids() {
2120 return executeOnSingleOrMultiple(this.selectors, t => t.replace("#", ""));
2121 }
2122 set ids(value) {
2123 this.selectors = executeOnSingleOrMultiple(value, t => `#${t}`);
2124 }
2125 load(data) {
2126 var _a, _b;
2127 if (!data) {
2128 return;
2129 }
2130 const ids = (_b = (_a = data.ids) !== null && _a !== void 0 ? _a : data.elementId) !== null && _b !== void 0 ? _b : data.el;
2131 if (ids !== undefined) {
2132 this.ids = ids;
2133 }
2134 if (data.selectors !== undefined) {
2135 this.selectors = data.selectors;
2136 }
2137 if (data.enable !== undefined) {
2138 this.enable = data.enable;
2139 }
2140 if (data.mode !== undefined) {
2141 this.mode = data.mode;
2142 }
2143 if (data.type !== undefined) {
2144 this.type = data.type;
2145 }
2146 }
2147}
2148;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/Parallax.js
2149class Parallax {
2150 constructor() {
2151 this.enable = false;
2152 this.force = 2;
2153 this.smooth = 10;
2154 }
2155 load(data) {
2156 if (!data) {
2157 return;
2158 }
2159 if (data.enable !== undefined) {
2160 this.enable = data.enable;
2161 }
2162 if (data.force !== undefined) {
2163 this.force = data.force;
2164 }
2165 if (data.smooth !== undefined) {
2166 this.smooth = data.smooth;
2167 }
2168 }
2169}
2170;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/HoverEvent.js
2171
2172class HoverEvent {
2173 constructor() {
2174 this.enable = false;
2175 this.mode = [];
2176 this.parallax = new Parallax();
2177 }
2178 load(data) {
2179 if (!data) {
2180 return;
2181 }
2182 if (data.enable !== undefined) {
2183 this.enable = data.enable;
2184 }
2185 if (data.mode !== undefined) {
2186 this.mode = data.mode;
2187 }
2188 this.parallax.load(data.parallax);
2189 }
2190}
2191;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/ResizeEvent.js
2192class ResizeEvent {
2193 constructor() {
2194 this.delay = 0.5;
2195 this.enable = true;
2196 }
2197 load(data) {
2198 if (data === undefined) {
2199 return;
2200 }
2201 if (data.delay !== undefined) {
2202 this.delay = data.delay;
2203 }
2204 if (data.enable !== undefined) {
2205 this.enable = data.enable;
2206 }
2207 }
2208}
2209;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/Events.js
2210
2211
2212
2213
2214
2215class Events {
2216 constructor() {
2217 this.onClick = new ClickEvent();
2218 this.onDiv = new DivEvent();
2219 this.onHover = new HoverEvent();
2220 this.resize = new ResizeEvent();
2221 }
2222 get onclick() {
2223 return this.onClick;
2224 }
2225 set onclick(value) {
2226 this.onClick = value;
2227 }
2228 get ondiv() {
2229 return this.onDiv;
2230 }
2231 set ondiv(value) {
2232 this.onDiv = value;
2233 }
2234 get onhover() {
2235 return this.onHover;
2236 }
2237 set onhover(value) {
2238 this.onHover = value;
2239 }
2240 load(data) {
2241 var _a, _b, _c;
2242 if (!data) {
2243 return;
2244 }
2245 this.onClick.load((_a = data.onClick) !== null && _a !== void 0 ? _a : data.onclick);
2246 const onDiv = (_b = data.onDiv) !== null && _b !== void 0 ? _b : data.ondiv;
2247 if (onDiv !== undefined) {
2248 this.onDiv = executeOnSingleOrMultiple(onDiv, t => {
2249 const tmp = new DivEvent();
2250 tmp.load(t);
2251 return tmp;
2252 });
2253 }
2254 this.onHover.load((_c = data.onHover) !== null && _c !== void 0 ? _c : data.onhover);
2255 if (typeof data.resize === "boolean") {
2256 this.resize.enable = data.resize;
2257 } else {
2258 this.resize.load(data.resize);
2259 }
2260 }
2261}
2262;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Modes.js
2263class Modes {
2264 constructor(engine, container) {
2265 this._engine = engine;
2266 this._container = container;
2267 }
2268 load(data) {
2269 if (!data) {
2270 return;
2271 }
2272 if (this._container) {
2273 const interactors = this._engine.plugins.interactors.get(this._container);
2274 if (interactors) {
2275 for (const interactor of interactors) {
2276 if (interactor.loadModeOptions) {
2277 interactor.loadModeOptions(this, data);
2278 }
2279 }
2280 }
2281 }
2282 }
2283}
2284;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Interactivity.js
2285
2286
2287class Interactivity {
2288 constructor(engine, container) {
2289 this.detectsOn = "window";
2290 this.events = new Events();
2291 this.modes = new Modes(engine, container);
2292 }
2293 get detect_on() {
2294 return this.detectsOn;
2295 }
2296 set detect_on(value) {
2297 this.detectsOn = value;
2298 }
2299 load(data) {
2300 var _a;
2301 if (!data) {
2302 return;
2303 }
2304 const detectsOn = (_a = data.detectsOn) !== null && _a !== void 0 ? _a : data.detect_on;
2305 if (detectsOn !== undefined) {
2306 this.detectsOn = detectsOn;
2307 }
2308 this.events.load(data.events);
2309 this.modes.load(data.modes);
2310 }
2311}
2312;// CONCATENATED MODULE: ./dist/browser/Options/Classes/ManualParticle.js
2313
2314class ManualParticle {
2315 load(data) {
2316 var _a, _b;
2317 if (!data) {
2318 return;
2319 }
2320 if (data.position !== undefined) {
2321 this.position = {
2322 x: (_a = data.position.x) !== null && _a !== void 0 ? _a : 50,
2323 y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50
2324 };
2325 }
2326 if (data.options !== undefined) {
2327 this.options = deepExtend({}, data.options);
2328 }
2329 }
2330}
2331;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Responsive.js
2332
2333class Responsive {
2334 constructor() {
2335 this.maxWidth = Infinity;
2336 this.options = {};
2337 this.mode = "canvas";
2338 }
2339 load(data) {
2340 if (!data) {
2341 return;
2342 }
2343 if (data.maxWidth !== undefined) {
2344 this.maxWidth = data.maxWidth;
2345 }
2346 if (data.mode !== undefined) {
2347 if (data.mode === "screen") {
2348 this.mode = "screen";
2349 } else {
2350 this.mode = "canvas";
2351 }
2352 }
2353 if (data.options !== undefined) {
2354 this.options = deepExtend({}, data.options);
2355 }
2356 }
2357}
2358;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Theme/ThemeDefault.js
2359class ThemeDefault {
2360 constructor() {
2361 this.auto = false;
2362 this.mode = "any";
2363 this.value = false;
2364 }
2365 load(data) {
2366 if (!data) {
2367 return;
2368 }
2369 if (data.auto !== undefined) {
2370 this.auto = data.auto;
2371 }
2372 if (data.mode !== undefined) {
2373 this.mode = data.mode;
2374 }
2375 if (data.value !== undefined) {
2376 this.value = data.value;
2377 }
2378 }
2379}
2380;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Theme/Theme.js
2381
2382
2383class Theme {
2384 constructor() {
2385 this.name = "";
2386 this.default = new ThemeDefault();
2387 }
2388 load(data) {
2389 if (!data) {
2390 return;
2391 }
2392 if (data.name !== undefined) {
2393 this.name = data.name;
2394 }
2395 this.default.load(data.default);
2396 if (data.options !== undefined) {
2397 this.options = deepExtend({}, data.options);
2398 }
2399 }
2400}
2401;// CONCATENATED MODULE: ./dist/browser/Options/Classes/ColorAnimation.js
2402
2403class ColorAnimation {
2404 constructor() {
2405 this.count = 0;
2406 this.enable = false;
2407 this.offset = 0;
2408 this.speed = 1;
2409 this.decay = 0;
2410 this.sync = true;
2411 }
2412 load(data) {
2413 if (!data) {
2414 return;
2415 }
2416 if (data.count !== undefined) {
2417 this.count = setRangeValue(data.count);
2418 }
2419 if (data.enable !== undefined) {
2420 this.enable = data.enable;
2421 }
2422 if (data.offset !== undefined) {
2423 this.offset = setRangeValue(data.offset);
2424 }
2425 if (data.speed !== undefined) {
2426 this.speed = setRangeValue(data.speed);
2427 }
2428 if (data.decay !== undefined) {
2429 this.decay = setRangeValue(data.decay);
2430 }
2431 if (data.sync !== undefined) {
2432 this.sync = data.sync;
2433 }
2434 }
2435}
2436;// CONCATENATED MODULE: ./dist/browser/Options/Classes/HslAnimation.js
2437
2438class HslAnimation {
2439 constructor() {
2440 this.h = new ColorAnimation();
2441 this.s = new ColorAnimation();
2442 this.l = new ColorAnimation();
2443 }
2444 load(data) {
2445 if (!data) {
2446 return;
2447 }
2448 this.h.load(data.h);
2449 this.s.load(data.s);
2450 this.l.load(data.l);
2451 }
2452}
2453;// CONCATENATED MODULE: ./dist/browser/Options/Classes/AnimatableColor.js
2454
2455
2456class AnimatableColor extends OptionsColor {
2457 constructor() {
2458 super();
2459 this.animation = new HslAnimation();
2460 }
2461 static create(source, data) {
2462 const color = new AnimatableColor();
2463 color.load(source);
2464 if (data !== undefined) {
2465 if (typeof data === "string" || data instanceof Array) {
2466 color.load({
2467 value: data
2468 });
2469 } else {
2470 color.load(data);
2471 }
2472 }
2473 return color;
2474 }
2475 load(data) {
2476 super.load(data);
2477 if (!data) {
2478 return;
2479 }
2480 const colorAnimation = data.animation;
2481 if (colorAnimation !== undefined) {
2482 if (colorAnimation.enable !== undefined) {
2483 this.animation.h.load(colorAnimation);
2484 } else {
2485 this.animation.load(data.animation);
2486 }
2487 }
2488 }
2489}
2490;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Collisions/CollisionsAbsorb.js
2491class CollisionsAbsorb {
2492 constructor() {
2493 this.speed = 2;
2494 }
2495 load(data) {
2496 if (!data) {
2497 return;
2498 }
2499 if (data.speed !== undefined) {
2500 this.speed = data.speed;
2501 }
2502 }
2503}
2504;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Collisions/CollisionsOverlap.js
2505class CollisionsOverlap {
2506 constructor() {
2507 this.enable = true;
2508 this.retries = 0;
2509 }
2510 load(data) {
2511 if (!data) {
2512 return;
2513 }
2514 if (data.enable !== undefined) {
2515 this.enable = data.enable;
2516 }
2517 if (data.retries !== undefined) {
2518 this.retries = data.retries;
2519 }
2520 }
2521}
2522;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Random.js
2523class Random {
2524 constructor() {
2525 this.enable = false;
2526 this.minimumValue = 0;
2527 }
2528 load(data) {
2529 if (!data) {
2530 return;
2531 }
2532 if (data.enable !== undefined) {
2533 this.enable = data.enable;
2534 }
2535 if (data.minimumValue !== undefined) {
2536 this.minimumValue = data.minimumValue;
2537 }
2538 }
2539}
2540;// CONCATENATED MODULE: ./dist/browser/Options/Classes/ValueWithRandom.js
2541
2542
2543class ValueWithRandom {
2544 constructor() {
2545 this.random = new Random();
2546 this.value = 0;
2547 }
2548 load(data) {
2549 if (!data) {
2550 return;
2551 }
2552 if (typeof data.random === "boolean") {
2553 this.random.enable = data.random;
2554 } else {
2555 this.random.load(data.random);
2556 }
2557 if (data.value !== undefined) {
2558 this.value = setRangeValue(data.value, this.random.enable ? this.random.minimumValue : undefined);
2559 }
2560 }
2561}
2562;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js
2563
2564class ParticlesBounceFactor extends ValueWithRandom {
2565 constructor() {
2566 super();
2567 this.random.minimumValue = 0.1;
2568 this.value = 1;
2569 }
2570}
2571;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js
2572
2573class ParticlesBounce {
2574 constructor() {
2575 this.horizontal = new ParticlesBounceFactor();
2576 this.vertical = new ParticlesBounceFactor();
2577 }
2578 load(data) {
2579 if (!data) {
2580 return;
2581 }
2582 this.horizontal.load(data.horizontal);
2583 this.vertical.load(data.vertical);
2584 }
2585}
2586;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Collisions/Collisions.js
2587
2588
2589
2590class Collisions {
2591 constructor() {
2592 this.absorb = new CollisionsAbsorb();
2593 this.bounce = new ParticlesBounce();
2594 this.enable = false;
2595 this.mode = "bounce";
2596 this.overlap = new CollisionsOverlap();
2597 }
2598 load(data) {
2599 if (!data) {
2600 return;
2601 }
2602 this.absorb.load(data.absorb);
2603 this.bounce.load(data.bounce);
2604 if (data.enable !== undefined) {
2605 this.enable = data.enable;
2606 }
2607 if (data.mode !== undefined) {
2608 this.mode = data.mode;
2609 }
2610 this.overlap.load(data.overlap);
2611 }
2612}
2613;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/MoveAngle.js
2614
2615class MoveAngle {
2616 constructor() {
2617 this.offset = 0;
2618 this.value = 90;
2619 }
2620 load(data) {
2621 if (!data) {
2622 return;
2623 }
2624 if (data.offset !== undefined) {
2625 this.offset = setRangeValue(data.offset);
2626 }
2627 if (data.value !== undefined) {
2628 this.value = setRangeValue(data.value);
2629 }
2630 }
2631}
2632;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/MoveAttract.js
2633
2634class MoveAttract {
2635 constructor() {
2636 this.distance = 200;
2637 this.enable = false;
2638 this.rotate = {
2639 x: 3000,
2640 y: 3000
2641 };
2642 }
2643 get rotateX() {
2644 return this.rotate.x;
2645 }
2646 set rotateX(value) {
2647 this.rotate.x = value;
2648 }
2649 get rotateY() {
2650 return this.rotate.y;
2651 }
2652 set rotateY(value) {
2653 this.rotate.y = value;
2654 }
2655 load(data) {
2656 var _a, _b, _c, _d;
2657 if (!data) {
2658 return;
2659 }
2660 if (data.distance !== undefined) {
2661 this.distance = setRangeValue(data.distance);
2662 }
2663 if (data.enable !== undefined) {
2664 this.enable = data.enable;
2665 }
2666 const rotateX = (_b = (_a = data.rotate) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : data.rotateX;
2667 if (rotateX !== undefined) {
2668 this.rotate.x = rotateX;
2669 }
2670 const rotateY = (_d = (_c = data.rotate) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : data.rotateY;
2671 if (rotateY !== undefined) {
2672 this.rotate.y = rotateY;
2673 }
2674 }
2675}
2676;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/MoveCenter.js
2677class MoveCenter {
2678 constructor() {
2679 this.x = 50;
2680 this.y = 50;
2681 this.mode = "percent";
2682 this.radius = 0;
2683 }
2684 load(data) {
2685 if (!data) {
2686 return;
2687 }
2688 if (data.x !== undefined) {
2689 this.x = data.x;
2690 }
2691 if (data.y !== undefined) {
2692 this.y = data.y;
2693 }
2694 if (data.mode !== undefined) {
2695 this.mode = data.mode;
2696 }
2697 if (data.radius !== undefined) {
2698 this.radius = data.radius;
2699 }
2700 }
2701}
2702;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/MoveGravity.js
2703
2704class MoveGravity {
2705 constructor() {
2706 this.acceleration = 9.81;
2707 this.enable = false;
2708 this.inverse = false;
2709 this.maxSpeed = 50;
2710 }
2711 load(data) {
2712 if (!data) {
2713 return;
2714 }
2715 if (data.acceleration !== undefined) {
2716 this.acceleration = setRangeValue(data.acceleration);
2717 }
2718 if (data.enable !== undefined) {
2719 this.enable = data.enable;
2720 }
2721 if (data.inverse !== undefined) {
2722 this.inverse = data.inverse;
2723 }
2724 if (data.maxSpeed !== undefined) {
2725 this.maxSpeed = setRangeValue(data.maxSpeed);
2726 }
2727 }
2728}
2729;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/Path/MovePath.js
2730
2731
2732class MovePath {
2733 constructor() {
2734 this.clamp = true;
2735 this.delay = new ValueWithRandom();
2736 this.enable = false;
2737 this.options = {};
2738 }
2739 load(data) {
2740 if (!data) {
2741 return;
2742 }
2743 if (data.clamp !== undefined) {
2744 this.clamp = data.clamp;
2745 }
2746 this.delay.load(data.delay);
2747 if (data.enable !== undefined) {
2748 this.enable = data.enable;
2749 }
2750 this.generator = data.generator;
2751 if (data.options) {
2752 this.options = deepExtend(this.options, data.options);
2753 }
2754 }
2755}
2756;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/MoveTrailFill.js
2757
2758class MoveTrailFill {
2759 load(data) {
2760 if (!data) {
2761 return;
2762 }
2763 if (data.color !== undefined) {
2764 this.color = OptionsColor.create(this.color, data.color);
2765 }
2766 if (data.image !== undefined) {
2767 this.image = data.image;
2768 }
2769 }
2770}
2771;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/MoveTrail.js
2772
2773class MoveTrail {
2774 constructor() {
2775 this.enable = false;
2776 this.length = 10;
2777 this.fill = new MoveTrailFill();
2778 }
2779 get fillColor() {
2780 return this.fill.color;
2781 }
2782 set fillColor(value) {
2783 this.fill.load({
2784 color: value
2785 });
2786 }
2787 load(data) {
2788 if (!data) {
2789 return;
2790 }
2791 if (data.enable !== undefined) {
2792 this.enable = data.enable;
2793 }
2794 if (data.fill !== undefined || data.fillColor !== undefined) {
2795 this.fill.load(data.fill || {
2796 color: data.fillColor
2797 });
2798 }
2799 if (data.length !== undefined) {
2800 this.length = data.length;
2801 }
2802 }
2803}
2804;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/OutModes.js
2805class OutModes {
2806 constructor() {
2807 this.default = "out";
2808 }
2809 load(data) {
2810 var _a, _b, _c, _d;
2811 if (!data) {
2812 return;
2813 }
2814 if (data.default !== undefined) {
2815 this.default = data.default;
2816 }
2817 this.bottom = (_a = data.bottom) !== null && _a !== void 0 ? _a : data.default;
2818 this.left = (_b = data.left) !== null && _b !== void 0 ? _b : data.default;
2819 this.right = (_c = data.right) !== null && _c !== void 0 ? _c : data.default;
2820 this.top = (_d = data.top) !== null && _d !== void 0 ? _d : data.default;
2821 }
2822}
2823;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/Spin.js
2824
2825
2826class Spin {
2827 constructor() {
2828 this.acceleration = 0;
2829 this.enable = false;
2830 }
2831 load(data) {
2832 if (!data) {
2833 return;
2834 }
2835 if (data.acceleration !== undefined) {
2836 this.acceleration = setRangeValue(data.acceleration);
2837 }
2838 if (data.enable !== undefined) {
2839 this.enable = data.enable;
2840 }
2841 this.position = data.position ? deepExtend({}, data.position) : undefined;
2842 }
2843}
2844;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/Move.js
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854class Move {
2855 constructor() {
2856 this.angle = new MoveAngle();
2857 this.attract = new MoveAttract();
2858 this.center = new MoveCenter();
2859 this.decay = 0;
2860 this.distance = {};
2861 this.direction = "none";
2862 this.drift = 0;
2863 this.enable = false;
2864 this.gravity = new MoveGravity();
2865 this.path = new MovePath();
2866 this.outModes = new OutModes();
2867 this.random = false;
2868 this.size = false;
2869 this.speed = 2;
2870 this.spin = new Spin();
2871 this.straight = false;
2872 this.trail = new MoveTrail();
2873 this.vibrate = false;
2874 this.warp = false;
2875 }
2876 get bounce() {
2877 return this.collisions;
2878 }
2879 set bounce(value) {
2880 this.collisions = value;
2881 }
2882 get collisions() {
2883 return false;
2884 }
2885 set collisions(_) {}
2886 get noise() {
2887 return this.path;
2888 }
2889 set noise(value) {
2890 this.path = value;
2891 }
2892 get outMode() {
2893 return this.outModes.default;
2894 }
2895 set outMode(value) {
2896 this.outModes.default = value;
2897 }
2898 get out_mode() {
2899 return this.outMode;
2900 }
2901 set out_mode(value) {
2902 this.outMode = value;
2903 }
2904 load(data) {
2905 var _a, _b, _c;
2906 if (!data) {
2907 return;
2908 }
2909 this.angle.load(typeof data.angle === "number" ? {
2910 value: data.angle
2911 } : data.angle);
2912 this.attract.load(data.attract);
2913 this.center.load(data.center);
2914 if (data.decay !== undefined) {
2915 this.decay = setRangeValue(data.decay);
2916 }
2917 if (data.direction !== undefined) {
2918 this.direction = data.direction;
2919 }
2920 if (data.distance !== undefined) {
2921 this.distance = typeof data.distance === "number" ? {
2922 horizontal: data.distance,
2923 vertical: data.distance
2924 } : Object.assign({}, data.distance);
2925 }
2926 if (data.drift !== undefined) {
2927 this.drift = setRangeValue(data.drift);
2928 }
2929 if (data.enable !== undefined) {
2930 this.enable = data.enable;
2931 }
2932 this.gravity.load(data.gravity);
2933 const outModes = (_b = (_a = data.outModes) !== null && _a !== void 0 ? _a : data.outMode) !== null && _b !== void 0 ? _b : data.out_mode;
2934 if (outModes !== undefined) {
2935 if (typeof outModes === "object") {
2936 this.outModes.load(outModes);
2937 } else {
2938 this.outModes.load({
2939 default: outModes
2940 });
2941 }
2942 }
2943 this.path.load((_c = data.path) !== null && _c !== void 0 ? _c : data.noise);
2944 if (data.random !== undefined) {
2945 this.random = data.random;
2946 }
2947 if (data.size !== undefined) {
2948 this.size = data.size;
2949 }
2950 if (data.speed !== undefined) {
2951 this.speed = setRangeValue(data.speed);
2952 }
2953 this.spin.load(data.spin);
2954 if (data.straight !== undefined) {
2955 this.straight = data.straight;
2956 }
2957 this.trail.load(data.trail);
2958 if (data.vibrate !== undefined) {
2959 this.vibrate = data.vibrate;
2960 }
2961 if (data.warp !== undefined) {
2962 this.warp = data.warp;
2963 }
2964 }
2965}
2966;// CONCATENATED MODULE: ./dist/browser/Options/Classes/AnimationOptions.js
2967
2968class AnimationOptions {
2969 constructor() {
2970 this.count = 0;
2971 this.enable = false;
2972 this.speed = 1;
2973 this.decay = 0;
2974 this.sync = false;
2975 }
2976 load(data) {
2977 if (!data) {
2978 return;
2979 }
2980 if (data.count !== undefined) {
2981 this.count = setRangeValue(data.count);
2982 }
2983 if (data.enable !== undefined) {
2984 this.enable = data.enable;
2985 }
2986 if (data.speed !== undefined) {
2987 this.speed = setRangeValue(data.speed);
2988 }
2989 if (data.decay !== undefined) {
2990 this.decay = setRangeValue(data.decay);
2991 }
2992 if (data.sync !== undefined) {
2993 this.sync = data.sync;
2994 }
2995 }
2996}
2997;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js
2998
2999class OpacityAnimation extends AnimationOptions {
3000 constructor() {
3001 super();
3002 this.destroy = "none";
3003 this.enable = false;
3004 this.speed = 2;
3005 this.startValue = "random";
3006 this.sync = false;
3007 }
3008 get opacity_min() {
3009 return this.minimumValue;
3010 }
3011 set opacity_min(value) {
3012 this.minimumValue = value;
3013 }
3014 load(data) {
3015 var _a;
3016 if (!data) {
3017 return;
3018 }
3019 super.load(data);
3020 if (data.destroy !== undefined) {
3021 this.destroy = data.destroy;
3022 }
3023 if (data.enable !== undefined) {
3024 this.enable = data.enable;
3025 }
3026 this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.opacity_min;
3027 if (data.speed !== undefined) {
3028 this.speed = data.speed;
3029 }
3030 if (data.startValue !== undefined) {
3031 this.startValue = data.startValue;
3032 }
3033 if (data.sync !== undefined) {
3034 this.sync = data.sync;
3035 }
3036 }
3037}
3038;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Opacity/Opacity.js
3039
3040
3041
3042class Opacity extends ValueWithRandom {
3043 constructor() {
3044 super();
3045 this.animation = new OpacityAnimation();
3046 this.random.minimumValue = 0.1;
3047 this.value = 1;
3048 }
3049 get anim() {
3050 return this.animation;
3051 }
3052 set anim(value) {
3053 this.animation = value;
3054 }
3055 load(data) {
3056 var _a;
3057 if (!data) {
3058 return;
3059 }
3060 super.load(data);
3061 const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
3062 if (animation !== undefined) {
3063 this.animation.load(animation);
3064 this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
3065 }
3066 }
3067}
3068;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Number/ParticlesDensity.js
3069class ParticlesDensity {
3070 constructor() {
3071 this.enable = false;
3072 this.width = 1920;
3073 this.height = 1080;
3074 }
3075 get area() {
3076 return this.width;
3077 }
3078 set area(value) {
3079 this.width = value;
3080 }
3081 get factor() {
3082 return this.height;
3083 }
3084 set factor(value) {
3085 this.height = value;
3086 }
3087 get value_area() {
3088 return this.area;
3089 }
3090 set value_area(value) {
3091 this.area = value;
3092 }
3093 load(data) {
3094 var _a, _b, _c;
3095 if (!data) {
3096 return;
3097 }
3098 if (data.enable !== undefined) {
3099 this.enable = data.enable;
3100 }
3101 const width = (_b = (_a = data.width) !== null && _a !== void 0 ? _a : data.area) !== null && _b !== void 0 ? _b : data.value_area;
3102 if (width !== undefined) {
3103 this.width = width;
3104 }
3105 const height = (_c = data.height) !== null && _c !== void 0 ? _c : data.factor;
3106 if (height !== undefined) {
3107 this.height = height;
3108 }
3109 }
3110}
3111;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Number/ParticlesNumber.js
3112
3113class ParticlesNumber {
3114 constructor() {
3115 this.density = new ParticlesDensity();
3116 this.limit = 0;
3117 this.value = 100;
3118 }
3119 get max() {
3120 return this.limit;
3121 }
3122 set max(value) {
3123 this.limit = value;
3124 }
3125 load(data) {
3126 var _a;
3127 if (!data) {
3128 return;
3129 }
3130 this.density.load(data.density);
3131 const limit = (_a = data.limit) !== null && _a !== void 0 ? _a : data.max;
3132 if (limit !== undefined) {
3133 this.limit = limit;
3134 }
3135 if (data.value !== undefined) {
3136 this.value = data.value;
3137 }
3138 }
3139}
3140;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Shadow.js
3141
3142class Shadow {
3143 constructor() {
3144 this.blur = 0;
3145 this.color = new OptionsColor();
3146 this.enable = false;
3147 this.offset = {
3148 x: 0,
3149 y: 0
3150 };
3151 this.color.value = "#000";
3152 }
3153 load(data) {
3154 if (!data) {
3155 return;
3156 }
3157 if (data.blur !== undefined) {
3158 this.blur = data.blur;
3159 }
3160 this.color = OptionsColor.create(this.color, data.color);
3161 if (data.enable !== undefined) {
3162 this.enable = data.enable;
3163 }
3164 if (data.offset === undefined) {
3165 return;
3166 }
3167 if (data.offset.x !== undefined) {
3168 this.offset.x = data.offset.x;
3169 }
3170 if (data.offset.y !== undefined) {
3171 this.offset.y = data.offset.y;
3172 }
3173 }
3174}
3175;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Shape/Shape.js
3176
3177const charKey = "character",
3178 charAltKey = "char",
3179 imageKey = "image",
3180 imageAltKey = "images",
3181 polygonKey = "polygon",
3182 polygonAltKey = "star";
3183class Shape {
3184 constructor() {
3185 this.options = {};
3186 this.type = "circle";
3187 }
3188 get character() {
3189 var _a;
3190 return (_a = this.options[charKey]) !== null && _a !== void 0 ? _a : this.options[charAltKey];
3191 }
3192 set character(value) {
3193 this.options[charAltKey] = this.options[charKey] = value;
3194 }
3195 get custom() {
3196 return this.options;
3197 }
3198 set custom(value) {
3199 this.options = value;
3200 }
3201 get image() {
3202 var _a;
3203 return (_a = this.options[imageKey]) !== null && _a !== void 0 ? _a : this.options[imageAltKey];
3204 }
3205 set image(value) {
3206 this.options[imageAltKey] = this.options[imageKey] = value;
3207 }
3208 get images() {
3209 return this.image;
3210 }
3211 set images(value) {
3212 this.image = value;
3213 }
3214 get polygon() {
3215 var _a;
3216 return (_a = this.options[polygonKey]) !== null && _a !== void 0 ? _a : this.options[polygonAltKey];
3217 }
3218 set polygon(value) {
3219 this.options[polygonAltKey] = this.options[polygonKey] = value;
3220 }
3221 get stroke() {
3222 return [];
3223 }
3224 set stroke(_value) {}
3225 load(data) {
3226 var _a, _b, _c;
3227 if (!data) {
3228 return;
3229 }
3230 const options = (_a = data.options) !== null && _a !== void 0 ? _a : data.custom;
3231 if (options !== undefined) {
3232 for (const shape in options) {
3233 const item = options[shape];
3234 if (item) {
3235 this.options[shape] = deepExtend((_b = this.options[shape]) !== null && _b !== void 0 ? _b : {}, item);
3236 }
3237 }
3238 }
3239 this.loadShape(data.character, charKey, charAltKey, true);
3240 this.loadShape(data.polygon, polygonKey, polygonAltKey, false);
3241 this.loadShape((_c = data.image) !== null && _c !== void 0 ? _c : data.images, imageKey, imageAltKey, true);
3242 if (data.type !== undefined) {
3243 this.type = data.type;
3244 }
3245 }
3246 loadShape(item, mainKey, altKey, altOverride) {
3247 var _a, _b;
3248 if (!item) {
3249 return;
3250 }
3251 const isArray = item instanceof Array;
3252 const emptyValue = isArray ? [] : {},
3253 mainDifferentValues = isArray !== this.options[mainKey] instanceof Array,
3254 altDifferentValues = isArray !== this.options[altKey] instanceof Array;
3255 if (mainDifferentValues) {
3256 this.options[mainKey] = emptyValue;
3257 }
3258 if (altDifferentValues && altOverride) {
3259 this.options[altKey] = emptyValue;
3260 }
3261 this.options[mainKey] = deepExtend((_a = this.options[mainKey]) !== null && _a !== void 0 ? _a : emptyValue, item);
3262 if (!this.options[altKey] || altOverride) {
3263 this.options[altKey] = deepExtend((_b = this.options[altKey]) !== null && _b !== void 0 ? _b : emptyValue, item);
3264 }
3265 }
3266}
3267;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Size/SizeAnimation.js
3268
3269class SizeAnimation extends AnimationOptions {
3270 constructor() {
3271 super();
3272 this.destroy = "none";
3273 this.enable = false;
3274 this.speed = 5;
3275 this.startValue = "random";
3276 this.sync = false;
3277 }
3278 get size_min() {
3279 return this.minimumValue;
3280 }
3281 set size_min(value) {
3282 this.minimumValue = value;
3283 }
3284 load(data) {
3285 var _a;
3286 super.load(data);
3287 if (!data) {
3288 return;
3289 }
3290 if (data.destroy !== undefined) {
3291 this.destroy = data.destroy;
3292 }
3293 if (data.enable !== undefined) {
3294 this.enable = data.enable;
3295 }
3296 this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.size_min;
3297 if (data.speed !== undefined) {
3298 this.speed = data.speed;
3299 }
3300 if (data.startValue !== undefined) {
3301 this.startValue = data.startValue;
3302 }
3303 if (data.sync !== undefined) {
3304 this.sync = data.sync;
3305 }
3306 }
3307}
3308;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Size/Size.js
3309
3310
3311
3312class Size extends ValueWithRandom {
3313 constructor() {
3314 super();
3315 this.animation = new SizeAnimation();
3316 this.random.minimumValue = 1;
3317 this.value = 3;
3318 }
3319 get anim() {
3320 return this.animation;
3321 }
3322 set anim(value) {
3323 this.animation = value;
3324 }
3325 load(data) {
3326 var _a;
3327 super.load(data);
3328 if (!data) {
3329 return;
3330 }
3331 const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
3332 if (animation !== undefined) {
3333 this.animation.load(animation);
3334 this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
3335 }
3336 }
3337}
3338;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Stroke.js
3339
3340
3341class Stroke {
3342 constructor() {
3343 this.width = 0;
3344 }
3345 load(data) {
3346 if (!data) {
3347 return;
3348 }
3349 if (data.color !== undefined) {
3350 this.color = AnimatableColor.create(this.color, data.color);
3351 }
3352 if (data.width !== undefined) {
3353 this.width = setRangeValue(data.width);
3354 }
3355 if (data.opacity !== undefined) {
3356 this.opacity = setRangeValue(data.opacity);
3357 }
3358 }
3359}
3360;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/ZIndex/ZIndex.js
3361
3362class ZIndex extends ValueWithRandom {
3363 constructor() {
3364 super();
3365 this.opacityRate = 1;
3366 this.sizeRate = 1;
3367 this.velocityRate = 1;
3368 }
3369 load(data) {
3370 super.load(data);
3371 if (!data) {
3372 return;
3373 }
3374 if (data.opacityRate !== undefined) {
3375 this.opacityRate = data.opacityRate;
3376 }
3377 if (data.sizeRate !== undefined) {
3378 this.sizeRate = data.sizeRate;
3379 }
3380 if (data.velocityRate !== undefined) {
3381 this.velocityRate = data.velocityRate;
3382 }
3383 }
3384}
3385;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/ParticlesOptions.js
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398class ParticlesOptions {
3399 constructor(engine, container) {
3400 this._engine = engine;
3401 this._container = container;
3402 this.bounce = new ParticlesBounce();
3403 this.collisions = new Collisions();
3404 this.color = new AnimatableColor();
3405 this.color.value = "#fff";
3406 this.groups = {};
3407 this.move = new Move();
3408 this.number = new ParticlesNumber();
3409 this.opacity = new Opacity();
3410 this.reduceDuplicates = false;
3411 this.shadow = new Shadow();
3412 this.shape = new Shape();
3413 this.size = new Size();
3414 this.stroke = new Stroke();
3415 this.zIndex = new ZIndex();
3416 }
3417 load(data) {
3418 var _a, _b, _c, _d, _e, _f;
3419 if (!data) {
3420 return;
3421 }
3422 this.bounce.load(data.bounce);
3423 this.color.load(AnimatableColor.create(this.color, data.color));
3424 if (data.groups !== undefined) {
3425 for (const group in data.groups) {
3426 const item = data.groups[group];
3427 if (item !== undefined) {
3428 this.groups[group] = deepExtend((_a = this.groups[group]) !== null && _a !== void 0 ? _a : {}, item);
3429 }
3430 }
3431 }
3432 this.move.load(data.move);
3433 this.number.load(data.number);
3434 this.opacity.load(data.opacity);
3435 if (data.reduceDuplicates !== undefined) {
3436 this.reduceDuplicates = data.reduceDuplicates;
3437 }
3438 this.shape.load(data.shape);
3439 this.size.load(data.size);
3440 this.shadow.load(data.shadow);
3441 this.zIndex.load(data.zIndex);
3442 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;
3443 if (collisions !== undefined) {
3444 this.collisions.enable = collisions;
3445 }
3446 this.collisions.load(data.collisions);
3447 if (data.interactivity !== undefined) {
3448 this.interactivity = deepExtend({}, data.interactivity);
3449 }
3450 const strokeToLoad = (_e = data.stroke) !== null && _e !== void 0 ? _e : (_f = data.shape) === null || _f === void 0 ? void 0 : _f.stroke;
3451 if (strokeToLoad) {
3452 this.stroke = executeOnSingleOrMultiple(strokeToLoad, t => {
3453 const tmp = new Stroke();
3454 tmp.load(t);
3455 return tmp;
3456 });
3457 }
3458 if (this._container) {
3459 const updaters = this._engine.plugins.updaters.get(this._container);
3460 if (updaters) {
3461 for (const updater of updaters) {
3462 if (updater.loadOptions) {
3463 updater.loadOptions(this, data);
3464 }
3465 }
3466 }
3467 const interactors = this._engine.plugins.interactors.get(this._container);
3468 if (interactors) {
3469 for (const interactor of interactors) {
3470 if (interactor.loadParticlesOptions) {
3471 interactor.loadParticlesOptions(this, data);
3472 }
3473 }
3474 }
3475 }
3476 }
3477}
3478;// CONCATENATED MODULE: ./dist/browser/Utils/OptionsUtils.js
3479
3480function loadOptions(options, ...sourceOptionsArr) {
3481 for (const sourceOptions of sourceOptionsArr) {
3482 options.load(sourceOptions);
3483 }
3484}
3485function loadParticlesOptions(engine, container, ...sourceOptionsArr) {
3486 const options = new ParticlesOptions(engine, container);
3487 loadOptions(options, ...sourceOptionsArr);
3488 return options;
3489}
3490;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Options.js
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501class Options {
3502 constructor(engine, container) {
3503 this._engine = engine;
3504 this._container = container;
3505 this.autoPlay = true;
3506 this.background = new Background();
3507 this.backgroundMask = new BackgroundMask();
3508 this.defaultThemes = {};
3509 this.delay = 0;
3510 this.fullScreen = new FullScreen();
3511 this.detectRetina = true;
3512 this.duration = 0;
3513 this.fpsLimit = 120;
3514 this.interactivity = new Interactivity(engine, container);
3515 this.manualParticles = [];
3516 this.particles = loadParticlesOptions(this._engine, this._container);
3517 this.pauseOnBlur = true;
3518 this.pauseOnOutsideViewport = true;
3519 this.responsive = [];
3520 this.smooth = false;
3521 this.style = {};
3522 this.themes = [];
3523 this.zLayers = 100;
3524 }
3525 get backgroundMode() {
3526 return this.fullScreen;
3527 }
3528 set backgroundMode(value) {
3529 this.fullScreen.load(value);
3530 }
3531 get fps_limit() {
3532 return this.fpsLimit;
3533 }
3534 set fps_limit(value) {
3535 this.fpsLimit = value;
3536 }
3537 get retina_detect() {
3538 return this.detectRetina;
3539 }
3540 set retina_detect(value) {
3541 this.detectRetina = value;
3542 }
3543 load(data) {
3544 var _a, _b, _c, _d, _e;
3545 if (!data) {
3546 return;
3547 }
3548 if (data.preset !== undefined) {
3549 executeOnSingleOrMultiple(data.preset, preset => this._importPreset(preset));
3550 }
3551 if (data.autoPlay !== undefined) {
3552 this.autoPlay = data.autoPlay;
3553 }
3554 if (data.delay !== undefined) {
3555 this.delay = setRangeValue(data.delay);
3556 }
3557 const detectRetina = (_a = data.detectRetina) !== null && _a !== void 0 ? _a : data.retina_detect;
3558 if (detectRetina !== undefined) {
3559 this.detectRetina = detectRetina;
3560 }
3561 if (data.duration !== undefined) {
3562 this.duration = setRangeValue(data.duration);
3563 }
3564 const fpsLimit = (_b = data.fpsLimit) !== null && _b !== void 0 ? _b : data.fps_limit;
3565 if (fpsLimit !== undefined) {
3566 this.fpsLimit = fpsLimit;
3567 }
3568 if (data.pauseOnBlur !== undefined) {
3569 this.pauseOnBlur = data.pauseOnBlur;
3570 }
3571 if (data.pauseOnOutsideViewport !== undefined) {
3572 this.pauseOnOutsideViewport = data.pauseOnOutsideViewport;
3573 }
3574 if (data.zLayers !== undefined) {
3575 this.zLayers = data.zLayers;
3576 }
3577 this.background.load(data.background);
3578 const fullScreen = (_c = data.fullScreen) !== null && _c !== void 0 ? _c : data.backgroundMode;
3579 if (typeof fullScreen === "boolean") {
3580 this.fullScreen.enable = fullScreen;
3581 } else {
3582 this.fullScreen.load(fullScreen);
3583 }
3584 this.backgroundMask.load(data.backgroundMask);
3585 this.interactivity.load(data.interactivity);
3586 if (data.manualParticles !== undefined) {
3587 this.manualParticles = data.manualParticles.map(t => {
3588 const tmp = new ManualParticle();
3589 tmp.load(t);
3590 return tmp;
3591 });
3592 }
3593 this.particles.load(data.particles);
3594 this.style = deepExtend(this.style, data.style);
3595 this._engine.plugins.loadOptions(this, data);
3596 if (data.smooth !== undefined) {
3597 this.smooth = data.smooth;
3598 }
3599 const interactors = this._engine.plugins.interactors.get(this._container);
3600 if (interactors) {
3601 for (const interactor of interactors) {
3602 if (interactor.loadOptions) {
3603 interactor.loadOptions(this, data);
3604 }
3605 }
3606 }
3607 if (data.responsive !== undefined) {
3608 for (const responsive of data.responsive) {
3609 const optResponsive = new Responsive();
3610 optResponsive.load(responsive);
3611 this.responsive.push(optResponsive);
3612 }
3613 }
3614 this.responsive.sort((a, b) => a.maxWidth - b.maxWidth);
3615 if (data.themes !== undefined) {
3616 for (const theme of data.themes) {
3617 const existingTheme = this.themes.find(t => t.name === theme.name);
3618 if (!existingTheme) {
3619 const optTheme = new Theme();
3620 optTheme.load(theme);
3621 this.themes.push(optTheme);
3622 } else {
3623 existingTheme.load(theme);
3624 }
3625 }
3626 }
3627 this.defaultThemes.dark = (_d = this._findDefaultTheme("dark")) === null || _d === void 0 ? void 0 : _d.name;
3628 this.defaultThemes.light = (_e = this._findDefaultTheme("light")) === null || _e === void 0 ? void 0 : _e.name;
3629 }
3630 setResponsive(width, pxRatio, defaultOptions) {
3631 this.load(defaultOptions);
3632 const responsiveOptions = this.responsive.find(t => t.mode === "screen" && screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
3633 this.load(responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.options);
3634 return responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.maxWidth;
3635 }
3636 setTheme(name) {
3637 if (name) {
3638 const chosenTheme = this.themes.find(theme => theme.name === name);
3639 if (chosenTheme) {
3640 this.load(chosenTheme.options);
3641 }
3642 } else {
3643 const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)"),
3644 clientDarkMode = mediaMatch && mediaMatch.matches,
3645 defaultTheme = this._findDefaultTheme(clientDarkMode ? "dark" : "light");
3646 if (defaultTheme) {
3647 this.load(defaultTheme.options);
3648 }
3649 }
3650 }
3651 _findDefaultTheme(mode) {
3652 var _a;
3653 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");
3654 }
3655 _importPreset(preset) {
3656 this.load(this._engine.plugins.getPreset(preset));
3657 }
3658}
3659;// CONCATENATED MODULE: ./dist/browser/Core/Utils/InteractionManager.js
3660class InteractionManager {
3661 constructor(engine, container) {
3662 this.container = container;
3663 this._engine = engine;
3664 this._interactors = this._engine.plugins.getInteractors(this.container, true);
3665 this._externalInteractors = [];
3666 this._particleInteractors = [];
3667 }
3668 async externalInteract(delta) {
3669 for (const interactor of this._externalInteractors) {
3670 if (interactor.isEnabled()) {
3671 await interactor.interact(delta);
3672 }
3673 }
3674 }
3675 handleClickMode(mode) {
3676 for (const interactor of this._externalInteractors) {
3677 if (interactor.handleClickMode) {
3678 interactor.handleClickMode(mode);
3679 }
3680 }
3681 }
3682 init() {
3683 this._externalInteractors = [];
3684 this._particleInteractors = [];
3685 for (const interactor of this._interactors) {
3686 switch (interactor.type) {
3687 case "external":
3688 this._externalInteractors.push(interactor);
3689 break;
3690 case "particles":
3691 this._particleInteractors.push(interactor);
3692 break;
3693 }
3694 interactor.init();
3695 }
3696 }
3697 async particlesInteract(particle, delta) {
3698 for (const interactor of this._externalInteractors) {
3699 interactor.clear(particle, delta);
3700 }
3701 for (const interactor of this._particleInteractors) {
3702 if (interactor.isEnabled(particle)) {
3703 await interactor.interact(particle, delta);
3704 }
3705 }
3706 }
3707 async reset(particle) {
3708 for (const interactor of this._externalInteractors) {
3709 if (interactor.isEnabled()) {
3710 await interactor.reset(particle);
3711 }
3712 }
3713 for (const interactor of this._particleInteractors) {
3714 if (interactor.isEnabled(particle)) {
3715 await interactor.reset(particle);
3716 }
3717 }
3718 }
3719}
3720;// CONCATENATED MODULE: ./dist/browser/Core/Particle.js
3721
3722
3723
3724
3725
3726
3727
3728
3729const fixOutMode = data => {
3730 if (!isInArray(data.outMode, data.checkModes)) {
3731 return;
3732 }
3733 if (data.coord > data.maxCoord - data.radius * 2) {
3734 data.setCb(-data.radius);
3735 } else if (data.coord < data.radius * 2) {
3736 data.setCb(data.radius);
3737 }
3738};
3739class Particle {
3740 constructor(engine, id, container, position, overrideOptions, group) {
3741 this.container = container;
3742 this._engine = engine;
3743 this.init(id, position, overrideOptions, group);
3744 }
3745 destroy(override) {
3746 var _a;
3747 if (this.unbreakable || this.destroyed) {
3748 return;
3749 }
3750 this.destroyed = true;
3751 this.bubble.inRange = false;
3752 this.slow.inRange = false;
3753 for (const [, plugin] of this.container.plugins) {
3754 if (plugin.particleDestroyed) {
3755 plugin.particleDestroyed(this, override);
3756 }
3757 }
3758 for (const updater of this.container.particles.updaters) {
3759 if (updater.particleDestroyed) {
3760 updater.particleDestroyed(this, override);
3761 }
3762 }
3763 (_a = this.pathGenerator) === null || _a === void 0 ? void 0 : _a.reset(this);
3764 }
3765 draw(delta) {
3766 const container = this.container;
3767 for (const [, plugin] of container.plugins) {
3768 container.canvas.drawParticlePlugin(plugin, this, delta);
3769 }
3770 container.canvas.drawParticle(this, delta);
3771 }
3772 getFillColor() {
3773 var _a;
3774 return this._getRollColor((_a = this.bubble.color) !== null && _a !== void 0 ? _a : getHslFromAnimation(this.color));
3775 }
3776 getMass() {
3777 return this.getRadius() ** 2 * Math.PI / 2;
3778 }
3779 getPosition() {
3780 return {
3781 x: this.position.x + this.offset.x,
3782 y: this.position.y + this.offset.y,
3783 z: this.position.z
3784 };
3785 }
3786 getRadius() {
3787 var _a;
3788 return (_a = this.bubble.radius) !== null && _a !== void 0 ? _a : this.size.value;
3789 }
3790 getStrokeColor() {
3791 var _a;
3792 return this._getRollColor((_a = this.bubble.color) !== null && _a !== void 0 ? _a : getHslFromAnimation(this.strokeColor));
3793 }
3794 init(id, position, overrideOptions, group) {
3795 var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3796 const container = this.container,
3797 engine = this._engine;
3798 this.id = id;
3799 this.group = group;
3800 this.fill = true;
3801 this.pathRotation = false;
3802 this.close = true;
3803 this.lastPathTime = 0;
3804 this.destroyed = false;
3805 this.unbreakable = false;
3806 this.rotation = 0;
3807 this.misplaced = false;
3808 this.retina = {
3809 maxDistance: {}
3810 };
3811 this.outType = "normal";
3812 this.ignoresResizeRatio = true;
3813 const pxRatio = container.retina.pixelRatio,
3814 mainOptions = container.actualOptions,
3815 particlesOptions = loadParticlesOptions(this._engine, container, mainOptions.particles),
3816 shapeType = particlesOptions.shape.type,
3817 {
3818 reduceDuplicates
3819 } = particlesOptions;
3820 this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
3821 const shapeOptions = particlesOptions.shape;
3822 if (overrideOptions && overrideOptions.shape && overrideOptions.shape.type) {
3823 const overrideShapeType = overrideOptions.shape.type,
3824 shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
3825 if (shape) {
3826 this.shape = shape;
3827 shapeOptions.load(overrideOptions.shape);
3828 }
3829 }
3830 this.shapeData = this._loadShapeData(shapeOptions, reduceDuplicates);
3831 particlesOptions.load(overrideOptions);
3832 particlesOptions.load((_a = this.shapeData) === null || _a === void 0 ? void 0 : _a.particles);
3833 this.interactivity = new Interactivity(engine, container);
3834 this.interactivity.load(container.actualOptions.interactivity);
3835 this.interactivity.load(particlesOptions.interactivity);
3836 this.fill = (_c = (_b = this.shapeData) === null || _b === void 0 ? void 0 : _b.fill) !== null && _c !== void 0 ? _c : this.fill;
3837 this.close = (_e = (_d = this.shapeData) === null || _d === void 0 ? void 0 : _d.close) !== null && _e !== void 0 ? _e : this.close;
3838 this.options = particlesOptions;
3839 const pathOptions = this.options.move.path;
3840 this.pathDelay = getValue(pathOptions.delay) * 1000;
3841 if (pathOptions.generator) {
3842 this.pathGenerator = this._engine.plugins.getPathGenerator(pathOptions.generator);
3843 if (this.pathGenerator && container.addPath(pathOptions.generator, this.pathGenerator)) {
3844 this.pathGenerator.init(container);
3845 }
3846 }
3847 const zIndexValue = getRangeValue(this.options.zIndex.value);
3848 container.retina.initParticle(this);
3849 const sizeOptions = this.options.size,
3850 sizeRange = sizeOptions.value,
3851 sizeAnimation = sizeOptions.animation;
3852 this.size = {
3853 enable: sizeOptions.animation.enable,
3854 value: getRangeValue(sizeOptions.value) * container.retina.pixelRatio,
3855 max: getRangeMax(sizeRange) * pxRatio,
3856 min: getRangeMin(sizeRange) * pxRatio,
3857 loops: 0,
3858 maxLoops: getRangeValue(sizeOptions.animation.count)
3859 };
3860 if (sizeAnimation.enable) {
3861 this.size.status = "increasing";
3862 this.size.decay = 1 - getRangeValue(sizeAnimation.decay);
3863 switch (sizeAnimation.startValue) {
3864 case "min":
3865 this.size.value = this.size.min;
3866 this.size.status = "increasing";
3867 break;
3868 case "random":
3869 this.size.value = randomInRange(this.size);
3870 this.size.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
3871 break;
3872 case "max":
3873 default:
3874 this.size.value = this.size.max;
3875 this.size.status = "decreasing";
3876 break;
3877 }
3878 }
3879 this.size.initialValue = this.size.value;
3880 this.bubble = {
3881 inRange: false
3882 };
3883 this.slow = {
3884 inRange: false,
3885 factor: 1
3886 };
3887 this.position = this._calcPosition(container, position, clamp(zIndexValue, 0, container.zLayers));
3888 this.initialPosition = this.position.copy();
3889 const canvasSize = container.canvas.size,
3890 moveCenter = Object.assign({}, this.options.move.center),
3891 isCenterPercent = moveCenter.mode === "percent";
3892 this.moveCenter = {
3893 x: moveCenter.x * (isCenterPercent ? canvasSize.width / 100 : 1),
3894 y: moveCenter.y * (isCenterPercent ? canvasSize.height / 100 : 1),
3895 radius: (_f = this.options.move.center.radius) !== null && _f !== void 0 ? _f : 0,
3896 mode: (_g = this.options.move.center.mode) !== null && _g !== void 0 ? _g : "percent"
3897 };
3898 this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
3899 switch (this.options.move.direction) {
3900 case "inside":
3901 this.outType = "inside";
3902 break;
3903 case "outside":
3904 this.outType = "outside";
3905 break;
3906 }
3907 this.initialVelocity = this._calculateVelocity();
3908 this.velocity = this.initialVelocity.copy();
3909 this.moveDecay = 1 - getRangeValue(this.options.move.decay);
3910 this.offset = Vector.origin;
3911 const particles = container.particles;
3912 particles.needsSort = particles.needsSort || particles.lastZIndex < this.position.z;
3913 particles.lastZIndex = this.position.z;
3914 this.zIndexFactor = this.position.z / container.zLayers;
3915 this.sides = 24;
3916 let drawer = container.drawers.get(this.shape);
3917 if (!drawer) {
3918 drawer = this._engine.plugins.getShapeDrawer(this.shape);
3919 if (drawer) {
3920 container.drawers.set(this.shape, drawer);
3921 }
3922 }
3923 if (drawer === null || drawer === void 0 ? void 0 : drawer.loadShape) {
3924 drawer === null || drawer === void 0 ? void 0 : drawer.loadShape(this);
3925 }
3926 const sideCountFunc = drawer === null || drawer === void 0 ? void 0 : drawer.getSidesCount;
3927 if (sideCountFunc) {
3928 this.sides = sideCountFunc(this);
3929 }
3930 this.spawning = false;
3931 this.shadowColor = rangeColorToRgb(this.options.shadow.color);
3932 for (const updater of container.particles.updaters) {
3933 updater.init(this);
3934 }
3935 for (const mover of container.particles.movers) {
3936 (_h = mover.init) === null || _h === void 0 ? void 0 : _h.call(mover, this);
3937 }
3938 if (drawer === null || drawer === void 0 ? void 0 : drawer.particleInit) {
3939 drawer.particleInit(container, this);
3940 }
3941 for (const [, plugin] of container.plugins) {
3942 (_j = plugin.particleCreated) === null || _j === void 0 ? void 0 : _j.call(plugin, this);
3943 }
3944 }
3945 isInsideCanvas() {
3946 const radius = this.getRadius(),
3947 canvasSize = this.container.canvas.size;
3948 return this.position.x >= -radius && this.position.y >= -radius && this.position.y <= canvasSize.height + radius && this.position.x <= canvasSize.width + radius;
3949 }
3950 isVisible() {
3951 return !this.destroyed && !this.spawning && this.isInsideCanvas();
3952 }
3953 reset() {
3954 var _a;
3955 for (const updater of this.container.particles.updaters) {
3956 (_a = updater.reset) === null || _a === void 0 ? void 0 : _a.call(updater, this);
3957 }
3958 }
3959 _calcPosition(container, position, zIndex, tryCount = 0) {
3960 var _a, _b, _c, _d;
3961 for (const [, plugin] of container.plugins) {
3962 const pluginPos = plugin.particlePosition !== undefined ? plugin.particlePosition(position, this) : undefined;
3963 if (pluginPos !== undefined) {
3964 return Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
3965 }
3966 }
3967 const canvasSize = container.canvas.size,
3968 exactPosition = calcExactPositionOrRandomFromSize({
3969 size: canvasSize,
3970 position: position
3971 }),
3972 pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex),
3973 radius = this.getRadius(),
3974 outModes = this.options.move.outModes,
3975 fixHorizontal = outMode => {
3976 fixOutMode({
3977 outMode,
3978 checkModes: ["bounce", "bounce-horizontal"],
3979 coord: pos.x,
3980 maxCoord: container.canvas.size.width,
3981 setCb: value => pos.x += value,
3982 radius
3983 });
3984 },
3985 fixVertical = outMode => {
3986 fixOutMode({
3987 outMode,
3988 checkModes: ["bounce", "bounce-vertical"],
3989 coord: pos.y,
3990 maxCoord: container.canvas.size.height,
3991 setCb: value => pos.y += value,
3992 radius
3993 });
3994 };
3995 fixHorizontal((_a = outModes.left) !== null && _a !== void 0 ? _a : outModes.default);
3996 fixHorizontal((_b = outModes.right) !== null && _b !== void 0 ? _b : outModes.default);
3997 fixVertical((_c = outModes.top) !== null && _c !== void 0 ? _c : outModes.default);
3998 fixVertical((_d = outModes.bottom) !== null && _d !== void 0 ? _d : outModes.default);
3999 if (this._checkOverlap(pos, tryCount)) {
4000 return this._calcPosition(container, undefined, zIndex, tryCount + 1);
4001 }
4002 return pos;
4003 }
4004 _calculateVelocity() {
4005 const baseVelocity = getParticleBaseVelocity(this.direction),
4006 res = baseVelocity.copy(),
4007 moveOptions = this.options.move;
4008 if (moveOptions.direction === "inside" || moveOptions.direction === "outside") {
4009 return res;
4010 }
4011 const rad = Math.PI / 180 * getRangeValue(moveOptions.angle.value),
4012 radOffset = Math.PI / 180 * getRangeValue(moveOptions.angle.offset),
4013 range = {
4014 left: radOffset - rad / 2,
4015 right: radOffset + rad / 2
4016 };
4017 if (!moveOptions.straight) {
4018 res.angle += randomInRange(setRangeValue(range.left, range.right));
4019 }
4020 if (moveOptions.random && typeof moveOptions.speed === "number") {
4021 res.length *= getRandom();
4022 }
4023 return res;
4024 }
4025 _checkOverlap(pos, tryCount = 0) {
4026 const collisionsOptions = this.options.collisions,
4027 radius = this.getRadius();
4028 if (!collisionsOptions.enable) {
4029 return false;
4030 }
4031 const overlapOptions = collisionsOptions.overlap;
4032 if (overlapOptions.enable) {
4033 return false;
4034 }
4035 const retries = overlapOptions.retries;
4036 if (retries >= 0 && tryCount > retries) {
4037 throw new Error("Particle is overlapping and can't be placed");
4038 }
4039 let overlaps = false;
4040 for (const particle of this.container.particles.array) {
4041 if (getDistance(pos, particle.position) < radius + particle.getRadius()) {
4042 overlaps = true;
4043 break;
4044 }
4045 }
4046 return overlaps;
4047 }
4048 _getRollColor(color) {
4049 var _a;
4050 if (!color || !this.roll || !this.backColor && !this.roll.alter) {
4051 return color;
4052 }
4053 const backFactor = this.roll.horizontal && this.roll.vertical ? 2 : 1,
4054 backSum = this.roll.horizontal ? Math.PI / 2 : 0,
4055 rolled = Math.floor((((_a = this.roll.angle) !== null && _a !== void 0 ? _a : 0) + backSum) / (Math.PI / backFactor)) % 2;
4056 if (!rolled) {
4057 return color;
4058 }
4059 if (this.backColor) {
4060 return this.backColor;
4061 }
4062 if (this.roll.alter) {
4063 return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
4064 }
4065 return color;
4066 }
4067 _loadShapeData(shapeOptions, reduceDuplicates) {
4068 const shapeData = shapeOptions.options[this.shape];
4069 if (shapeData) {
4070 return deepExtend({}, itemFromSingleOrMultiple(shapeData, this.id, reduceDuplicates));
4071 }
4072 }
4073}
4074;// CONCATENATED MODULE: ./dist/browser/Core/Utils/Point.js
4075class Point {
4076 constructor(position, particle) {
4077 this.position = position;
4078 this.particle = particle;
4079 }
4080}
4081;// CONCATENATED MODULE: ./dist/browser/Core/Utils/Range.js
4082class Range {
4083 constructor(x, y) {
4084 this.position = {
4085 x: x,
4086 y: y
4087 };
4088 }
4089}
4090;// CONCATENATED MODULE: ./dist/browser/Core/Utils/Circle.js
4091
4092
4093class Circle extends Range {
4094 constructor(x, y, radius) {
4095 super(x, y);
4096 this.radius = radius;
4097 }
4098 contains(point) {
4099 return getDistance(point, this.position) <= this.radius;
4100 }
4101 intersects(range) {
4102 const rect = range,
4103 circle = range,
4104 pos1 = this.position,
4105 pos2 = range.position,
4106 distPos = {
4107 x: Math.abs(pos2.x - pos1.x),
4108 y: Math.abs(pos2.y - pos1.y)
4109 },
4110 r = this.radius;
4111 if (circle.radius !== undefined) {
4112 const rSum = r + circle.radius,
4113 dist = Math.sqrt(distPos.x ** 2 + distPos.y ** 2);
4114 return rSum > dist;
4115 } else if (rect.size !== undefined) {
4116 const w = rect.size.width,
4117 h = rect.size.height,
4118 edges = Math.pow(distPos.x - w, 2) + Math.pow(distPos.y - h, 2);
4119 return edges <= r ** 2 || distPos.x <= r + w && distPos.y <= r + h || distPos.x <= w || distPos.y <= h;
4120 }
4121 return false;
4122 }
4123}
4124;// CONCATENATED MODULE: ./dist/browser/Core/Utils/Rectangle.js
4125
4126
4127class Rectangle extends Range {
4128 constructor(x, y, width, height) {
4129 super(x, y);
4130 this.size = {
4131 height: height,
4132 width: width
4133 };
4134 }
4135 contains(point) {
4136 const w = this.size.width,
4137 h = this.size.height,
4138 pos = this.position;
4139 return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
4140 }
4141 intersects(range) {
4142 if (range instanceof Circle) {
4143 range.intersects(this);
4144 }
4145 const w = this.size.width,
4146 h = this.size.height,
4147 pos1 = this.position,
4148 pos2 = range.position,
4149 size2 = range instanceof Rectangle ? range.size : {
4150 width: 0,
4151 height: 0
4152 },
4153 w2 = size2.width,
4154 h2 = size2.height;
4155 return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
4156 }
4157}
4158;// CONCATENATED MODULE: ./dist/browser/Core/Utils/QuadTree.js
4159
4160
4161
4162class QuadTree {
4163 constructor(rectangle, capacity) {
4164 this.rectangle = rectangle;
4165 this.capacity = capacity;
4166 this._points = [];
4167 this._divided = false;
4168 }
4169 insert(point) {
4170 var _a, _b, _c, _d, _e;
4171 if (!this.rectangle.contains(point.position)) {
4172 return false;
4173 }
4174 if (this._points.length < this.capacity) {
4175 this._points.push(point);
4176 return true;
4177 }
4178 if (!this._divided) {
4179 this.subdivide();
4180 }
4181 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;
4182 }
4183 query(range, check, found) {
4184 var _a, _b, _c, _d;
4185 const res = found !== null && found !== void 0 ? found : [];
4186 if (!range.intersects(this.rectangle)) {
4187 return [];
4188 }
4189 for (const p of this._points) {
4190 if (!range.contains(p.position) && getDistance(range.position, p.position) > p.particle.getRadius() && (!check || check(p.particle))) {
4191 continue;
4192 }
4193 res.push(p.particle);
4194 }
4195 if (this._divided) {
4196 (_a = this._NE) === null || _a === void 0 ? void 0 : _a.query(range, check, res);
4197 (_b = this._NW) === null || _b === void 0 ? void 0 : _b.query(range, check, res);
4198 (_c = this._SE) === null || _c === void 0 ? void 0 : _c.query(range, check, res);
4199 (_d = this._SW) === null || _d === void 0 ? void 0 : _d.query(range, check, res);
4200 }
4201 return res;
4202 }
4203 queryCircle(position, radius, check) {
4204 return this.query(new Circle(position.x, position.y, radius), check);
4205 }
4206 queryRectangle(position, size, check) {
4207 return this.query(new Rectangle(position.x, position.y, size.width, size.height), check);
4208 }
4209 subdivide() {
4210 const x = this.rectangle.position.x,
4211 y = this.rectangle.position.y,
4212 w = this.rectangle.size.width,
4213 h = this.rectangle.size.height,
4214 capacity = this.capacity;
4215 this._NE = new QuadTree(new Rectangle(x, y, w / 2, h / 2), capacity);
4216 this._NW = new QuadTree(new Rectangle(x + w / 2, y, w / 2, h / 2), capacity);
4217 this._SE = new QuadTree(new Rectangle(x, y + h / 2, w / 2, h / 2), capacity);
4218 this._SW = new QuadTree(new Rectangle(x + w / 2, y + h / 2, w / 2, h / 2), capacity);
4219 this._divided = true;
4220 }
4221}
4222;// CONCATENATED MODULE: ./dist/browser/Core/Particles.js
4223
4224
4225
4226
4227
4228
4229class Particles {
4230 constructor(engine, container) {
4231 this.container = container;
4232 this._engine = engine;
4233 this.nextId = 0;
4234 this.array = [];
4235 this.zArray = [];
4236 this.pool = [];
4237 this.limit = 0;
4238 this.needsSort = false;
4239 this.lastZIndex = 0;
4240 this.interactionManager = new InteractionManager(this._engine, container);
4241 const canvasSize = this.container.canvas.size;
4242 this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
4243 this.movers = this._engine.plugins.getMovers(container, true);
4244 this.updaters = this._engine.plugins.getUpdaters(container, true);
4245 }
4246 get count() {
4247 return this.array.length;
4248 }
4249 addManualParticles() {
4250 const container = this.container,
4251 options = container.actualOptions;
4252 for (const particle of options.manualParticles) {
4253 this.addParticle(calcPositionFromSize({
4254 size: container.canvas.size,
4255 position: particle.position
4256 }), particle.options);
4257 }
4258 }
4259 addParticle(position, overrideOptions, group, initializer) {
4260 const container = this.container,
4261 options = container.actualOptions,
4262 limit = options.particles.number.limit;
4263 if (limit > 0) {
4264 const countToRemove = this.count + 1 - limit;
4265 if (countToRemove > 0) {
4266 this.removeQuantity(countToRemove);
4267 }
4268 }
4269 return this._pushParticle(position, overrideOptions, group, initializer);
4270 }
4271 clear() {
4272 this.array = [];
4273 this.zArray = [];
4274 }
4275 destroy() {
4276 this.array = [];
4277 this.zArray = [];
4278 this.movers = [];
4279 this.updaters = [];
4280 }
4281 async draw(delta) {
4282 const container = this.container,
4283 canvasSize = this.container.canvas.size;
4284 this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
4285 container.canvas.clear();
4286 await this.update(delta);
4287 if (this.needsSort) {
4288 this.zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
4289 this.lastZIndex = this.zArray[this.zArray.length - 1].position.z;
4290 this.needsSort = false;
4291 }
4292 for (const [, plugin] of container.plugins) {
4293 container.canvas.drawPlugin(plugin, delta);
4294 }
4295 for (const p of this.zArray) {
4296 p.draw(delta);
4297 }
4298 }
4299 handleClickMode(mode) {
4300 this.interactionManager.handleClickMode(mode);
4301 }
4302 init() {
4303 var _a;
4304 const container = this.container,
4305 options = container.actualOptions;
4306 this.lastZIndex = 0;
4307 this.needsSort = false;
4308 let handled = false;
4309 this.updaters = this._engine.plugins.getUpdaters(container, true);
4310 this.interactionManager.init();
4311 for (const [, plugin] of container.plugins) {
4312 if (plugin.particlesInitialization !== undefined) {
4313 handled = plugin.particlesInitialization();
4314 }
4315 if (handled) {
4316 break;
4317 }
4318 }
4319 this.interactionManager.init();
4320 for (const [, pathGenerator] of container.pathGenerators) {
4321 pathGenerator.init(container);
4322 }
4323 this.addManualParticles();
4324 if (!handled) {
4325 for (const group in options.particles.groups) {
4326 const groupOptions = options.particles.groups[group];
4327 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++) {
4328 this.addParticle(undefined, groupOptions, group);
4329 }
4330 }
4331 for (let i = this.count; i < options.particles.number.value; i++) {
4332 this.addParticle();
4333 }
4334 }
4335 }
4336 push(nb, mouse, overrideOptions, group) {
4337 this.pushing = true;
4338 for (let i = 0; i < nb; i++) {
4339 this.addParticle(mouse === null || mouse === void 0 ? void 0 : mouse.position, overrideOptions, group);
4340 }
4341 this.pushing = false;
4342 }
4343 async redraw() {
4344 this.clear();
4345 this.init();
4346 await this.draw({
4347 value: 0,
4348 factor: 0
4349 });
4350 }
4351 remove(particle, group, override) {
4352 this.removeAt(this.array.indexOf(particle), undefined, group, override);
4353 }
4354 removeAt(index, quantity = 1, group, override) {
4355 if (index < 0 || index > this.count) {
4356 return;
4357 }
4358 let deleted = 0;
4359 for (let i = index; deleted < quantity && i < this.count; i++) {
4360 const particle = this.array[i];
4361 if (!particle || particle.group !== group) {
4362 continue;
4363 }
4364 particle.destroy(override);
4365 this.array.splice(i--, 1);
4366 const zIdx = this.zArray.indexOf(particle);
4367 this.zArray.splice(zIdx, 1);
4368 this.pool.push(particle);
4369 deleted++;
4370 this._engine.dispatchEvent("particleRemoved", {
4371 container: this.container,
4372 data: {
4373 particle
4374 }
4375 });
4376 }
4377 }
4378 removeQuantity(quantity, group) {
4379 this.removeAt(0, quantity, group);
4380 }
4381 setDensity() {
4382 const options = this.container.actualOptions;
4383 for (const group in options.particles.groups) {
4384 this._applyDensity(options.particles.groups[group], 0, group);
4385 }
4386 this._applyDensity(options.particles, options.manualParticles.length);
4387 }
4388 async update(delta) {
4389 var _a, _b;
4390 const container = this.container,
4391 particlesToDelete = [];
4392 for (const [, pathGenerator] of container.pathGenerators) {
4393 pathGenerator.update();
4394 }
4395 for (const [, plugin] of container.plugins) {
4396 (_a = plugin.update) === null || _a === void 0 ? void 0 : _a.call(plugin, delta);
4397 }
4398 for (const particle of this.array) {
4399 const resizeFactor = container.canvas.resizeFactor;
4400 if (resizeFactor && !particle.ignoresResizeRatio) {
4401 particle.position.x *= resizeFactor.width;
4402 particle.position.y *= resizeFactor.height;
4403 particle.initialPosition.x *= resizeFactor.width;
4404 particle.initialPosition.y *= resizeFactor.height;
4405 }
4406 particle.ignoresResizeRatio = false;
4407 await this.interactionManager.reset(particle);
4408 for (const [, plugin] of this.container.plugins) {
4409 if (particle.destroyed) {
4410 break;
4411 }
4412 (_b = plugin.particleUpdate) === null || _b === void 0 ? void 0 : _b.call(plugin, particle, delta);
4413 }
4414 for (const mover of this.movers) {
4415 if (mover.isEnabled(particle)) {
4416 mover.move(particle, delta);
4417 }
4418 }
4419 if (particle.destroyed) {
4420 particlesToDelete.push(particle);
4421 continue;
4422 }
4423 this.quadTree.insert(new Point(particle.getPosition(), particle));
4424 }
4425 for (const particle of particlesToDelete) {
4426 this.remove(particle);
4427 }
4428 await this.interactionManager.externalInteract(delta);
4429 for (const particle of this.array) {
4430 for (const updater of this.updaters) {
4431 updater.update(particle, delta);
4432 }
4433 if (!particle.destroyed && !particle.spawning) {
4434 await this.interactionManager.particlesInteract(particle, delta);
4435 }
4436 }
4437 delete container.canvas.resizeFactor;
4438 }
4439 _applyDensity(options, manualCount, group) {
4440 var _a;
4441 if (!((_a = options.number.density) === null || _a === void 0 ? void 0 : _a.enable)) {
4442 return;
4443 }
4444 const numberOptions = options.number,
4445 densityFactor = this._initDensityFactor(numberOptions.density),
4446 optParticlesNumber = numberOptions.value,
4447 optParticlesLimit = numberOptions.limit > 0 ? numberOptions.limit : optParticlesNumber,
4448 particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + manualCount,
4449 particlesCount = Math.min(this.count, this.array.filter(t => t.group === group).length);
4450 this.limit = numberOptions.limit * densityFactor;
4451 if (particlesCount < particlesNumber) {
4452 this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
4453 } else if (particlesCount > particlesNumber) {
4454 this.removeQuantity(particlesCount - particlesNumber, group);
4455 }
4456 }
4457 _initDensityFactor(densityOptions) {
4458 const container = this.container;
4459 if (!container.canvas.element || !densityOptions.enable) {
4460 return 1;
4461 }
4462 const canvas = container.canvas.element,
4463 pxRatio = container.retina.pixelRatio;
4464 return canvas.width * canvas.height / (densityOptions.factor * pxRatio ** 2 * densityOptions.area);
4465 }
4466 _pushParticle(position, overrideOptions, group, initializer) {
4467 try {
4468 let particle = this.pool.pop();
4469 if (particle) {
4470 particle.init(this.nextId, position, overrideOptions, group);
4471 } else {
4472 particle = new Particle(this._engine, this.nextId, this.container, position, overrideOptions, group);
4473 }
4474 let canAdd = true;
4475 if (initializer) {
4476 canAdd = initializer(particle);
4477 }
4478 if (!canAdd) {
4479 return;
4480 }
4481 this.array.push(particle);
4482 this.zArray.push(particle);
4483 this.nextId++;
4484 this._engine.dispatchEvent("particleAdded", {
4485 container: this.container,
4486 data: {
4487 particle
4488 }
4489 });
4490 return particle;
4491 } catch (e) {
4492 console.warn(`error adding particle: ${e}`);
4493 return;
4494 }
4495 }
4496}
4497;// CONCATENATED MODULE: ./dist/browser/Core/Retina.js
4498
4499
4500class Retina {
4501 constructor(container) {
4502 this.container = container;
4503 }
4504 init() {
4505 const container = this.container,
4506 options = container.actualOptions;
4507 this.pixelRatio = !options.detectRetina || isSsr() ? 1 : window.devicePixelRatio;
4508 this.reduceFactor = 1;
4509 const ratio = this.pixelRatio;
4510 if (container.canvas.element) {
4511 const element = container.canvas.element;
4512 container.canvas.size.width = element.offsetWidth * ratio;
4513 container.canvas.size.height = element.offsetHeight * ratio;
4514 }
4515 const particles = options.particles;
4516 this.attractDistance = getRangeValue(particles.move.attract.distance) * ratio;
4517 this.sizeAnimationSpeed = getRangeValue(particles.size.animation.speed) * ratio;
4518 this.maxSpeed = getRangeValue(particles.move.gravity.maxSpeed) * ratio;
4519 }
4520 initParticle(particle) {
4521 const options = particle.options,
4522 ratio = this.pixelRatio,
4523 moveDistance = options.move.distance,
4524 props = particle.retina;
4525 props.attractDistance = getRangeValue(options.move.attract.distance) * ratio;
4526 props.moveDrift = getRangeValue(options.move.drift) * ratio;
4527 props.moveSpeed = getRangeValue(options.move.speed) * ratio;
4528 props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
4529 const maxDistance = props.maxDistance;
4530 maxDistance.horizontal = moveDistance.horizontal !== undefined ? moveDistance.horizontal * ratio : undefined;
4531 maxDistance.vertical = moveDistance.vertical !== undefined ? moveDistance.vertical * ratio : undefined;
4532 props.maxSpeed = getRangeValue(options.move.gravity.maxSpeed) * ratio;
4533 }
4534}
4535;// CONCATENATED MODULE: ./dist/browser/Core/Container.js
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545function guardCheck(container) {
4546 return container && !container.destroyed;
4547}
4548function loadContainerOptions(engine, container, ...sourceOptionsArr) {
4549 const options = new Options(engine, container);
4550 loadOptions(options, ...sourceOptionsArr);
4551 return options;
4552}
4553const defaultPathGeneratorKey = "default",
4554 defaultPathGenerator = {
4555 generate: p => {
4556 const v = p.velocity.copy();
4557 v.angle += v.length * Math.PI / 180;
4558 return v;
4559 },
4560 init: () => {},
4561 update: () => {},
4562 reset: () => {}
4563 };
4564class Container {
4565 constructor(engine, id, sourceOptions) {
4566 this.id = id;
4567 this._engine = engine;
4568 this.fpsLimit = 120;
4569 this.smooth = false;
4570 this._delay = 0;
4571 this.duration = 0;
4572 this.lifeTime = 0;
4573 this._firstStart = true;
4574 this.started = false;
4575 this.destroyed = false;
4576 this._paused = true;
4577 this.lastFrameTime = 0;
4578 this.zLayers = 100;
4579 this.pageHidden = false;
4580 this._sourceOptions = sourceOptions;
4581 this._initialSourceOptions = sourceOptions;
4582 this.retina = new Retina(this);
4583 this.canvas = new Canvas(this);
4584 this.particles = new Particles(this._engine, this);
4585 this.frameManager = new FrameManager(this);
4586 this.pathGenerators = new Map();
4587 this.interactivity = {
4588 mouse: {
4589 clicking: false,
4590 inside: false
4591 }
4592 };
4593 this.plugins = new Map();
4594 this.drawers = new Map();
4595 this._options = loadContainerOptions(this._engine, this);
4596 this.actualOptions = loadContainerOptions(this._engine, this);
4597 this._eventListeners = new EventListeners(this);
4598 if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) {
4599 this._intersectionObserver = new IntersectionObserver(entries => this._intersectionManager(entries));
4600 }
4601 this._engine.dispatchEvent("containerBuilt", {
4602 container: this
4603 });
4604 }
4605 get options() {
4606 return this._options;
4607 }
4608 get sourceOptions() {
4609 return this._sourceOptions;
4610 }
4611 addClickHandler(callback) {
4612 if (!guardCheck(this)) {
4613 return;
4614 }
4615 const el = this.interactivity.element;
4616 if (!el) {
4617 return;
4618 }
4619 const clickOrTouchHandler = (e, pos, radius) => {
4620 if (!guardCheck(this)) {
4621 return;
4622 }
4623 const pxRatio = this.retina.pixelRatio,
4624 posRetina = {
4625 x: pos.x * pxRatio,
4626 y: pos.y * pxRatio
4627 },
4628 particles = this.particles.quadTree.queryCircle(posRetina, radius * pxRatio);
4629 callback(e, particles);
4630 };
4631 const clickHandler = e => {
4632 if (!guardCheck(this)) {
4633 return;
4634 }
4635 const mouseEvent = e,
4636 pos = {
4637 x: mouseEvent.offsetX || mouseEvent.clientX,
4638 y: mouseEvent.offsetY || mouseEvent.clientY
4639 };
4640 clickOrTouchHandler(e, pos, 1);
4641 };
4642 const touchStartHandler = () => {
4643 if (!guardCheck(this)) {
4644 return;
4645 }
4646 touched = true;
4647 touchMoved = false;
4648 };
4649 const touchMoveHandler = () => {
4650 if (!guardCheck(this)) {
4651 return;
4652 }
4653 touchMoved = true;
4654 };
4655 const touchEndHandler = e => {
4656 if (!guardCheck(this)) {
4657 return;
4658 }
4659 if (touched && !touchMoved) {
4660 const touchEvent = e;
4661 let lastTouch = touchEvent.touches[touchEvent.touches.length - 1];
4662 if (!lastTouch) {
4663 lastTouch = touchEvent.changedTouches[touchEvent.changedTouches.length - 1];
4664 if (!lastTouch) {
4665 return;
4666 }
4667 }
4668 const element = this.canvas.element,
4669 canvasRect = element ? element.getBoundingClientRect() : undefined,
4670 pos = {
4671 x: lastTouch.clientX - (canvasRect ? canvasRect.left : 0),
4672 y: lastTouch.clientY - (canvasRect ? canvasRect.top : 0)
4673 };
4674 clickOrTouchHandler(e, pos, Math.max(lastTouch.radiusX, lastTouch.radiusY));
4675 }
4676 touched = false;
4677 touchMoved = false;
4678 };
4679 const touchCancelHandler = () => {
4680 if (!guardCheck(this)) {
4681 return;
4682 }
4683 touched = false;
4684 touchMoved = false;
4685 };
4686 let touched = false,
4687 touchMoved = false;
4688 el.addEventListener("click", clickHandler);
4689 el.addEventListener("touchstart", touchStartHandler);
4690 el.addEventListener("touchmove", touchMoveHandler);
4691 el.addEventListener("touchend", touchEndHandler);
4692 el.addEventListener("touchcancel", touchCancelHandler);
4693 }
4694 addPath(key, generator, override = false) {
4695 if (!guardCheck(this) || !override && this.pathGenerators.has(key)) {
4696 return false;
4697 }
4698 this.pathGenerators.set(key, generator !== null && generator !== void 0 ? generator : defaultPathGenerator);
4699 return true;
4700 }
4701 destroy() {
4702 if (!guardCheck(this)) {
4703 return;
4704 }
4705 this.stop();
4706 this.particles.destroy();
4707 this.canvas.destroy();
4708 for (const [, drawer] of this.drawers) {
4709 if (drawer.destroy) {
4710 drawer.destroy(this);
4711 }
4712 }
4713 for (const key of this.drawers.keys()) {
4714 this.drawers.delete(key);
4715 }
4716 this._engine.plugins.destroy(this);
4717 this.destroyed = true;
4718 const mainArr = this._engine.dom(),
4719 idx = mainArr.findIndex(t => t === this);
4720 if (idx >= 0) {
4721 mainArr.splice(idx, 1);
4722 }
4723 this._engine.dispatchEvent("containerDestroyed", {
4724 container: this
4725 });
4726 }
4727 draw(force) {
4728 if (!guardCheck(this)) {
4729 return;
4730 }
4731 let refreshTime = force;
4732 this._drawAnimationFrame = animate()(async timestamp => {
4733 if (refreshTime) {
4734 this.lastFrameTime = undefined;
4735 refreshTime = false;
4736 }
4737 await this.frameManager.nextFrame(timestamp);
4738 });
4739 }
4740 exportConfiguration() {
4741 return JSON.stringify(this.actualOptions, (key, value) => {
4742 if (key === "_engine" || key === "_container") {
4743 return;
4744 }
4745 return value;
4746 }, 2);
4747 }
4748 exportImage(callback, type, quality) {
4749 const element = this.canvas.element;
4750 if (element) {
4751 element.toBlob(callback, type !== null && type !== void 0 ? type : "image/png", quality);
4752 }
4753 }
4754 exportImg(callback) {
4755 this.exportImage(callback);
4756 }
4757 getAnimationStatus() {
4758 return !this._paused && !this.pageHidden && guardCheck(this);
4759 }
4760 handleClickMode(mode) {
4761 if (!guardCheck(this)) {
4762 return;
4763 }
4764 this.particles.handleClickMode(mode);
4765 for (const [, plugin] of this.plugins) {
4766 if (plugin.handleClickMode) {
4767 plugin.handleClickMode(mode);
4768 }
4769 }
4770 }
4771 async init() {
4772 if (!guardCheck(this)) {
4773 return;
4774 }
4775 const shapes = this._engine.plugins.getSupportedShapes();
4776 for (const type of shapes) {
4777 const drawer = this._engine.plugins.getShapeDrawer(type);
4778 if (drawer) {
4779 this.drawers.set(type, drawer);
4780 }
4781 }
4782 this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
4783 this.actualOptions = loadContainerOptions(this._engine, this, this._options);
4784 const availablePlugins = this._engine.plugins.getAvailablePlugins(this);
4785 for (const [id, plugin] of availablePlugins) {
4786 this.plugins.set(id, plugin);
4787 }
4788 this.retina.init();
4789 await this.canvas.init();
4790 this.updateActualOptions();
4791 this.canvas.initBackground();
4792 this.canvas.resize();
4793 this.zLayers = this.actualOptions.zLayers;
4794 this.duration = getRangeValue(this.actualOptions.duration) * 1000;
4795 this._delay = getRangeValue(this.actualOptions.delay) * 1000;
4796 this.lifeTime = 0;
4797 this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
4798 this.smooth = this.actualOptions.smooth;
4799 for (const [, drawer] of this.drawers) {
4800 if (drawer.init) {
4801 await drawer.init(this);
4802 }
4803 }
4804 for (const [, plugin] of this.plugins) {
4805 if (plugin.init) {
4806 await plugin.init();
4807 }
4808 }
4809 this._engine.dispatchEvent("containerInit", {
4810 container: this
4811 });
4812 this.particles.init();
4813 this.particles.setDensity();
4814 for (const [, plugin] of this.plugins) {
4815 if (plugin.particlesSetup) {
4816 plugin.particlesSetup();
4817 }
4818 }
4819 this._engine.dispatchEvent("particlesSetup", {
4820 container: this
4821 });
4822 }
4823 async loadTheme(name) {
4824 if (!guardCheck(this)) {
4825 return;
4826 }
4827 this._currentTheme = name;
4828 await this.refresh();
4829 }
4830 pause() {
4831 if (!guardCheck(this)) {
4832 return;
4833 }
4834 if (this._drawAnimationFrame !== undefined) {
4835 cancelAnimation()(this._drawAnimationFrame);
4836 delete this._drawAnimationFrame;
4837 }
4838 if (this._paused) {
4839 return;
4840 }
4841 for (const [, plugin] of this.plugins) {
4842 if (plugin.pause) {
4843 plugin.pause();
4844 }
4845 }
4846 if (!this.pageHidden) {
4847 this._paused = true;
4848 }
4849 this._engine.dispatchEvent("containerPaused", {
4850 container: this
4851 });
4852 }
4853 play(force) {
4854 if (!guardCheck(this)) {
4855 return;
4856 }
4857 const needsUpdate = this._paused || force;
4858 if (this._firstStart && !this.actualOptions.autoPlay) {
4859 this._firstStart = false;
4860 return;
4861 }
4862 if (this._paused) {
4863 this._paused = false;
4864 }
4865 if (needsUpdate) {
4866 for (const [, plugin] of this.plugins) {
4867 if (plugin.play) {
4868 plugin.play();
4869 }
4870 }
4871 }
4872 this._engine.dispatchEvent("containerPlay", {
4873 container: this
4874 });
4875 this.draw(needsUpdate || false);
4876 }
4877 async refresh() {
4878 if (!guardCheck(this)) {
4879 return;
4880 }
4881 this.stop();
4882 return this.start();
4883 }
4884 async reset() {
4885 if (!guardCheck(this)) {
4886 return;
4887 }
4888 this._options = loadContainerOptions(this._engine, this);
4889 return this.refresh();
4890 }
4891 setNoise(noiseOrGenerator, init, update) {
4892 if (!guardCheck(this)) {
4893 return;
4894 }
4895 this.setPath(noiseOrGenerator, init, update);
4896 }
4897 setPath(pathOrGenerator, init, update) {
4898 if (!pathOrGenerator || !guardCheck(this)) {
4899 return;
4900 }
4901 const pathGenerator = Object.assign({}, defaultPathGenerator);
4902 if (typeof pathOrGenerator === "function") {
4903 pathGenerator.generate = pathOrGenerator;
4904 if (init) {
4905 pathGenerator.init = init;
4906 }
4907 if (update) {
4908 pathGenerator.update = update;
4909 }
4910 } else {
4911 const oldGenerator = pathGenerator;
4912 pathGenerator.generate = pathOrGenerator.generate || oldGenerator.generate;
4913 pathGenerator.init = pathOrGenerator.init || oldGenerator.init;
4914 pathGenerator.update = pathOrGenerator.update || oldGenerator.update;
4915 }
4916 this.addPath(defaultPathGeneratorKey, pathGenerator, true);
4917 }
4918 async start() {
4919 if (!guardCheck(this) || this.started) {
4920 return;
4921 }
4922 await this.init();
4923 this.started = true;
4924 await new Promise(resolve => {
4925 this._delayTimeout = setTimeout(async () => {
4926 this._eventListeners.addListeners();
4927 if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
4928 this._intersectionObserver.observe(this.interactivity.element);
4929 }
4930 for (const [, plugin] of this.plugins) {
4931 if (plugin.start) {
4932 await plugin.start();
4933 }
4934 }
4935 this._engine.dispatchEvent("containerStarted", {
4936 container: this
4937 });
4938 this.play();
4939 resolve();
4940 }, this._delay);
4941 });
4942 }
4943 stop() {
4944 if (!guardCheck(this) || !this.started) {
4945 return;
4946 }
4947 if (this._delayTimeout) {
4948 clearTimeout(this._delayTimeout);
4949 delete this._delayTimeout;
4950 }
4951 this._firstStart = true;
4952 this.started = false;
4953 this._eventListeners.removeListeners();
4954 this.pause();
4955 this.particles.clear();
4956 this.canvas.clear();
4957 if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
4958 this._intersectionObserver.unobserve(this.interactivity.element);
4959 }
4960 for (const [, plugin] of this.plugins) {
4961 if (plugin.stop) {
4962 plugin.stop();
4963 }
4964 }
4965 for (const key of this.plugins.keys()) {
4966 this.plugins.delete(key);
4967 }
4968 this._sourceOptions = this._options;
4969 this._engine.dispatchEvent("containerStopped", {
4970 container: this
4971 });
4972 }
4973 updateActualOptions() {
4974 this.actualOptions.responsive = [];
4975 const newMaxWidth = this.actualOptions.setResponsive(this.canvas.size.width, this.retina.pixelRatio, this._options);
4976 this.actualOptions.setTheme(this._currentTheme);
4977 if (this.responsiveMaxWidth === newMaxWidth) {
4978 return false;
4979 }
4980 this.responsiveMaxWidth = newMaxWidth;
4981 return true;
4982 }
4983 _intersectionManager(entries) {
4984 if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
4985 return;
4986 }
4987 for (const entry of entries) {
4988 if (entry.target !== this.interactivity.element) {
4989 continue;
4990 }
4991 (entry.isIntersecting ? this.play : this.pause)();
4992 }
4993 }
4994}
4995;// CONCATENATED MODULE: ./dist/browser/Core/Loader.js
4996
4997
4998
4999
5000async function getDataFromUrl(jsonUrl, index) {
5001 const url = itemFromSingleOrMultiple(jsonUrl, index);
5002 if (!url) {
5003 return;
5004 }
5005 const response = await fetch(url);
5006 if (response.ok) {
5007 return response.json();
5008 }
5009 console.error(`tsParticles - Error ${response.status} while retrieving config file`);
5010}
5011class Loader {
5012 constructor(engine) {
5013 this._engine = engine;
5014 }
5015 load(tagId, options, index) {
5016 const params = {
5017 index,
5018 remote: false
5019 };
5020 if (typeof tagId === "string") {
5021 params.tagId = tagId;
5022 } else {
5023 params.options = tagId;
5024 }
5025 if (typeof options === "number") {
5026 params.index = options;
5027 } else {
5028 params.options = options !== null && options !== void 0 ? options : params.options;
5029 }
5030 return this.loadOptions(params);
5031 }
5032 async loadJSON(tagId, jsonUrl, index) {
5033 let url, id;
5034 if (typeof jsonUrl === "number" || jsonUrl === undefined) {
5035 url = tagId;
5036 } else {
5037 id = tagId;
5038 url = jsonUrl;
5039 }
5040 return this.loadRemoteOptions({
5041 tagId: id,
5042 url,
5043 index,
5044 remote: true
5045 });
5046 }
5047 async loadOptions(params) {
5048 var _a, _b, _c;
5049 const tagId = (_a = params.tagId) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(getRandom() * 10000)}`,
5050 {
5051 index,
5052 url: jsonUrl,
5053 remote
5054 } = params,
5055 options = remote ? await getDataFromUrl(jsonUrl, index) : params.options;
5056 let domContainer = (_b = params.element) !== null && _b !== void 0 ? _b : document.getElementById(tagId);
5057 if (!domContainer) {
5058 domContainer = document.createElement("div");
5059 domContainer.id = tagId;
5060 (_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
5061 }
5062 const currentOptions = itemFromSingleOrMultiple(options, index),
5063 dom = this._engine.dom(),
5064 oldIndex = dom.findIndex(v => v.id === tagId);
5065 if (oldIndex >= 0) {
5066 const old = this._engine.domItem(oldIndex);
5067 if (old && !old.destroyed) {
5068 old.destroy();
5069 dom.splice(oldIndex, 1);
5070 }
5071 }
5072 let canvasEl;
5073 if (domContainer.tagName.toLowerCase() === "canvas") {
5074 canvasEl = domContainer;
5075 canvasEl.dataset[generatedAttribute] = "false";
5076 } else {
5077 const existingCanvases = domContainer.getElementsByTagName("canvas");
5078 if (existingCanvases.length) {
5079 canvasEl = existingCanvases[0];
5080 canvasEl.dataset[generatedAttribute] = "false";
5081 } else {
5082 canvasEl = document.createElement("canvas");
5083 canvasEl.dataset[generatedAttribute] = "true";
5084 domContainer.appendChild(canvasEl);
5085 }
5086 }
5087 if (!canvasEl.style.width) {
5088 canvasEl.style.width = "100%";
5089 }
5090 if (!canvasEl.style.height) {
5091 canvasEl.style.height = "100%";
5092 }
5093 const newItem = new Container(this._engine, tagId, currentOptions);
5094 if (oldIndex >= 0) {
5095 dom.splice(oldIndex, 0, newItem);
5096 } else {
5097 dom.push(newItem);
5098 }
5099 newItem.canvas.loadCanvas(canvasEl);
5100 await newItem.start();
5101 return newItem;
5102 }
5103 async loadRemoteOptions(params) {
5104 return this.loadOptions(params);
5105 }
5106 async set(id, domContainer, options, index) {
5107 const params = {
5108 index,
5109 remote: false
5110 };
5111 if (typeof id === "string") {
5112 params.tagId = id;
5113 } else {
5114 params.element = id;
5115 }
5116 if (domContainer instanceof HTMLElement) {
5117 params.element = domContainer;
5118 } else {
5119 params.options = domContainer;
5120 }
5121 if (typeof options === "number") {
5122 params.index = options;
5123 } else {
5124 params.options = options !== null && options !== void 0 ? options : params.options;
5125 }
5126 return this.loadOptions(params);
5127 }
5128 async setJSON(id, domContainer, jsonUrl, index) {
5129 let url, newId, newIndex, element;
5130 if (id instanceof HTMLElement) {
5131 element = id;
5132 url = domContainer;
5133 newIndex = jsonUrl;
5134 } else {
5135 newId = id;
5136 element = domContainer;
5137 url = jsonUrl;
5138 newIndex = index;
5139 }
5140 return this.loadRemoteOptions({
5141 tagId: newId,
5142 url,
5143 index: newIndex,
5144 element,
5145 remote: true
5146 });
5147 }
5148}
5149;// CONCATENATED MODULE: ./dist/browser/Core/Utils/Plugins.js
5150
5151function getItemsFromInitializer(container, map, initializers, force = false) {
5152 let res = map.get(container);
5153 if (!res || force) {
5154 res = [...initializers.values()].map(t => t(container));
5155 map.set(container, res);
5156 }
5157 return res;
5158}
5159class Plugins {
5160 constructor(engine) {
5161 this._engine = engine;
5162 this.plugins = [];
5163 this._initializers = {
5164 interactors: new Map(),
5165 movers: new Map(),
5166 updaters: new Map()
5167 };
5168 this.interactors = new Map();
5169 this.movers = new Map();
5170 this.updaters = new Map();
5171 this.presets = new Map();
5172 this.drawers = new Map();
5173 this.pathGenerators = new Map();
5174 }
5175 addInteractor(name, initInteractor) {
5176 this._initializers.interactors.set(name, initInteractor);
5177 }
5178 addParticleMover(name, initMover) {
5179 this._initializers.movers.set(name, initMover);
5180 }
5181 addParticleUpdater(name, initUpdater) {
5182 this._initializers.updaters.set(name, initUpdater);
5183 }
5184 addPathGenerator(type, pathGenerator) {
5185 if (!this.getPathGenerator(type)) {
5186 this.pathGenerators.set(type, pathGenerator);
5187 }
5188 }
5189 addPlugin(plugin) {
5190 if (!this.getPlugin(plugin.id)) {
5191 this.plugins.push(plugin);
5192 }
5193 }
5194 addPreset(presetKey, options, override = false) {
5195 if (override || !this.getPreset(presetKey)) {
5196 this.presets.set(presetKey, options);
5197 }
5198 }
5199 addShapeDrawer(types, drawer) {
5200 executeOnSingleOrMultiple(types, type => {
5201 if (!this.getShapeDrawer(type)) {
5202 this.drawers.set(type, drawer);
5203 }
5204 });
5205 }
5206 destroy(container) {
5207 this.updaters.delete(container);
5208 this.movers.delete(container);
5209 this.interactors.delete(container);
5210 }
5211 getAvailablePlugins(container) {
5212 const res = new Map();
5213 for (const plugin of this.plugins) {
5214 if (!plugin.needsPlugin(container.actualOptions)) {
5215 continue;
5216 }
5217 res.set(plugin.id, plugin.getPlugin(container));
5218 }
5219 return res;
5220 }
5221 getInteractors(container, force = false) {
5222 return getItemsFromInitializer(container, this.interactors, this._initializers.interactors, force);
5223 }
5224 getMovers(container, force = false) {
5225 return getItemsFromInitializer(container, this.movers, this._initializers.movers, force);
5226 }
5227 getPathGenerator(type) {
5228 return this.pathGenerators.get(type);
5229 }
5230 getPlugin(plugin) {
5231 return this.plugins.find(t => t.id === plugin);
5232 }
5233 getPreset(preset) {
5234 return this.presets.get(preset);
5235 }
5236 getShapeDrawer(type) {
5237 return this.drawers.get(type);
5238 }
5239 getSupportedShapes() {
5240 return this.drawers.keys();
5241 }
5242 getUpdaters(container, force = false) {
5243 return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);
5244 }
5245 loadOptions(options, sourceOptions) {
5246 for (const plugin of this.plugins) {
5247 plugin.loadOptions(options, sourceOptions);
5248 }
5249 }
5250 loadParticlesOptions(container, options, ...sourceOptions) {
5251 const updaters = this.updaters.get(container);
5252 if (!updaters) {
5253 return;
5254 }
5255 for (const updater of updaters) {
5256 if (updater.loadOptions) {
5257 updater.loadOptions(options, ...sourceOptions);
5258 }
5259 }
5260 }
5261}
5262;// CONCATENATED MODULE: ./dist/browser/engine.js
5263
5264
5265
5266class Engine {
5267 constructor() {
5268 this._domArray = [];
5269 this._eventDispatcher = new EventDispatcher();
5270 this._initialized = false;
5271 this._loader = new Loader(this);
5272 this.plugins = new Plugins(this);
5273 }
5274 addEventListener(type, listener) {
5275 this._eventDispatcher.addEventListener(type, listener);
5276 }
5277 async addInteractor(name, interactorInitializer) {
5278 this.plugins.addInteractor(name, interactorInitializer);
5279 await this.refresh();
5280 }
5281 async addMover(name, moverInitializer) {
5282 this.plugins.addParticleMover(name, moverInitializer);
5283 await this.refresh();
5284 }
5285 async addParticleUpdater(name, updaterInitializer) {
5286 this.plugins.addParticleUpdater(name, updaterInitializer);
5287 await this.refresh();
5288 }
5289 async addPathGenerator(name, generator) {
5290 this.plugins.addPathGenerator(name, generator);
5291 await this.refresh();
5292 }
5293 async addPlugin(plugin) {
5294 this.plugins.addPlugin(plugin);
5295 await this.refresh();
5296 }
5297 async addPreset(preset, options, override = false) {
5298 this.plugins.addPreset(preset, options, override);
5299 await this.refresh();
5300 }
5301 async addShape(shape, drawer, init, afterEffect, destroy) {
5302 let customDrawer;
5303 if (typeof drawer === "function") {
5304 customDrawer = {
5305 afterEffect: afterEffect,
5306 destroy: destroy,
5307 draw: drawer,
5308 init: init
5309 };
5310 } else {
5311 customDrawer = drawer;
5312 }
5313 this.plugins.addShapeDrawer(shape, customDrawer);
5314 await this.refresh();
5315 }
5316 dispatchEvent(type, args) {
5317 this._eventDispatcher.dispatchEvent(type, args);
5318 }
5319 dom() {
5320 return this._domArray;
5321 }
5322 domItem(index) {
5323 const dom = this.dom(),
5324 item = dom[index];
5325 if (item && !item.destroyed) {
5326 return item;
5327 }
5328 dom.splice(index, 1);
5329 }
5330 init() {
5331 if (!this._initialized) {
5332 this._initialized = true;
5333 }
5334 }
5335 async load(tagId, options) {
5336 return this._loader.load(tagId, options);
5337 }
5338 async loadFromArray(tagId, options, index) {
5339 return this._loader.load(tagId, options, index);
5340 }
5341 async loadJSON(tagId, pathConfigJson, index) {
5342 return this._loader.loadJSON(tagId, pathConfigJson, index);
5343 }
5344 async refresh() {
5345 for (const instance of this.dom()) {
5346 await instance.refresh();
5347 }
5348 }
5349 removeEventListener(type, listener) {
5350 this._eventDispatcher.removeEventListener(type, listener);
5351 }
5352 async set(id, element, options) {
5353 return this._loader.set(id, element, options);
5354 }
5355 async setJSON(id, element, pathConfigJson, index) {
5356 return this._loader.setJSON(id, element, pathConfigJson, index);
5357 }
5358 setOnClickHandler(callback) {
5359 const dom = this.dom();
5360 if (!dom.length) {
5361 throw new Error("Can only set click handlers after calling tsParticles.load() or tsParticles.loadJSON()");
5362 }
5363 for (const domItem of dom) {
5364 domItem.addClickHandler(callback);
5365 }
5366 }
5367}
5368;// CONCATENATED MODULE: ./dist/browser/Utils/HslColorManager.js
5369
5370
5371class HslColorManager {
5372 constructor() {
5373 this.key = "hsl";
5374 this.stringPrefix = "hsl";
5375 }
5376 handleColor(color) {
5377 var _a;
5378 const colorValue = color.value,
5379 hslColor = (_a = colorValue.hsl) !== null && _a !== void 0 ? _a : color.value;
5380 if (hslColor.h !== undefined && hslColor.s !== undefined && hslColor.l !== undefined) {
5381 return hslToRgb(hslColor);
5382 }
5383 }
5384 handleRangeColor(color) {
5385 var _a;
5386 const colorValue = color.value,
5387 hslColor = (_a = colorValue.hsl) !== null && _a !== void 0 ? _a : color.value;
5388 if (hslColor.h !== undefined && hslColor.l !== undefined) {
5389 return hslToRgb({
5390 h: getRangeValue(hslColor.h),
5391 l: getRangeValue(hslColor.l),
5392 s: getRangeValue(hslColor.s)
5393 });
5394 }
5395 }
5396 parseString(input) {
5397 if (!input.startsWith("hsl")) {
5398 return;
5399 }
5400 const regex = /hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.%]+)\s*)?\)/i,
5401 result = regex.exec(input);
5402 return result ? hslaToRgba({
5403 a: result.length > 4 ? parseAlpha(result[5]) : 1,
5404 h: parseInt(result[1], 10),
5405 l: parseInt(result[3], 10),
5406 s: parseInt(result[2], 10)
5407 }) : undefined;
5408 }
5409}
5410;// CONCATENATED MODULE: ./dist/browser/Utils/RgbColorManager.js
5411
5412class RgbColorManager {
5413 constructor() {
5414 this.key = "rgb";
5415 this.stringPrefix = "rgb";
5416 }
5417 handleColor(color) {
5418 var _a;
5419 const colorValue = color.value,
5420 rgbColor = (_a = colorValue.rgb) !== null && _a !== void 0 ? _a : color.value;
5421 if (rgbColor.r !== undefined) {
5422 return rgbColor;
5423 }
5424 }
5425 handleRangeColor(color) {
5426 var _a;
5427 const colorValue = color.value,
5428 rgbColor = (_a = colorValue.rgb) !== null && _a !== void 0 ? _a : color.value;
5429 if (rgbColor.r !== undefined) {
5430 return {
5431 r: getRangeValue(rgbColor.r),
5432 g: getRangeValue(rgbColor.g),
5433 b: getRangeValue(rgbColor.b)
5434 };
5435 }
5436 }
5437 parseString(input) {
5438 if (!input.startsWith(this.stringPrefix)) {
5439 return;
5440 }
5441 const regex = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([\d.%]+)\s*)?\)/i,
5442 result = regex.exec(input);
5443 return result ? {
5444 a: result.length > 4 ? parseAlpha(result[5]) : 1,
5445 b: parseInt(result[3], 10),
5446 g: parseInt(result[2], 10),
5447 r: parseInt(result[1], 10)
5448 } : undefined;
5449 }
5450}
5451;// CONCATENATED MODULE: ./dist/browser/Core/Utils/ExternalInteractorBase.js
5452class ExternalInteractorBase {
5453 constructor(container) {
5454 this.container = container;
5455 this.type = "external";
5456 }
5457}
5458;// CONCATENATED MODULE: ./dist/browser/Core/Utils/ParticlesInteractorBase.js
5459class ParticlesInteractorBase {
5460 constructor(container) {
5461 this.container = container;
5462 this.type = "particles";
5463 }
5464}
5465;// CONCATENATED MODULE: ./dist/browser/index.js
5466
5467
5468
5469
5470const rgbColorManager = new RgbColorManager(),
5471 hslColorManager = new HslColorManager();
5472addColorManager(rgbColorManager);
5473addColorManager(hslColorManager);
5474const tsParticles = new Engine();
5475tsParticles.init();
5476
5477
5478
5479
5480
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/******/ return __webpack_exports__;
5660/******/ })()
5661;
5662});
\No newline at end of file