@tsparticles/stencil 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/cjs/Container-DFed5jPA.js +3556 -0
  4. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  5. package/dist/cjs/index-BY5-j3YK.js +1143 -0
  6. package/dist/cjs/index-Dwz1YgEM.js +1229 -0
  7. package/dist/cjs/index.cjs.js +9 -0
  8. package/dist/cjs/loader.cjs.js +13 -0
  9. package/dist/cjs/stencil-particles.cjs.entry.js +76 -0
  10. package/dist/cjs/tsparticlesstencil.cjs.js +25 -0
  11. package/dist/collection/collection-manifest.json +13 -0
  12. package/dist/collection/components/stencil-particles/stencil-particles.js +144 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/initParticlesEngine.js +38 -0
  15. package/dist/esm/Container-Di-pVL5B.js +3554 -0
  16. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  17. package/dist/esm/index-BzK79uqU.js +1223 -0
  18. package/dist/esm/index-CPcFDf6d.js +1052 -0
  19. package/dist/esm/index.js +1 -0
  20. package/dist/esm/loader.js +11 -0
  21. package/dist/esm/stencil-particles.entry.js +74 -0
  22. package/dist/esm/tsparticlesstencil.js +21 -0
  23. package/dist/index.cjs.js +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/tsparticlesstencil/index.esm.js +1 -0
  26. package/dist/tsparticlesstencil/p-2a10755a.entry.js +1 -0
  27. package/dist/tsparticlesstencil/p-BzK79uqU.js +2 -0
  28. package/dist/tsparticlesstencil/p-C6McIuSD.js +1 -0
  29. package/dist/tsparticlesstencil/p-DQuL1Twl.js +1 -0
  30. package/dist/tsparticlesstencil/p-x9G6hxBi.js +1 -0
  31. package/dist/tsparticlesstencil/tsparticlesstencil.esm.js +1 -0
  32. package/dist/types/components/stencil-particles/stencil-particles.d.ts +16 -0
  33. package/dist/types/components.d.ts +52 -0
  34. package/dist/types/index.d.ts +2 -0
  35. package/dist/types/initParticlesEngine.d.ts +5 -0
  36. package/dist/types/stencil-public-runtime.d.ts +1860 -0
  37. package/loader/cdn.js +1 -0
  38. package/loader/index.cjs.js +1 -0
  39. package/loader/index.d.ts +24 -0
  40. package/loader/index.es2017.js +1 -0
  41. package/loader/index.js +2 -0
  42. package/package.json +64 -0
