1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.ConfettiOptions = void 0;
|
4 | const tsparticles_engine_1 = require("tsparticles-engine");
|
5 | class ConfettiOptions {
|
6 | constructor() {
|
7 | this.angle = 90;
|
8 | this.count = 50;
|
9 | this.spread = 45;
|
10 | this.startVelocity = 45;
|
11 | this.decay = 0.9;
|
12 | this.gravity = 1;
|
13 | this.drift = 0;
|
14 | this.ticks = 200;
|
15 | this.position = {
|
16 | x: 50,
|
17 | y: 50,
|
18 | };
|
19 | this.colors = ["#26ccff", "#a25afd", "#ff5e7e", "#88ff5a", "#fcff42", "#ffa62d", "#ff36ff"];
|
20 | this.shapes = ["square", "circle"];
|
21 | this.scalar = 1;
|
22 | this.zIndex = 100;
|
23 | this.disableForReducedMotion = true;
|
24 | this.shapeOptions = {};
|
25 | }
|
26 | get origin() {
|
27 | return {
|
28 | x: this.position.x / 100,
|
29 | y: this.position.y / 100,
|
30 | };
|
31 | }
|
32 | set origin(value) {
|
33 | this.position.x = value.x * 100;
|
34 | this.position.y = value.y * 100;
|
35 | }
|
36 | get particleCount() {
|
37 | return this.count;
|
38 | }
|
39 | set particleCount(value) {
|
40 | this.count = value;
|
41 | }
|
42 | load(data) {
|
43 | var _a, _b;
|
44 | if (!data) {
|
45 | return;
|
46 | }
|
47 | if (data.angle !== undefined) {
|
48 | this.angle = data.angle;
|
49 | }
|
50 | const count = (_a = data.count) !== null && _a !== void 0 ? _a : data.particleCount;
|
51 | if (count !== undefined) {
|
52 | this.count = count;
|
53 | }
|
54 | if (data.spread !== undefined) {
|
55 | this.spread = data.spread;
|
56 | }
|
57 | if (data.startVelocity !== undefined) {
|
58 | this.startVelocity = data.startVelocity;
|
59 | }
|
60 | if (data.decay !== undefined) {
|
61 | this.decay = data.decay;
|
62 | }
|
63 | if (data.gravity !== undefined) {
|
64 | this.gravity = data.gravity;
|
65 | }
|
66 | if (data.drift !== undefined) {
|
67 | this.drift = data.drift;
|
68 | }
|
69 | if (data.ticks !== undefined) {
|
70 | this.ticks = data.ticks;
|
71 | }
|
72 | const origin = data.origin;
|
73 | if (origin && !data.position) {
|
74 | data.position = {
|
75 | x: origin.x !== undefined ? origin.x * 100 : undefined,
|
76 | y: origin.y !== undefined ? origin.y * 100 : undefined,
|
77 | };
|
78 | }
|
79 | const position = data.position;
|
80 | if (position) {
|
81 | if (position.x !== undefined) {
|
82 | this.position.x = position.x;
|
83 | }
|
84 | if (position.y !== undefined) {
|
85 | this.position.y = position.y;
|
86 | }
|
87 | }
|
88 | if (data.colors !== undefined) {
|
89 | if (data.colors instanceof Array) {
|
90 | this.colors = [...data.colors];
|
91 | }
|
92 | else {
|
93 | this.colors = data.colors;
|
94 | }
|
95 | }
|
96 | const options = data.shapeOptions;
|
97 | if (options !== undefined) {
|
98 | for (const shape in options) {
|
99 | const item = options[shape];
|
100 | if (item) {
|
101 | this.shapeOptions[shape] = (0, tsparticles_engine_1.deepExtend)((_b = this.shapeOptions[shape]) !== null && _b !== void 0 ? _b : {}, item);
|
102 | }
|
103 | }
|
104 | }
|
105 | if (data.shapes !== undefined) {
|
106 | if (data.shapes instanceof Array) {
|
107 | this.shapes = [...data.shapes];
|
108 | }
|
109 | else {
|
110 | this.shapes = data.shapes;
|
111 | }
|
112 | }
|
113 | if (data.scalar !== undefined) {
|
114 | this.scalar = data.scalar;
|
115 | }
|
116 | if (data.zIndex !== undefined) {
|
117 | this.zIndex = data.zIndex;
|
118 | }
|
119 | if (data.disableForReducedMotion !== undefined) {
|
120 | this.disableForReducedMotion = data.disableForReducedMotion;
|
121 | }
|
122 | }
|
123 | }
|
124 | exports.ConfettiOptions = ConfettiOptions;
|