@@ -0,0 +1,1052 @@
1
+ const generatedAttribute = "generated", defaultCompositeValue = "source-over", resizeEvent = "resize", visibilityChangeEvent = "visibilitychange", percentDenominator = 100, half = 0.5, millisecondsToSeconds = 1000, originPoint = {
2
+ x: 0,
3
+ y: 0,
4
+ z: 0,
5
+ }, defaultTransform = {
6
+ a: 1,
7
+ b: 0,
8
+ c: 0,
9
+ d: 1,
10
+ }, randomColorValue = "random", double = 2, doublePI = Math.PI * double, defaultFps = 60, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, defaultDensityFactor = 1, deleteCount = 1, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultZoom = 1;
11
+
12
+ var MoveDirection;
13
+ (function (MoveDirection) {
14
+ MoveDirection["bottom"] = "bottom";
15
+ MoveDirection["bottomLeft"] = "bottom-left";
16
+ MoveDirection["bottomRight"] = "bottom-right";
17
+ MoveDirection["left"] = "left";
18
+ MoveDirection["none"] = "none";
19
+ MoveDirection["right"] = "right";
20
+ MoveDirection["top"] = "top";
21
+ MoveDirection["topLeft"] = "top-left";
22
+ MoveDirection["topRight"] = "top-right";
23
+ MoveDirection["outside"] = "outside";
24
+ MoveDirection["inside"] = "inside";
25
+ })(MoveDirection || (MoveDirection = {}));
26
+
27
+ function getZ(source) {
28
+ return "z" in source ? source.z : originPoint.z;
29
+ }
30
+ class Vector3d {
31
+ x;
32
+ y;
33
+ z;
34
+ constructor(x = originPoint.x, y = originPoint.y, z = originPoint.z) {
35
+ this.x = x;
36
+ this.y = y;
37
+ this.z = z;
38
+ }
39
+ static get origin() {
40
+ return Vector3d.create(originPoint.x, originPoint.y, originPoint.z);
41
+ }
42
+ get angle() {
43
+ return Math.atan2(this.y, this.x);
44
+ }
45
+ set angle(angle) {
46
+ this.#updateFromAngle(angle, this.length);
47
+ }
48
+ get length() {
49
+ return Math.sqrt(this.getLengthSq());
50
+ }
51
+ set length(length) {
52
+ this.#updateFromAngle(this.angle, length);
53
+ }
54
+ static clone(source) {
55
+ return Vector3d.create(source.x, source.y, getZ(source));
56
+ }
57
+ static create(x, y, z) {
58
+ if (typeof x === "number") {
59
+ return new Vector3d(x, y ?? originPoint.y, z ?? originPoint.z);
60
+ }
61
+ return new Vector3d(x.x, x.y, getZ(x));
62
+ }
63
+ add(v) {
64
+ return Vector3d.create(this.x + v.x, this.y + v.y, this.z + getZ(v));
65
+ }
66
+ addTo(v) {
67
+ this.x += v.x;
68
+ this.y += v.y;
69
+ this.z += getZ(v);
70
+ }
71
+ copy() {
72
+ return Vector3d.clone(this);
73
+ }
74
+ div(n) {
75
+ return Vector3d.create(this.x / n, this.y / n, this.z / n);
76
+ }
77
+ divTo(n) {
78
+ this.x /= n;
79
+ this.y /= n;
80
+ this.z /= n;
81
+ }
82
+ getLengthSq() {
83
+ return this.x ** squareExp + this.y ** squareExp;
84
+ }
85
+ mult(n) {
86
+ return Vector3d.create(this.x * n, this.y * n, this.z * n);
87
+ }
88
+ multTo(n) {
89
+ this.x *= n;
90
+ this.y *= n;
91
+ this.z *= n;
92
+ }
93
+ normalize() {
94
+ const length = this.length;
95
+ if (length != none) {
96
+ this.multTo(inverseFactorNumerator / length);
97
+ }
98
+ }
99
+ rotate(angle) {
100
+ return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), originPoint.z);
101
+ }
102
+ setTo(c) {
103
+ this.x = c.x;
104
+ this.y = c.y;
105
+ this.z = getZ(c);
106
+ }
107
+ sub(v) {
108
+ return Vector3d.create(this.x - v.x, this.y - v.y, this.z - getZ(v));
109
+ }
110
+ subFrom(v) {
111
+ this.x -= v.x;
112
+ this.y -= v.y;
113
+ this.z -= getZ(v);
114
+ }
115
+ #updateFromAngle(angle, length) {
116
+ this.x = Math.cos(angle) * length;
117
+ this.y = Math.sin(angle) * length;
118
+ }
119
+ }
120
+ class Vector extends Vector3d {
121
+ constructor(x = originPoint.x, y = originPoint.y) {
122
+ super(x, y, originPoint.z);
123
+ }
124
+ static get origin() {
125
+ return Vector.create(originPoint.x, originPoint.y);
126
+ }
127
+ static clone(source) {
128
+ return Vector.create(source.x, source.y);
129
+ }
130
+ static create(x, y) {
131
+ if (typeof x === "number") {
132
+ return new Vector(x, y ?? originPoint.y);
133
+ }
134
+ return new Vector(x.x, x.y);
135
+ }
136
+ }
137
+
138
+ function isBoolean(arg) {
139
+ return typeof arg === "boolean";
140
+ }
141
+ function isString(arg) {
142
+ return typeof arg === "string";
143
+ }
144
+ function isNumber(arg) {
145
+ return typeof arg === "number";
146
+ }
147
+ function isObject(arg) {
148
+ return typeof arg === "object" && arg !== null;
149
+ }
150
+ function isArray(arg) {
151
+ return Array.isArray(arg);
152
+ }
153
+ function isNull(arg) {
154
+ return arg === null || arg === undefined;
155
+ }
156
+
157
+ const piDeg = 180, degToRadFactor = Math.PI / piDeg;
158
+ let _random = Math.random;
159
+ const _animationLoop = {
160
+ nextFrame: (cb) => requestAnimationFrame(cb),
161
+ cancel: (idx) => {
162
+ cancelAnimationFrame(idx);
163
+ },
164
+ };
165
+ function getRandom() {
166
+ const min = 0, max = 1;
167
+ return clamp(_random(), min, max - Number.EPSILON);
168
+ }
169
+ function getRandomInRange(min, max) {
170
+ return getRandom() * (max - min) + min;
171
+ }
172
+ function animate(fn) {
173
+ return _animationLoop.nextFrame(fn);
174
+ }
175
+ function cancelAnimation(handle) {
176
+ _animationLoop.cancel(handle);
177
+ }
178
+ function clamp(num, min, max) {
179
+ return Math.min(Math.max(num, min), max);
180
+ }
181
+ function randomInRangeValue(r) {
182
+ const max = getRangeMax(r), minOffset = 0;
183
+ let min = getRangeMin(r);
184
+ if (max === min) {
185
+ min = minOffset;
186
+ }
187
+ return getRandomInRange(min, max);
188
+ }
189
+ function getRangeValue(value) {
190
+ return isNumber(value) ? value : randomInRangeValue(value);
191
+ }
192
+ function getRangeMin(value) {
193
+ return isNumber(value) ? value : value.min;
194
+ }
195
+ function getRangeMax(value) {
196
+ return isNumber(value) ? value : value.max;
197
+ }
198
+ function setRangeValue(source, value) {
199
+ if (source === value || (value === undefined && isNumber(source))) {
200
+ return source;
201
+ }
202
+ const min = getRangeMin(source), max = getRangeMax(source);
203
+ return value !== undefined
204
+ ? {
205
+ min: Math.min(min, value),
206
+ max: Math.max(max, value),
207
+ }
208
+ : setRangeValue(min, max);
209
+ }
210
+ function getDistanceSq(pointA, pointB) {
211
+ const dx = pointA.x - pointB.x, dy = pointA.y - pointB.y;
212
+ return dx * dx + dy * dy;
213
+ }
214
+ function checkDistance(pointA, pointB, distance) {
215
+ return getDistanceSq(pointA, pointB) <= distance * distance;
216
+ }
217
+ function degToRad(degrees) {
218
+ return degrees * degToRadFactor;
219
+ }
220
+ function getParticleDirectionAngle(direction, position, center) {
221
+ if (isNumber(direction)) {
222
+ return degToRad(direction);
223
+ }
224
+ switch (direction) {
225
+ case MoveDirection.top:
226
+ return -Math.PI * half;
227
+ case MoveDirection.topRight:
228
+ return -Math.PI * quarter;
229
+ case MoveDirection.right:
230
+ return empty;
231
+ case MoveDirection.bottomRight:
232
+ return Math.PI * quarter;
233
+ case MoveDirection.bottom:
234
+ return Math.PI * half;
235
+ case MoveDirection.bottomLeft:
236
+ return Math.PI * threeQuarter;
237
+ case MoveDirection.left:
238
+ return Math.PI;
239
+ case MoveDirection.topLeft:
240
+ return -Math.PI * threeQuarter;
241
+ case MoveDirection.inside:
242
+ return Math.atan2(center.y - position.y, center.x - position.x);
243
+ case MoveDirection.outside:
244
+ return Math.atan2(position.y - center.y, position.x - center.x);
245
+ default:
246
+ return getRandom() * doublePI;
247
+ }
248
+ }
249
+ function getParticleBaseVelocity(direction) {
250
+ const baseVelocity = Vector.origin;
251
+ baseVelocity.length = 1;
252
+ baseVelocity.angle = direction;
253
+ return baseVelocity;
254
+ }
255
+ function calcExactPositionOrRandomFromSize(data) {
256
+ const { position, size } = data;
257
+ return {
258
+ x: position?.x ?? getRandom() * size.width,
259
+ y: position?.y ?? getRandom() * size.height,
260
+ };
261
+ }
262
+
263
+ var AnimationMode;
264
+ (function (AnimationMode) {
265
+ AnimationMode["auto"] = "auto";
266
+ AnimationMode["increase"] = "increase";
267
+ AnimationMode["decrease"] = "decrease";
268
+ AnimationMode["random"] = "random";
269
+ })(AnimationMode || (AnimationMode = {}));
270
+
271
+ var AnimationStatus;
272
+ (function (AnimationStatus) {
273
+ AnimationStatus["increasing"] = "increasing";
274
+ AnimationStatus["decreasing"] = "decreasing";
275
+ })(AnimationStatus || (AnimationStatus = {}));
276
+
277
+ var DestroyType;
278
+ (function (DestroyType) {
279
+ DestroyType["none"] = "none";
280
+ DestroyType["max"] = "max";
281
+ DestroyType["min"] = "min";
282
+ })(DestroyType || (DestroyType = {}));
283
+
284
+ var OutModeDirection;
285
+ (function (OutModeDirection) {
286
+ OutModeDirection["bottom"] = "bottom";
287
+ OutModeDirection["left"] = "left";
288
+ OutModeDirection["right"] = "right";
289
+ OutModeDirection["top"] = "top";
290
+ })(OutModeDirection || (OutModeDirection = {}));
291
+
292
+ var PixelMode;
293
+ (function (PixelMode) {
294
+ PixelMode["precise"] = "precise";
295
+ PixelMode["percent"] = "percent";
296
+ })(PixelMode || (PixelMode = {}));
297
+
298
+ var StartValueType;
299
+ (function (StartValueType) {
300
+ StartValueType["max"] = "max";
301
+ StartValueType["min"] = "min";
302
+ StartValueType["random"] = "random";
303
+ })(StartValueType || (StartValueType = {}));
304
+
305
+ function memoize(fn, options) {
306
+ const cache = new Map(), keyFn = options?.keyFn, stableStringify = (obj, seen = new WeakSet()) => {
307
+ if (obj === null) {
308
+ return "null";
309
+ }
310
+ const t = typeof obj;
311
+ if (t === "undefined") {
312
+ return "undefined";
313
+ }
314
+ if (t === "number" || t === "boolean" || t === "string") {
315
+ return JSON.stringify(obj);
316
+ }
317
+ if (t === "function") {
318
+ try {
319
+ const fn = obj;
320
+ return fn.toString();
321
+ }
322
+ catch {
323
+ return '"[Function]"';
324
+ }
325
+ }
326
+ if (t === "symbol") {
327
+ try {
328
+ return obj.toString();
329
+ }
330
+ catch {
331
+ return '"[Symbol]"';
332
+ }
333
+ }
334
+ if (Array.isArray(obj)) {
335
+ return `[${obj.map(i => stableStringify(i, seen)).join(",")}]`;
336
+ }
337
+ if (seen.has(obj)) {
338
+ return '"[Circular]"';
339
+ }
340
+ seen.add(obj);
341
+ const keys = Object.keys(obj).sort();
342
+ return `{${keys.map(k => `${JSON.stringify(k)}:${stableStringify(obj[k], seen)}`).join(",")}}`;
343
+ }, defaultKeyer = (args) => stableStringify(args), makeKey = (args) => (keyFn ? keyFn(args) : defaultKeyer(args));
344
+ return (...args) => {
345
+ const key = makeKey(args), now = Date.now(), entry = cache.get(key);
346
+ if (entry !== undefined) {
347
+ {
348
+ cache.delete(key);
349
+ cache.set(key, { value: entry.value, ts: entry.ts });
350
+ return entry.value;
351
+ }
352
+ }
353
+ const result = fn(...args);
354
+ cache.set(key, { value: result, ts: now });
355
+ return result;
356
+ };
357
+ }
358
+ function hasMatchMedia() {
359
+ return typeof matchMedia !== "undefined";
360
+ }
361
+ function safeDocument() {
362
+ return globalThis.document;
363
+ }
364
+ function safeMatchMedia(query) {
365
+ if (!hasMatchMedia()) {
366
+ return;
367
+ }
368
+ return matchMedia(query);
369
+ }
370
+ function safeMutationObserver(callback) {
371
+ if (typeof MutationObserver === "undefined") {
372
+ return;
373
+ }
374
+ return new MutationObserver(callback);
375
+ }
376
+ function isInArray(value, array) {
377
+ return value === array || (isArray(array) && array.includes(value));
378
+ }
379
+ function arrayRandomIndex(array) {
380
+ return Math.floor(getRandom() * array.length);
381
+ }
382
+ function itemFromArray(array, index, useIndex = true) {
383
+ return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
384
+ }
385
+ function deepExtend(destination, ...sources) {
386
+ for (const source of sources) {
387
+ if (isNull(source)) {
388
+ continue;
389
+ }
390
+ if (!isObject(source)) {
391
+ destination = source;
392
+ continue;
393
+ }
394
+ if (Array.isArray(source)) {
395
+ if (!Array.isArray(destination)) {
396
+ destination = [];
397
+ }
398
+ }
399
+ else if (!isObject(destination) || Array.isArray(destination)) {
400
+ destination = {};
401
+ }
402
+ const sourceKeys = Object.keys(source), dangerousKeys = new Set(["__proto__", "constructor", "prototype"]), hasNested = sourceKeys.some(k => {
403
+ const v = source[k];
404
+ return isObject(v) || Array.isArray(v);
405
+ });
406
+ if (!hasNested) {
407
+ const sourceDict = source, destDict = destination;
408
+ for (const key of sourceKeys) {
409
+ if (dangerousKeys.has(key)) {
410
+ continue;
411
+ }
412
+ if (key in sourceDict) {
413
+ const v = sourceDict[key];
414
+ if (v !== undefined) {
415
+ destDict[key] = v;
416
+ }
417
+ }
418
+ }
419
+ continue;
420
+ }
421
+ for (const key of sourceKeys) {
422
+ if (dangerousKeys.has(key)) {
423
+ continue;
424
+ }
425
+ const sourceDict = source, destDict = destination, value = sourceDict[key];
426
+ destDict[key] = Array.isArray(value)
427
+ ? value.map(v => deepExtend(undefined, v))
428
+ : deepExtend(destDict[key], value);
429
+ }
430
+ }
431
+ return destination;
432
+ }
433
+ function executeOnSingleOrMultiple(obj, callback) {
434
+ const defaultIndex = 0;
435
+ return isArray(obj) ? obj.map((item, index) => callback(item, index)) : callback(obj, defaultIndex);
436
+ }
437
+ function itemFromSingleOrMultiple(obj, index, useIndex) {
438
+ return isArray(obj) ? itemFromArray(obj, index, useIndex) : obj;
439
+ }
440
+ function getPositionOrSize(positionOrSize, canvasSize) {
441
+ const isPercent = positionOrSize.mode === PixelMode.percent;
442
+ if (!isPercent) {
443
+ const { mode: _, ...rest } = positionOrSize;
444
+ return rest;
445
+ }
446
+ const isPosition = "x" in positionOrSize;
447
+ if (isPosition) {
448
+ return {
449
+ x: (positionOrSize.x / percentDenominator) * canvasSize.width,
450
+ y: (positionOrSize.y / percentDenominator) * canvasSize.height,
451
+ };
452
+ }
453
+ else {
454
+ return {
455
+ width: (positionOrSize.width / percentDenominator) * canvasSize.width,
456
+ height: (positionOrSize.height / percentDenominator) * canvasSize.height,
457
+ };
458
+ }
459
+ }
460
+ function getPosition(position, canvasSize) {
461
+ return getPositionOrSize(position, canvasSize);
462
+ }
463
+ function cloneStyle(style) {
464
+ const clonedStyle = safeDocument().createElement("div").style;
465
+ for (const key in style) {
466
+ const styleKey = style[key];
467
+ if (!(key in style) || isNull(styleKey)) {
468
+ continue;
469
+ }
470
+ const styleValue = style.getPropertyValue?.(styleKey);
471
+ if (!styleValue) {
472
+ continue;
473
+ }
474
+ const stylePriority = style.getPropertyPriority?.(styleKey);
475
+ if (stylePriority) {
476
+ clonedStyle.setProperty(styleKey, styleValue, stylePriority);
477
+ }
478
+ else {
479
+ clonedStyle.setProperty(styleKey, styleValue);
480
+ }
481
+ }
482
+ return clonedStyle;
483
+ }
484
+ function computeFullScreenStyle(zIndex) {
485
+ const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
486
+ width: "100%",
487
+ height: "100%",
488
+ margin: "0",
489
+ padding: "0",
490
+ borderWidth: "0",
491
+ position: "fixed",
492
+ zIndex: zIndex.toString(radix),
493
+ "z-index": zIndex.toString(radix),
494
+ top: "0",
495
+ left: "0",
496
+ "pointer-events": "none",
497
+ };
498
+ for (const key in style) {
499
+ const value = style[key];
500
+ if (value === undefined) {
501
+ continue;
502
+ }
503
+ fullScreenStyle.setProperty(key, value);
504
+ }
505
+ return fullScreenStyle;
506
+ }
507
+ const getFullScreenStyle = memoize(computeFullScreenStyle);
508
+ function manageListener(element, event, handler, add, options) {
509
+ if (add) {
510
+ let addOptions = { passive: true };
511
+ if (isBoolean(options)) {
512
+ addOptions.capture = options;
513
+ }
514
+ else if (options !== undefined) {
515
+ addOptions = options;
516
+ }
517
+ element.addEventListener(event, handler, addOptions);
518
+ }
519
+ else {
520
+ const removeOptions = options;
521
+ element.removeEventListener(event, handler, removeOptions);
522
+ }
523
+ }
524
+ async function getItemsFromInitializer(container, map, initializers, force = false) {
525
+ let res = map.get(container);
526
+ if (!res || force) {
527
+ res = await Promise.all([...initializers.values()].map(t => t(container)));
528
+ map.set(container, res);
529
+ }
530
+ return res;
531
+ }
532
+ async function getItemMapFromInitializer(container, map, initializers, force = false) {
533
+ let res = map.get(container);
534
+ if (!res || force) {
535
+ const entries = await Promise.all([...initializers.entries()].map(([key, initializer]) => initializer(container).then(item => [key, item])));
536
+ res = new Map(entries);
537
+ map.set(container, res);
538
+ }
539
+ return res;
540
+ }
541
+
542
+ class EventDispatcher {
543
+ #listeners;
544
+ constructor() {
545
+ this.#listeners = new Map();
546
+ }
547
+ addEventListener(type, listener) {
548
+ this.removeEventListener(type, listener);
549
+ let arr = this.#listeners.get(type);
550
+ if (!arr) {
551
+ arr = [];
552
+ this.#listeners.set(type, arr);
553
+ }
554
+ arr.push(listener);
555
+ }
556
+ dispatchEvent(type, args) {
557
+ const listeners = this.#listeners.get(type);
558
+ listeners?.forEach(handler => {
559
+ handler(args);
560
+ });
561
+ }
562
+ hasEventListener(type) {
563
+ return !!this.#listeners.get(type);
564
+ }
565
+ removeAllEventListeners(type) {
566
+ if (!type) {
567
+ this.#listeners = new Map();
568
+ }
569
+ else {
570
+ this.#listeners.delete(type);
571
+ }
572
+ }
573
+ removeEventListener(type, listener) {
574
+ const arr = this.#listeners.get(type);
575
+ if (!arr) {
576
+ return;
577
+ }
578
+ const length = arr.length, idx = arr.indexOf(listener);
579
+ if (idx < minIndex) {
580
+ return;
581
+ }
582
+ if (length === deleteCount) {
583
+ this.#listeners.delete(type);
584
+ }
585
+ else {
586
+ arr.splice(idx, deleteCount);
587
+ }
588
+ }
589
+ }
590
+
591
+ var EventType;
592
+ (function (EventType) {
593
+ EventType["configAdded"] = "configAdded";
594
+ EventType["containerInit"] = "containerInit";
595
+ EventType["particlesSetup"] = "particlesSetup";
596
+ EventType["containerStarted"] = "containerStarted";
597
+ EventType["containerStopped"] = "containerStopped";
598
+ EventType["containerDestroyed"] = "containerDestroyed";
599
+ EventType["containerPaused"] = "containerPaused";
600
+ EventType["containerPlay"] = "containerPlay";
601
+ EventType["containerBuilt"] = "containerBuilt";
602
+ EventType["particleAdded"] = "particleAdded";
603
+ EventType["particleDestroyed"] = "particleDestroyed";
604
+ EventType["particleRemoved"] = "particleRemoved";
605
+ })(EventType || (EventType = {}));
606
+
607
+ class PluginManager {
608
+ colorManagers = new Map();
609
+ easingFunctions = new Map();
610
+ effectDrawers = new Map();
611
+ initializers = {
612
+ effects: new Map(),
613
+ shapes: new Map(),
614
+ updaters: new Map(),
615
+ };
616
+ palettes = new Map();
617
+ plugins = [];
618
+ presets = new Map();
619
+ shapeDrawers = new Map();
620
+ updaters = new Map();
621
+ #allLoadersSet = new Set();
622
+ #configs = new Map();
623
+ #engine;
624
+ #executedSet = new Set();
625
+ #initialized = false;
626
+ #isRunningLoaders = false;
627
+ #loadPromises = new Set();
628
+ constructor(engine) {
629
+ this.#engine = engine;
630
+ }
631
+ get configs() {
632
+ const res = {};
633
+ for (const [name, config] of this.#configs) {
634
+ res[name] = config;
635
+ }
636
+ return res;
637
+ }
638
+ addColorManager(name, manager) {
639
+ this.colorManagers.set(name, manager);
640
+ }
641
+ addConfig(config) {
642
+ const key = config.key ?? config.name ?? "default";
643
+ this.#configs.set(key, config);
644
+ this.#engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
645
+ }
646
+ addEasing(name, easing) {
647
+ if (this.easingFunctions.get(name)) {
648
+ return;
649
+ }
650
+ this.easingFunctions.set(name, easing);
651
+ }
652
+ addEffect(effect, drawer) {
653
+ this.initializers.effects.set(effect, drawer);
654
+ }
655
+ addPalette(name, palette) {
656
+ this.palettes.set(name, palette);
657
+ }
658
+ addParticleUpdater(name, updaterInitializer) {
659
+ this.initializers.updaters.set(name, updaterInitializer);
660
+ }
661
+ addPlugin(plugin) {
662
+ if (this.getPlugin(plugin.id)) {
663
+ return;
664
+ }
665
+ this.plugins.push(plugin);
666
+ }
667
+ addPreset(preset, options, override = false) {
668
+ if (!(override || !this.getPreset(preset))) {
669
+ return;
670
+ }
671
+ this.presets.set(preset, options);
672
+ }
673
+ addShape(shapes, drawer) {
674
+ for (const shape of shapes) {
675
+ this.initializers.shapes.set(shape, drawer);
676
+ }
677
+ }
678
+ clearPlugins(container) {
679
+ this.effectDrawers.delete(container);
680
+ this.shapeDrawers.delete(container);
681
+ this.updaters.delete(container);
682
+ }
683
+ getEasing(name) {
684
+ return this.easingFunctions.get(name) ?? ((value) => value);
685
+ }
686
+ getEffectDrawers(container, force = false) {
687
+ return getItemMapFromInitializer(container, this.effectDrawers, this.initializers.effects, force);
688
+ }
689
+ getPalette(name) {
690
+ return this.palettes.get(name);
691
+ }
692
+ getPlugin(plugin) {
693
+ return this.plugins.find(t => t.id === plugin);
694
+ }
695
+ getPreset(preset) {
696
+ return this.presets.get(preset);
697
+ }
698
+ async getShapeDrawers(container, force = false) {
699
+ return getItemMapFromInitializer(container, this.shapeDrawers, this.initializers.shapes, force);
700
+ }
701
+ async getUpdaters(container, force = false) {
702
+ return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
703
+ }
704
+ async init() {
705
+ if (this.#initialized || this.#isRunningLoaders) {
706
+ return;
707
+ }
708
+ this.#isRunningLoaders = true;
709
+ this.#executedSet = new Set();
710
+ this.#allLoadersSet = new Set(this.#loadPromises);
711
+ try {
712
+ for (const loader of this.#allLoadersSet) {
713
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
714
+ }
715
+ }
716
+ finally {
717
+ this.#loadPromises.clear();
718
+ this.#isRunningLoaders = false;
719
+ this.#initialized = true;
720
+ }
721
+ }
722
+ loadParticlesOptions(container, options, ...sourceOptions) {
723
+ const updaters = this.updaters.get(container);
724
+ if (!updaters) {
725
+ return;
726
+ }
727
+ updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
728
+ }
729
+ async register(...loaders) {
730
+ if (this.#initialized) {
731
+ throw new Error("Register plugins can only be done before calling tsParticles.load()");
732
+ }
733
+ for (const loader of loaders) {
734
+ if (this.#isRunningLoaders) {
735
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
736
+ }
737
+ else {
738
+ this.#loadPromises.add(loader);
739
+ }
740
+ }
741
+ }
742
+ async #runLoader(loader, executed, allLoaders) {
743
+ if (executed.has(loader))
744
+ return;
745
+ executed.add(loader);
746
+ allLoaders.add(loader);
747
+ await loader(this.#engine);
748
+ }
749
+ }
750
+
751
+ const errorPrefix = "tsParticles - Error";
752
+ const wrap = (fn) => (...args) => {
753
+ fn(...args);
754
+ }, _logger = {
755
+ debug: wrap(console.debug),
756
+ error: (message, ...optionalParams) => {
757
+ console.error(`${errorPrefix} - ${message}`, ...optionalParams);
758
+ },
759
+ info: wrap(console.info),
760
+ log: wrap(console.log),
761
+ trace: wrap(console.trace),
762
+ verbose: wrap(console.log),
763
+ warning: wrap(console.warn),
764
+ };
765
+ function getLogger() {
766
+ return _logger;
767
+ }
768
+
769
+ const fullPercent = "100%";
770
+ async function getDataFromUrl(data) {
771
+ const url = itemFromSingleOrMultiple(data.url, data.index);
772
+ if (!url) {
773
+ return data.fallback;
774
+ }
775
+ const response = await fetch(url);
776
+ if (response.ok) {
777
+ return (await response.json());
778
+ }
779
+ getLogger().error(`${response.status.toString()} while retrieving config file`);
780
+ return data.fallback;
781
+ }
782
+ const getCanvasFromContainer = (domContainer) => {
783
+ const documentSafe = safeDocument();
784
+ let canvasEl;
785
+ const isCanvas = domContainer instanceof HTMLCanvasElement || domContainer.tagName.toLowerCase() === canvasTag;
786
+ if (isCanvas) {
787
+ canvasEl = domContainer;
788
+ canvasEl.dataset[generatedAttribute] ??= generatedFalse;
789
+ if (canvasEl.dataset[generatedAttribute] === generatedTrue) {
790
+ canvasEl.style.width ||= fullPercent;
791
+ canvasEl.style.height ||= fullPercent;
792
+ canvasEl.style.pointerEvents = "none";
793
+ canvasEl.style.setProperty("pointer-events", "none");
794
+ }
795
+ }
796
+ else {
797
+ const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases.item(canvasFirstIndex);
798
+ if (foundCanvas) {
799
+ canvasEl = foundCanvas;
800
+ canvasEl.dataset[generatedAttribute] = generatedFalse;
801
+ }
802
+ else {
803
+ canvasEl = documentSafe.createElement(canvasTag);
804
+ canvasEl.dataset[generatedAttribute] = generatedTrue;
805
+ domContainer.appendChild(canvasEl);
806
+ }
807
+ canvasEl.style.width ||= fullPercent;
808
+ canvasEl.style.height ||= fullPercent;
809
+ canvasEl.style.pointerEvents = "none";
810
+ canvasEl.style.setProperty("pointer-events", "none");
811
+ }
812
+ return canvasEl;
813
+ }, getDomContainer = (id, source) => {
814
+ const documentSafe = safeDocument();
815
+ let domContainer = source ?? documentSafe.getElementById(id);
816
+ if (domContainer) {
817
+ return domContainer;
818
+ }
819
+ domContainer = documentSafe.createElement("canvas");
820
+ domContainer.id = id;
821
+ domContainer.dataset[generatedAttribute] = generatedTrue;
822
+ documentSafe.body.append(domContainer);
823
+ return domContainer;
824
+ };
825
+ class Engine {
826
+ pluginManager = new PluginManager(this);
827
+ #domArray = [];
828
+ #eventDispatcher = new EventDispatcher();
829
+ #initialized = false;
830
+ get items() {
831
+ return this.#domArray;
832
+ }
833
+ get version() {
834
+ return "4.0.5";
835
+ }
836
+ addEventListener(type, listener) {
837
+ this.#eventDispatcher.addEventListener(type, listener);
838
+ }
839
+ checkVersion(pluginVersion) {
840
+ if (this.version === pluginVersion) {
841
+ return;
842
+ }
843
+ throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
844
+ }
845
+ dispatchEvent(type, args) {
846
+ this.#eventDispatcher.dispatchEvent(type, args);
847
+ }
848
+ async init() {
849
+ if (this.#initialized) {
850
+ return;
851
+ }
852
+ await this.pluginManager.init();
853
+ this.#initialized = true;
854
+ }
855
+ item(index) {
856
+ const items = this.items, item = items[index];
857
+ if (item?.destroyed) {
858
+ items.splice(index, removeDeleteCount);
859
+ return;
860
+ }
861
+ return item;
862
+ }
863
+ async load(params) {
864
+ await this.init();
865
+ let domSourceElement;
866
+ if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
867
+ domSourceElement = params.element;
868
+ }
869
+ const { Container } = await import('./Container-Di-pVL5B.js'), id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
870
+ dispatchCallback: (eventType, args) => {
871
+ this.dispatchEvent(eventType, args);
872
+ },
873
+ id,
874
+ onDestroy: (remove) => {
875
+ if (!remove) {
876
+ return;
877
+ }
878
+ const mainArr = this.items, idx = mainArr.indexOf(newItem);
879
+ if (idx >= removeMinIndex) {
880
+ mainArr.splice(idx, removeDeleteCount);
881
+ }
882
+ },
883
+ pluginManager: this.pluginManager,
884
+ sourceOptions: currentOptions,
885
+ });
886
+ if (oldIndex >= loadMinIndex) {
887
+ const old = this.item(oldIndex), deleteCount = old ? one : none;
888
+ if (old && !old.destroyed) {
889
+ old.destroy(false);
890
+ }
891
+ items.splice(oldIndex, deleteCount, newItem);
892
+ }
893
+ else {
894
+ items.push(newItem);
895
+ }
896
+ const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
897
+ ? params.element
898
+ : getCanvasFromContainer(getDomContainer(id, domSourceElement));
899
+ newItem.canvas.loadCanvas(sourceCanvas);
900
+ await newItem.start();
901
+ return newItem;
902
+ }
903
+ async refresh(refresh = true) {
904
+ if (!refresh) {
905
+ return;
906
+ }
907
+ await Promise.all(this.items.map(t => t.refresh()));
908
+ }
909
+ removeEventListener(type, listener) {
910
+ this.#eventDispatcher.removeEventListener(type, listener);
911
+ }
912
+ }
913
+
914
+ function initEngine() {
915
+ return new Engine();
916
+ }
917
+
918
+ var RangeType;
919
+ (function (RangeType) {
920
+ RangeType["circle"] = "circle";
921
+ RangeType["rectangle"] = "rectangle";
922
+ })(RangeType || (RangeType = {}));
923
+
924
+ var RotateDirection;
925
+ (function (RotateDirection) {
926
+ RotateDirection["clockwise"] = "clockwise";
927
+ RotateDirection["counterClockwise"] = "counter-clockwise";
928
+ RotateDirection["random"] = "random";
929
+ })(RotateDirection || (RotateDirection = {}));
930
+
931
+ var LimitMode;
932
+ (function (LimitMode) {
933
+ LimitMode["delete"] = "delete";
934
+ LimitMode["wait"] = "wait";
935
+ })(LimitMode || (LimitMode = {}));
936
+
937
+ var OutMode;
938
+ (function (OutMode) {
939
+ OutMode["bounce"] = "bounce";
940
+ OutMode["none"] = "none";
941
+ OutMode["out"] = "out";
942
+ OutMode["destroy"] = "destroy";
943
+ OutMode["split"] = "split";
944
+ })(OutMode || (OutMode = {}));
945
+
946
+ var AlterType;
947
+ (function (AlterType) {
948
+ AlterType["darken"] = "darken";
949
+ AlterType["enlighten"] = "enlighten";
950
+ })(AlterType || (AlterType = {}));
951
+
952
+ var GradientType;
953
+ (function (GradientType) {
954
+ GradientType["linear"] = "linear";
955
+ GradientType["radial"] = "radial";
956
+ GradientType["random"] = "random";
957
+ })(GradientType || (GradientType = {}));
958
+
959
+ var ParticleOutType;
960
+ (function (ParticleOutType) {
961
+ ParticleOutType["normal"] = "normal";
962
+ ParticleOutType["inside"] = "inside";
963
+ ParticleOutType["outside"] = "outside";
964
+ })(ParticleOutType || (ParticleOutType = {}));
965
+
966
+ var EasingType;
967
+ (function (EasingType) {
968
+ EasingType["easeInBack"] = "ease-in-back";
969
+ EasingType["easeInBounce"] = "ease-in-bounce";
970
+ EasingType["easeInCirc"] = "ease-in-circ";
971
+ EasingType["easeInCubic"] = "ease-in-cubic";
972
+ EasingType["easeInElastic"] = "ease-in-elastic";
973
+ EasingType["easeInExpo"] = "ease-in-expo";
974
+ EasingType["easeInGaussian"] = "ease-in-gaussian";
975
+ EasingType["easeInLinear"] = "ease-in-linear";
976
+ EasingType["easeInQuad"] = "ease-in-quad";
977
+ EasingType["easeInQuart"] = "ease-in-quart";
978
+ EasingType["easeInQuint"] = "ease-in-quint";
979
+ EasingType["easeInSigmoid"] = "ease-in-sigmoid";
980
+ EasingType["easeInSine"] = "ease-in-sine";
981
+ EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
982
+ EasingType["easeOutBack"] = "ease-out-back";
983
+ EasingType["easeOutBounce"] = "ease-out-bounce";
984
+ EasingType["easeOutCirc"] = "ease-out-circ";
985
+ EasingType["easeOutCubic"] = "ease-out-cubic";
986
+ EasingType["easeOutElastic"] = "ease-out-elastic";
987
+ EasingType["easeOutExpo"] = "ease-out-expo";
988
+ EasingType["easeOutGaussian"] = "ease-out-gaussian";
989
+ EasingType["easeOutLinear"] = "ease-out-linear";
990
+ EasingType["easeOutQuad"] = "ease-out-quad";
991
+ EasingType["easeOutQuart"] = "ease-out-quart";
992
+ EasingType["easeOutQuint"] = "ease-out-quint";
993
+ EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
994
+ EasingType["easeOutSine"] = "ease-out-sine";
995
+ EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
996
+ EasingType["easeInOutBack"] = "ease-in-out-back";
997
+ EasingType["easeInOutBounce"] = "ease-in-out-bounce";
998
+ EasingType["easeInOutCirc"] = "ease-in-out-circ";
999
+ EasingType["easeInOutCubic"] = "ease-in-out-cubic";
1000
+ EasingType["easeInOutElastic"] = "ease-in-out-elastic";
1001
+ EasingType["easeInOutExpo"] = "ease-in-out-expo";
1002
+ EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
1003
+ EasingType["easeInOutLinear"] = "ease-in-out-linear";
1004
+ EasingType["easeInOutQuad"] = "ease-in-out-quad";
1005
+ EasingType["easeInOutQuart"] = "ease-in-out-quart";
1006
+ EasingType["easeInOutQuint"] = "ease-in-out-quint";
1007
+ EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
1008
+ EasingType["easeInOutSine"] = "ease-in-out-sine";
1009
+ EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
1010
+ })(EasingType || (EasingType = {}));
1011
+
1012
+ const tsParticles = initEngine();
1013
+
1014
+ let initialized = false;
1015
+ let initPromise;
1016
+ let initCallback;
1017
+ async function initParticlesEngine(init) {
1018
+ if (initialized) {
1019
+ return;
1020
+ }
1021
+ if (initPromise) {
1022
+ if (initCallback !== init) {
1023
+ throw new Error("initParticlesEngine callback must be stable across the app lifecycle.");
1024
+ }
1025
+ await initPromise;
1026
+ return;
1027
+ }
1028
+ initCallback = init;
1029
+ initPromise = (async () => {
1030
+ if (init) {
1031
+ await init(tsParticles);
1032
+ }
1033
+ if (typeof tsParticles.init === "function") {
1034
+ await tsParticles.init();
1035
+ }
1036
+ initialized = true;
1037
+ })().catch((error) => {
1038
+ initPromise = undefined;
1039
+ initCallback = undefined;
1040
+ initialized = false;
1041
+ throw error;
1042
+ });
1043
+ await initPromise;
1044
+ }
1045
+ function isParticlesEngineInitialized() {
1046
+ return initialized;
1047
+ }
1048
+ async function waitForParticlesEngineInitialization() {
1049
+ await (initPromise !== null && initPromise !== void 0 ? initPromise : Promise.resolve());
1050
+ }
1051
+
1052
+ export { millisecondsToSeconds as $, AlterType as A, lFactor as B, double as C, hPhase as D, rgbMax as E, getRandomInRange as F, identity as G, defaultRgbMin as H, sextuple as I, triple as J, phaseNumerator as K, LimitMode as L, MoveDirection as M, sNormalizedOffset as N, OutMode as O, PixelMode as P, minimumSize as Q, RangeType as R, defaultCompositeValue as S, defaultTransformValue as T, zIndexFactorOffset as U, safeMutationObserver as V, generatedAttribute as W, cloneStyle as X, safeMatchMedia as Y, getFullScreenStyle as Z, safeDocument as _, isNull as a, manageListener as a0, visibilityChangeEvent as a1, resizeEvent as a2, Vector3d as a3, EventType as a4, defaultAngle as a5, defaultTransform as a6, ParticleOutType as a7, itemFromSingleOrMultiple as a8, getRandom as a9, defaultRatio as aA, defaultReduceFactor as aB, animate as aC, defaultFpsLimit as aD, minFpsLimit as aE, cancelAnimation as aF, defaultFps as aG, isParticlesEngineInitialized as aH, waitForParticlesEngineInitialization as aI, defaultRetryCount as aa, tryCountIncrement as ab, getParticleBaseVelocity as ac, randomInRangeValue as ad, OutModeDirection as ae, clamp as af, minZ as ag, getPosition as ah, getParticleDirectionAngle as ai, Vector as aj, getRangeValue as ak, doublePI as al, calcExactPositionOrRandomFromSize as am, isInArray as an, degToRad as ao, spatialHashGridCellSize as ap, minLimit as aq, minCount as ar, getLogger as as, minIndex as at, defaultRemoveQuantity as au, defaultDensityFactor as av, empty as aw, deleteCount as ax, countOffset as ay, one as az, setRangeValue as b, checkDistance as c, hMax as d, lMax as e, sMin as f, sMax as g, hMin as h, initParticlesEngine as i, isString as j, isArray as k, lMin as l, deepExtend as m, isNumber as n, isObject as o, executeOnSingleOrMultiple as p, isBoolean as q, originPoint as r, squareExp as s, tsParticles as t, minStrokeWidth as u, defaultZoom as v, itemFromArray as w, defaultOpacity as x, randomColorValue as y, half as z };