jl-particle-interactive 0.1.0 → 0.2.1

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.
@@ -1,9 +1,470 @@
1
- var H = Object.defineProperty;
2
- var j = (n, t, e) => t in n ? H(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var y = (n, t, e) => j(n, typeof t != "symbol" ? t + "" : t, e);
4
- import { jsx as L } from "react/jsx-runtime";
5
- import { useRef as E, useEffect as z } from "react";
6
- const G = {
1
+ var J = Object.defineProperty;
2
+ var K = (t, e, n) => e in t ? J(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var g = (t, e, n) => K(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { jsx as $, jsxs as _ } from "react/jsx-runtime";
5
+ import { useRef as I, useEffect as L } from "react";
6
+ function U(t, e, n, i) {
7
+ let s = e + t.baseX, m = n + t.baseY;
8
+ s += Math.sin(i * t.randomSpeed + t.baseY * 0.05) * 15 * t.z, m += Math.cos(i * t.randomSpeed + t.baseX * 0.05) * 15 * t.z;
9
+ const r = s - t.x, o = m - t.y, h = r * 0.06, y = o * 0.06;
10
+ return { forceX: h, forceY: y };
11
+ }
12
+ function Q(t, e, n, i, s, m) {
13
+ const r = i, o = s, h = t.x - r, y = t.y - o, d = Math.max(Math.sqrt(h * h + y * y), 1);
14
+ let c = 0, a = 0;
15
+ const u = Math.sin(d * 0.02 - m * 3) * 2.5 * t.z;
16
+ c += h / d * u, a += y / d * u;
17
+ const P = Math.cos(d * 0.01 - m * 1 + t.randomSpeed) * 0.8 * t.z, q = -y / d, b = h / d;
18
+ return c += q * P, a += b * P, { forceX: c, forceY: a, dxCenter: h, dyCenter: y, distToCenter: d };
19
+ }
20
+ function V(t, e) {
21
+ let s = Math.min(e / 400, 1) * 2.5 + t.sizeBias * 1;
22
+ s < 0.4 && (s = 0), t.scale += (s - t.scale) * 0.15;
23
+ }
24
+ function Z(t, e, n, i, s, m) {
25
+ let r = 0, o = 0;
26
+ s === "horizontal" ? (r = 1, o = 0) : s === "diagonal" ? (r = -e / i, o = -n / i) : (r = -n / i, o = e / i);
27
+ const h = Math.atan2(o, r), y = t.sizeBias > 0.3 ? 1 : 0, d = Math.max(0, Math.sin(m * 0.5 + t.randomSpeed * 10)), c = Math.sin(m * 3 + t.baseX * 0.1 + t.randomSpeed) * 0.5 * d * y;
28
+ r = Math.cos(h + c), o = Math.sin(h + c);
29
+ const a = Math.max(1 - i / 400, 0.1);
30
+ s === "horizontal" ? (t.dirX = t.dirX * (1 - 0.2) + r * 0.2, t.dirY = t.dirY * (1 - 0.2) + o * 0.2) : (t.dirX = t.dirX * (1 - a * 0.3) + r * a * 0.3, t.dirY = t.dirY * (1 - a * 0.3) + o * a * 0.3);
31
+ const l = Math.sqrt(t.dirX * t.dirX + t.dirY * t.dirY);
32
+ l > 0 && (t.dirX /= l, t.dirY /= l);
33
+ }
34
+ class tt {
35
+ constructor(e, n, i) {
36
+ g(this, "x");
37
+ g(this, "y");
38
+ g(this, "baseX");
39
+ // Relative X to swarm center
40
+ g(this, "baseY");
41
+ // Relative Y to swarm center
42
+ g(this, "z");
43
+ g(this, "vx");
44
+ g(this, "vy");
45
+ g(this, "color");
46
+ g(this, "targetColor", null);
47
+ g(this, "colorDelay", 0);
48
+ g(this, "angleTarget");
49
+ g(this, "randomSpeed");
50
+ g(this, "sizeBias");
51
+ g(this, "scale");
52
+ g(this, "dirX");
53
+ g(this, "dirY");
54
+ g(this, "initialized", !1);
55
+ this.x = e, this.y = n, this.baseX = e, this.baseY = n, this.z = Math.random() * 1.5 + 0.2, this.vx = 0, this.vy = 0, this.color = i, this.angleTarget = Math.random() * Math.PI * 2, this.randomSpeed = Math.random() * 2 + 1, this.sizeBias = Math.random(), this.scale = 1, this.dirX = Math.cos(this.angleTarget), this.dirY = Math.sin(this.angleTarget);
56
+ }
57
+ update(e, n, i, s, m, r, o, h = "vertical") {
58
+ this.initialized || (this.x = i + this.baseX, this.y = s + this.baseY, this.initialized = !0);
59
+ const {
60
+ forceX: y,
61
+ forceY: d,
62
+ dxCenter: c,
63
+ dyCenter: a,
64
+ distToCenter: l
65
+ } = Q(this, e, n, i, s, o), {
66
+ forceX: u,
67
+ forceY: w
68
+ } = U(this, i, s, o);
69
+ this.vx += y + u, this.vy += d + w, this.vx *= 0.75, this.vy *= 0.75, this.x += this.vx, this.y += this.vy, V(this, l), Z(this, c, a, l, h, o), this.targetColor && (this.colorDelay -= 1, this.colorDelay <= 0 && (this.color = this.targetColor, this.targetColor = null));
70
+ }
71
+ draw(e, n, i = "bean") {
72
+ if (this.scale <= 0.05) return;
73
+ e.fillStyle = this.color;
74
+ const s = Math.sqrt(this.baseX * this.baseX + this.baseY * this.baseY), m = Math.max(0, 1 - s / 350);
75
+ if (e.globalAlpha = Math.min(1, (0.5 + this.z * 0.5) * Math.min(this.scale, 1) * m), !(e.globalAlpha <= 0.01))
76
+ if (i === "circle") {
77
+ const r = Math.max(0.1, 2 * this.scale * this.z);
78
+ e.beginPath(), e.arc(this.x, this.y, r, 0, Math.PI * 2), e.fill();
79
+ } else if (i === "square") {
80
+ const r = Math.max(0.1, 2 * this.scale * this.z);
81
+ e.fillRect(this.x - r, this.y - r, r * 2, r * 2);
82
+ } else {
83
+ const o = (6 + this.sizeBias * 6) * this.scale, h = Math.sin(n * 3.5 + this.baseX * 0.1 + this.randomSpeed * 5), y = 0.4 + 0.6 * ((h + 1) / 2), d = o * 0.5 * y, c = Math.max(0.8, this.z * 1.5 * this.scale * (0.8 + 0.2 * h)), a = Math.atan2(this.dirY, this.dirX);
84
+ e.beginPath(), e.ellipse(this.x, this.y, d, c, a, 0, Math.PI * 2), e.fill();
85
+ }
86
+ }
87
+ }
88
+ function et({ config: t, backgroundColor: e }) {
89
+ const n = I(null), i = I(null), s = I([]), m = I(0), r = I({ x: -1e3, y: -1e3, isDown: !1, active: !1 }), o = I({ x: 0, y: 0, initialized: !1 });
90
+ L(() => {
91
+ const c = (l) => {
92
+ if (!n.current) return;
93
+ const u = n.current.getBoundingClientRect();
94
+ r.current.x = l.clientX - u.left, r.current.y = l.clientY - u.top, r.current.active = !0;
95
+ }, a = () => {
96
+ r.current.active = !1;
97
+ };
98
+ return window.addEventListener("pointermove", c), window.addEventListener("pointerleave", a), () => {
99
+ window.removeEventListener("pointermove", c), window.removeEventListener("pointerleave", a);
100
+ };
101
+ }, []);
102
+ const h = I(t), y = I(null), d = I(0);
103
+ return L(() => {
104
+ h.current = t;
105
+ }, [t]), L(() => {
106
+ if (y.current && (clearInterval(y.current), y.current = null), !t.colors || t.colors.length === 0) {
107
+ const a = t.color || "#8B5CF6";
108
+ s.current.forEach((l) => {
109
+ l.targetColor = a, l.colorDelay = Math.random() * 20;
110
+ });
111
+ return;
112
+ }
113
+ const c = (a) => {
114
+ const l = r.current.active ? r.current.x : o.current.x, u = r.current.active ? r.current.y : o.current.y;
115
+ s.current.forEach((w) => {
116
+ const P = w.x - l, q = w.y - u, b = Math.sqrt(P * P + q * q);
117
+ w.targetColor = a, w.colorDelay = Math.max(0, b * 0.15);
118
+ });
119
+ };
120
+ return t.colorMode === "mixed" ? s.current.forEach((a, l) => {
121
+ a.targetColor = t.colors[l % t.colors.length], a.colorDelay = Math.random() * 20;
122
+ }) : (d.current = 0, c(t.colors[0]), t.colors.length > 1 && (y.current = setInterval(() => {
123
+ const a = t.colors;
124
+ d.current = (d.current + 1) % a.length, c(a[d.current]);
125
+ }, 3e3))), () => {
126
+ y.current && clearInterval(y.current);
127
+ };
128
+ }, [t.colors, t.color, t.colorMode]), L(() => {
129
+ if (!n.current || !i.current || h.current.name === "NONE") return;
130
+ const c = i.current, a = n.current, l = (b) => {
131
+ for (const C of b) {
132
+ const { width: f, height: p } = C.contentRect, R = window.devicePixelRatio || 1;
133
+ c.width = f * R, c.height = p * R, c.style.width = `${f}px`, c.style.height = `${p}px`;
134
+ const S = c.getContext("2d");
135
+ S && S.scale(R, R), s.current = [];
136
+ const z = Math.floor(350 * (h.current.density ?? 1)), v = h.current.colors, X = h.current.colorMode || "wave";
137
+ for (let M = 0; M < z; M++) {
138
+ const x = Math.sqrt(Math.random()) * 350, Y = Math.random() * Math.PI * 2, E = Math.cos(Y) * x, T = Math.sin(Y) * x;
139
+ let F;
140
+ if (v && v.length > 0)
141
+ F = X === "mixed" ? v[M % v.length] : v[0];
142
+ else if (h.current.color)
143
+ F = h.current.color;
144
+ else {
145
+ const A = 210 + Math.max(0, Math.min(1, (E + 350) / 700)) * 130 + (Math.random() * 15 - 7.5), O = 75 + Math.random() * 25, N = 60 + Math.random() * 15;
146
+ F = `hsl(${A}, ${O}%, ${N}%)`;
147
+ }
148
+ s.current.push(new tt(E, T, F));
149
+ }
150
+ }
151
+ }, u = new ResizeObserver(l);
152
+ u.observe(a);
153
+ const w = c.getContext("2d");
154
+ let P = 0;
155
+ const q = () => {
156
+ const b = a.getBoundingClientRect();
157
+ if (w.clearRect(0, 0, b.width, b.height), e !== "transparent" && (w.fillStyle = e, w.fillRect(0, 0, b.width, b.height)), o.current.initialized || (o.current.x = b.width / 2, o.current.y = b.height / 2, o.current.initialized = !0), h.current.name === "FOLLOW_POINTER") {
158
+ let C = b.width / 2, f = b.height / 2;
159
+ const p = r.current.active ? r.current.x : null, R = r.current.active ? r.current.y : null;
160
+ p !== null && R !== null && (C = p, f = R);
161
+ const S = h.current.pointerTrackingSpeed ?? 0.06;
162
+ o.current.x += (C - o.current.x) * S, o.current.y += (f - o.current.y) * S;
163
+ const D = h.current.particleSpeed ?? 1;
164
+ P += 0.012 * D;
165
+ const z = s.current, v = 18, X = v * v;
166
+ for (let M = 0; M < z.length; M++) {
167
+ const x = z[M];
168
+ for (let Y = M + 1; Y < z.length; Y++) {
169
+ const E = z[Y], T = x.x - E.x, F = x.y - E.y, W = T * T + F * F;
170
+ if (W < X && W > 0) {
171
+ const A = Math.sqrt(W), O = (v - A) / v, N = T / A * O * 0.8, B = F / A * O * 0.8;
172
+ x.x += N, x.y += B, E.x -= N, E.y -= B, x.vx += N * 0.1, x.vy += B * 0.1, E.vx -= N * 0.1, E.vy -= B * 0.1;
173
+ }
174
+ }
175
+ }
176
+ for (const M of z) {
177
+ M.update(p, R, o.current.x, o.current.y, b.width, b.height, P, h.current.orientation);
178
+ const x = h.current.shape || "bean";
179
+ M.draw(w, P, x);
180
+ }
181
+ }
182
+ m.current = requestAnimationFrame(q);
183
+ };
184
+ return q(), () => {
185
+ u.disconnect(), cancelAnimationFrame(m.current);
186
+ };
187
+ }, [e, t.density]), t.name === "NONE" ? null : /* @__PURE__ */ $("div", { ref: n, style: { position: "absolute", inset: 0, zIndex: 0, overflow: "hidden" }, children: /* @__PURE__ */ $("canvas", { ref: i, style: { display: "block", width: "100%", height: "100%" } }) });
188
+ }
189
+ class nt {
190
+ constructor(e, n) {
191
+ g(this, "x");
192
+ g(this, "y");
193
+ g(this, "vx");
194
+ g(this, "vy");
195
+ g(this, "radius");
196
+ g(this, "currentColor", "#8B5CF6");
197
+ g(this, "targetColor", null);
198
+ g(this, "colorDelay", 0);
199
+ this.x = e, this.y = n;
200
+ const i = Math.random() * Math.PI * 2, s = Math.random() * 0.5 + 0.1;
201
+ this.vx = Math.cos(i) * s, this.vy = Math.sin(i) * s, this.radius = Math.random() * 1.5 + 1;
202
+ }
203
+ update(e, n, i, s, m = 1, r = 0.06) {
204
+ if (this.x += this.vx * m, this.y += this.vy * m, this.x < 0 ? (this.x = 0, this.vx *= -1) : this.x > e && (this.x = e, this.vx *= -1), this.y < 0 ? (this.y = 0, this.vy *= -1) : this.y > n && (this.y = n, this.vy *= -1), i !== null && s !== null) {
205
+ const o = i - this.x, h = s - this.y, y = o * o + h * h, d = 150, c = d * d;
206
+ if (y < c) {
207
+ const a = Math.sqrt(y), l = (d - a) / d, u = r / 0.06;
208
+ this.x -= o / a * l * 2 * u, this.y -= h / a * l * 2 * u;
209
+ }
210
+ }
211
+ this.targetColor && (this.colorDelay -= 1 * m, this.colorDelay <= 0 && (this.currentColor = this.targetColor, this.targetColor = null));
212
+ }
213
+ draw(e, n = "circle", i = 0) {
214
+ if (e.fillStyle = this.currentColor, n === "square")
215
+ e.fillRect(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);
216
+ else if (n === "bean") {
217
+ const s = Math.sin(i * 0.05 + this.x * 0.01 + this.y * 0.01), m = this.radius * 2 * (0.8 + 0.4 * s), r = this.radius * (0.8 + 0.2 * s), o = this.vx !== 0 || this.vy !== 0 ? Math.atan2(this.vy, this.vx) : 0;
218
+ e.beginPath(), e.ellipse(this.x, this.y, m, r, o, 0, Math.PI * 2), e.fill();
219
+ } else
220
+ e.beginPath(), e.arc(this.x, this.y, this.radius, 0, Math.PI * 2), e.fill();
221
+ }
222
+ }
223
+ function rt({ config: t, backgroundColor: e }) {
224
+ const n = I(null), i = I(null), s = I([]), m = I(0), r = I({ x: -1e3, y: -1e3, active: !1 });
225
+ L(() => {
226
+ const d = (a) => {
227
+ if (!n.current) return;
228
+ const l = n.current.getBoundingClientRect();
229
+ r.current.x = a.clientX - l.left, r.current.y = a.clientY - l.top, r.current.active = !0;
230
+ }, c = () => {
231
+ r.current.active = !1;
232
+ };
233
+ return window.addEventListener("pointermove", d), window.addEventListener("pointerleave", c), () => {
234
+ window.removeEventListener("pointermove", d), window.removeEventListener("pointerleave", c);
235
+ };
236
+ }, []);
237
+ const o = I(t), h = I(0), y = I(null);
238
+ return L(() => {
239
+ o.current = t;
240
+ }, [t]), L(() => {
241
+ if (y.current && (clearInterval(y.current), y.current = null), !t.colors || t.colors.length === 0) {
242
+ const l = t.color || "#8B5CF6";
243
+ s.current.forEach((u) => {
244
+ u.targetColor = l, u.colorDelay = Math.random() * 20;
245
+ });
246
+ return;
247
+ }
248
+ const d = r.current.active ? r.current.x : n.current ? n.current.clientWidth / 2 : 0, c = r.current.active ? r.current.y : n.current ? n.current.clientHeight / 2 : 0, a = (l) => {
249
+ s.current.forEach((u) => {
250
+ const w = u.x - d, P = u.y - c, q = Math.sqrt(w * w + P * P);
251
+ u.targetColor = l, u.colorDelay = Math.max(0, q * 0.2);
252
+ });
253
+ };
254
+ return t.colorMode === "mixed" ? s.current.forEach((l, u) => {
255
+ l.targetColor = t.colors[u % t.colors.length], l.colorDelay = Math.random() * 20;
256
+ }) : (h.current = 0, a(t.colors[0]), t.colors.length > 1 && (y.current = setInterval(() => {
257
+ const l = t.colors;
258
+ h.current = (h.current + 1) % l.length, a(l[h.current]);
259
+ }, 3e3))), () => {
260
+ y.current && clearInterval(y.current);
261
+ };
262
+ }, [t.colors, t.color, t.colorMode]), L(() => {
263
+ if (!n.current || !i.current) return;
264
+ const d = i.current, c = n.current, a = (q) => {
265
+ for (const b of q) {
266
+ const { width: C, height: f } = b.contentRect, p = window.devicePixelRatio || 1;
267
+ d.width = C * p, d.height = f * p, d.style.width = `${C}px`, d.style.height = `${f}px`;
268
+ const R = d.getContext("2d");
269
+ R && R.scale(p, p), s.current = [];
270
+ const S = C * f, D = o.current.density ?? 1, z = Math.min(
271
+ Math.floor(300 * D),
272
+ Math.floor(S / 6e3 * D)
273
+ ), v = o.current.colors, X = o.current.colorMode || "wave";
274
+ for (let M = 0; M < z; M++) {
275
+ const x = new nt(Math.random() * C, Math.random() * f);
276
+ v && v.length > 0 ? x.currentColor = X === "mixed" ? v[M % v.length] : v[0] : o.current.color && (x.currentColor = o.current.color), s.current.push(x);
277
+ }
278
+ }
279
+ }, l = new ResizeObserver(a);
280
+ l.observe(c);
281
+ const u = d.getContext("2d");
282
+ let w = 0;
283
+ const P = () => {
284
+ w += 1;
285
+ const q = c.getBoundingClientRect();
286
+ u.clearRect(0, 0, q.width, q.height), e !== "transparent" && (u.fillStyle = e, u.fillRect(0, 0, q.width, q.height));
287
+ const b = r.current.active ? r.current.x : null, C = r.current.active ? r.current.y : null, f = s.current, p = o.current.shape || "circle", R = 120, S = R * R, D = o.current.particleSpeed ?? 1, z = o.current.pointerTrackingSpeed ?? 0.06;
288
+ for (let v = 0; v < f.length; v++) {
289
+ const X = f[v];
290
+ X.update(q.width, q.height, b, C, D, z), u.globalAlpha = 1, X.draw(u, p, w);
291
+ for (let M = v + 1; M < f.length; M++) {
292
+ const x = f[M], Y = X.x - x.x, E = X.y - x.y, T = Y * Y + E * E;
293
+ if (T < S) {
294
+ const F = 1 - Math.sqrt(T) / R;
295
+ u.beginPath(), u.moveTo(X.x, X.y), u.lineTo(x.x, x.y), u.strokeStyle = X.currentColor, u.globalAlpha = F * 0.5, u.lineWidth = 1, u.stroke();
296
+ }
297
+ }
298
+ }
299
+ if (u.globalAlpha = 1, b !== null && C !== null)
300
+ for (let M = 0; M < f.length; M++) {
301
+ const x = f[M], Y = x.x - b, E = x.y - C, T = Y * Y + E * E;
302
+ if (T < 22500) {
303
+ const F = 1 - Math.sqrt(T) / 150;
304
+ u.beginPath(), u.moveTo(x.x, x.y), u.lineTo(b, C), u.strokeStyle = x.currentColor, u.globalAlpha = F * 0.8, u.lineWidth = 1.5, u.stroke();
305
+ }
306
+ }
307
+ u.globalAlpha = 1, m.current = requestAnimationFrame(P);
308
+ };
309
+ return P(), () => {
310
+ l.disconnect(), cancelAnimationFrame(m.current);
311
+ };
312
+ }, [e, t.density]), /* @__PURE__ */ $("div", { ref: n, style: { position: "absolute", inset: 0, zIndex: 0, overflow: "hidden" }, children: /* @__PURE__ */ $("canvas", { ref: i, style: { display: "block", width: "100%", height: "100%" } }) });
313
+ }
314
+ class st {
315
+ constructor(e, n, i, s) {
316
+ g(this, "x", 0);
317
+ g(this, "y", 0);
318
+ g(this, "baseX");
319
+ g(this, "baseY");
320
+ g(this, "vx", 0);
321
+ g(this, "vy", 0);
322
+ g(this, "color");
323
+ g(this, "size");
324
+ g(this, "angle");
325
+ g(this, "dist");
326
+ g(this, "spring");
327
+ g(this, "friction");
328
+ g(this, "targetColor", null);
329
+ g(this, "colorDelay", 0);
330
+ this.baseX = e, this.baseY = n, this.color = i, this.size = s, this.angle = Math.atan2(n, e), this.dist = Math.sqrt(e * e + n * n);
331
+ const m = Math.min(1, this.dist / 350);
332
+ this.spring = 0.15 - m * 0.13, this.friction = 0.85 + m * 0.1;
333
+ }
334
+ update(e, n, i, s) {
335
+ const r = 1 + Math.sin(this.angle * 3 + i * 1.2) * 0.05 + Math.cos(this.angle * 5 - i * 0.6) * 0.03, o = this.dist * s * r, h = Math.cos(this.angle) * o, y = Math.sin(this.angle) * o, d = this.dist * 0.1 * r, c = Math.sin(i * 3 + this.dist * 0.05) * d, a = e + h + Math.cos(this.angle + Math.PI / 2) * c, l = n + y + Math.sin(this.angle + Math.PI / 2) * c, u = a - this.x, w = l - this.y;
336
+ this.vx += u * this.spring, this.vy += w * this.spring, this.vx *= this.friction, this.vy *= this.friction, this.x += this.vx, this.y += this.vy, this.targetColor && (this.colorDelay -= 1, this.colorDelay <= 0 && (this.color = this.targetColor, this.targetColor = null));
337
+ }
338
+ draw(e, n, i) {
339
+ const s = Math.min(1, this.dist / 350), m = 1 + (1 - s) * (i - 1) * 1.5, r = this.size * m;
340
+ e.globalAlpha = Math.max(0.15, 1 - s * 0.7), e.fillStyle = this.color, e.beginPath(), n === "circle" ? e.arc(this.x, this.y, r, 0, Math.PI * 2) : n === "square" ? e.rect(this.x - r, this.y - r, r * 2, r * 2) : e.ellipse(this.x, this.y, r * 1.5, r, 0, 0, Math.PI * 2), e.fill();
341
+ }
342
+ }
343
+ function ot({ config: t, backgroundColor: e }) {
344
+ const n = I(null), i = I(null), s = I([]), m = I(0), r = I({ x: -1e3, y: -1e3, active: !1 }), o = I({ x: 0, y: 0, initialized: !1, angle: -Math.PI / 2 });
345
+ L(() => {
346
+ const c = (a) => {
347
+ if (!n.current) return;
348
+ const l = n.current.getBoundingClientRect();
349
+ r.current.x = a.clientX - l.left, r.current.y = a.clientY - l.top, r.current.active = !0;
350
+ };
351
+ return window.addEventListener("pointermove", c), () => {
352
+ window.removeEventListener("pointermove", c);
353
+ };
354
+ }, []);
355
+ const h = I(t), y = I(0), d = I(null);
356
+ return L(() => {
357
+ h.current = t;
358
+ }, [t]), L(() => {
359
+ if (d.current && (clearInterval(d.current), d.current = null), !t.colors || t.colors.length === 0) {
360
+ const a = t.color || "#8B5CF6";
361
+ s.current.forEach((l) => {
362
+ l.targetColor = a, l.colorDelay = Math.random() * 20;
363
+ });
364
+ return;
365
+ }
366
+ const c = (a) => {
367
+ s.current.forEach((l) => {
368
+ l.targetColor = a, l.colorDelay = Math.max(0, l.dist * 0.2);
369
+ });
370
+ };
371
+ return t.colorMode === "mixed" ? s.current.forEach((a, l) => {
372
+ a.targetColor = t.colors[l % t.colors.length], a.colorDelay = Math.max(0, a.dist * 0.2) + Math.random() * 10;
373
+ }) : (y.current = 0, c(t.colors[0]), t.colors.length > 1 && (d.current = setInterval(() => {
374
+ const a = t.colors;
375
+ y.current = (y.current + 1) % a.length, c(a[y.current]);
376
+ }, 3e3))), () => {
377
+ d.current && clearInterval(d.current);
378
+ };
379
+ }, [t.colors, t.color, t.colorMode]), L(() => {
380
+ if (!n.current || !i.current) return;
381
+ const c = i.current, a = n.current, l = (b) => {
382
+ for (const C of b) {
383
+ const { width: f, height: p } = C.contentRect, R = window.devicePixelRatio || 1;
384
+ c.width = f * R, c.height = p * R, c.style.width = `${f}px`, c.style.height = `${p}px`;
385
+ const S = c.getContext("2d");
386
+ S && S.scale(R, R), s.current = [];
387
+ const z = Math.floor(350 * (h.current.density ?? 1)), v = h.current.colors, X = h.current.colorMode || "wave";
388
+ for (let M = 0; M < z; M++) {
389
+ const x = Math.random() * Math.PI * 2, Y = Math.sqrt(Math.random()) * 350, E = Math.cos(x) * Y, T = Math.sin(x) * Y;
390
+ let F;
391
+ if (v && v.length > 0)
392
+ F = X === "mixed" ? v[M % v.length] : v[0];
393
+ else if (h.current.color)
394
+ F = h.current.color;
395
+ else {
396
+ const O = 260 + Math.random() * 60, N = 70 + Math.random() * 30, B = 60 + Math.random() * 20;
397
+ F = `hsl(${O}, ${N}%, ${B}%)`;
398
+ }
399
+ let W = 2 + Math.random() * 2;
400
+ Y > 200 && (W *= 0.6), Y < 80 && (W *= 1.5);
401
+ const A = new st(E, T, F, W);
402
+ A.x = f / 2, A.y = p / 2, s.current.push(A);
403
+ }
404
+ }
405
+ }, u = new ResizeObserver(l);
406
+ u.observe(a);
407
+ const w = c.getContext("2d");
408
+ let P = 0;
409
+ const q = () => {
410
+ const b = a.getBoundingClientRect();
411
+ w.globalCompositeOperation = "source-over", e === "transparent" ? w.clearRect(0, 0, b.width, b.height) : (w.fillStyle = e, w.fillRect(0, 0, b.width, b.height)), o.current.initialized || (o.current.x = b.width / 2, o.current.y = b.height / 2, o.current.initialized = !0);
412
+ let C = b.width / 2, f = b.height / 2;
413
+ const p = r.current.active ? r.current.x : null, R = r.current.active ? r.current.y : null;
414
+ p !== null && R !== null && (C = p, f = R);
415
+ const S = C - o.current.x, D = f - o.current.y, z = Math.sqrt(S * S + D * D);
416
+ let v = 0, X = 0;
417
+ z > 1 ? (v = S / z, X = D / z, o.current.angle = Math.atan2(X, v)) : (v = Math.cos(o.current.angle), X = Math.sin(o.current.angle));
418
+ const M = h.current.particleSpeed ?? 1;
419
+ P += 0.02 * M;
420
+ const x = P % 4;
421
+ let Y = 1, E = 1, T = 0;
422
+ if (x < 1) {
423
+ const B = x;
424
+ Y = 1 - Math.sin(B * Math.PI) * 0.3, E = 1 + Math.sin(B * Math.PI) * 0.15, T = Math.sin(B * Math.PI) * 12;
425
+ } else {
426
+ const B = (x - 1) / 3;
427
+ Y = 0.7 + 0.3 * Math.sin(B * Math.PI / 2), E = 1, T = 0;
428
+ }
429
+ const F = h.current.pointerTrackingSpeed ?? 0.02;
430
+ o.current.x += S * F, o.current.y += D * F, o.current.x += v * T * M, o.current.y += X * T * M;
431
+ const A = 200 * (E + (x < 1 ? x * 0.15 : 0)), O = w.createRadialGradient(
432
+ o.current.x,
433
+ o.current.y,
434
+ 0,
435
+ o.current.x,
436
+ o.current.y,
437
+ A
438
+ );
439
+ O.addColorStop(0, "rgba(80, 150, 255, 0.05)"), O.addColorStop(1, "rgba(80, 150, 255, 0)"), w.fillStyle = O, w.beginPath(), w.arc(o.current.x, o.current.y, A, 0, Math.PI * 2), w.fill();
440
+ const N = s.current;
441
+ w.globalCompositeOperation = "source-over";
442
+ for (const B of N) {
443
+ B.update(o.current.x, o.current.y, P, Y);
444
+ const G = h.current.shape || "circle";
445
+ B.draw(w, G, E);
446
+ }
447
+ m.current = requestAnimationFrame(q);
448
+ };
449
+ return q(), () => {
450
+ u.disconnect(), cancelAnimationFrame(m.current);
451
+ };
452
+ }, [e, t.density]), /* @__PURE__ */ $(
453
+ "div",
454
+ {
455
+ ref: n,
456
+ style: { position: "absolute", inset: 0, zIndex: 0, overflow: "hidden", pointerEvents: "none" },
457
+ children: /* @__PURE__ */ $(
458
+ "canvas",
459
+ {
460
+ ref: i,
461
+ style: { display: "block", width: "100%", height: "100%", pointerEvents: "none" }
462
+ }
463
+ )
464
+ }
465
+ );
466
+ }
467
+ const it = {
7
468
  position: "relative",
8
469
  border: "1px solid rgba(255, 255, 255, 0.1)",
9
470
  borderRadius: "1rem",
@@ -11,257 +472,288 @@ const G = {
11
472
  boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
12
473
  transition: "all 300ms ease-out"
13
474
  };
14
- function _({
15
- children: n,
16
- width: t = "100%",
17
- height: e = "60vh",
18
- backgroundColor: r = "#050505",
19
- className: a = "",
20
- style: l
475
+ function ft({
476
+ children: t,
477
+ width: e = "100%",
478
+ height: n = "60vh",
479
+ backgroundColor: i = "#050505",
480
+ className: s = "",
481
+ style: m,
482
+ background: r = { name: "NONE" }
21
483
  }) {
22
- return /* @__PURE__ */ L(
484
+ return /* @__PURE__ */ _(
23
485
  "div",
24
486
  {
25
- className: a,
26
- style: { ...G, width: t, height: e, backgroundColor: r, ...l },
27
- children: n
487
+ className: s,
488
+ style: { ...it, width: e, height: n, backgroundColor: i, ...m },
489
+ children: [
490
+ r.name === "FOLLOW_POINTER" && /* @__PURE__ */ $(et, { config: r, backgroundColor: i }),
491
+ r.name === "NET" && /* @__PURE__ */ $(rt, { config: r, backgroundColor: i }),
492
+ r.name === "JELLYFISH" && /* @__PURE__ */ $(ot, { config: r, backgroundColor: i }),
493
+ /* @__PURE__ */ $("div", { style: { position: "relative", zIndex: 10, width: "100%", height: "100%" }, children: t })
494
+ ]
28
495
  }
29
496
  );
30
497
  }
31
- function K(n) {
32
- const t = E({ x: -1e3, y: -1e3, isDown: !1, active: !1 });
33
- return z(() => {
34
- const e = n.current;
35
- if (!e) return;
36
- const r = (D) => {
37
- const u = e.getBoundingClientRect();
38
- t.current.x = D.clientX - u.left, t.current.y = D.clientY - u.top, t.current.active = !0;
39
- }, a = () => {
40
- t.current.active = !1;
41
- }, l = () => {
42
- t.current.isDown = !0;
43
- }, x = () => {
44
- t.current.isDown = !1;
498
+ function ct(t) {
499
+ const e = I({ x: -1e3, y: -1e3, isDown: !1, active: !1 });
500
+ return L(() => {
501
+ const n = t.current;
502
+ if (!n) return;
503
+ const i = (o) => {
504
+ const h = n.getBoundingClientRect();
505
+ e.current.x = o.clientX - h.left, e.current.y = o.clientY - h.top, e.current.active = !0;
506
+ }, s = () => {
507
+ e.current.active = !1;
508
+ }, m = () => {
509
+ e.current.isDown = !0;
510
+ }, r = () => {
511
+ e.current.isDown = !1;
45
512
  };
46
- return e.addEventListener("pointermove", r), e.addEventListener("pointerleave", a), e.addEventListener("pointerdown", l), e.addEventListener("pointerup", x), e.style.touchAction = "none", () => {
47
- e.removeEventListener("pointermove", r), e.removeEventListener("pointerleave", a), e.removeEventListener("pointerdown", l), e.removeEventListener("pointerup", x);
513
+ return n.addEventListener("pointermove", i), n.addEventListener("pointerleave", s), n.addEventListener("pointerdown", m), n.addEventListener("pointerup", r), n.style.touchAction = "none", () => {
514
+ n.removeEventListener("pointermove", i), n.removeEventListener("pointerleave", s), n.removeEventListener("pointerdown", m), n.removeEventListener("pointerup", r);
48
515
  };
49
- }, [n]), t;
516
+ }, [t]), e;
50
517
  }
51
- function U(n, t, e, r, a, l, x, D, u) {
52
- if (a === null || l === null || !D && u === "none")
53
- return { x: e, y: r };
54
- let g = e, h = r;
55
- const i = a - n, d = l - t, f = i * i + d * d, p = Math.sqrt(f);
56
- if (D && !x && f < 3e4) {
57
- const v = (3e4 - f) / 3e4;
58
- g += i * v * 0.15, h += d * v * 0.15;
518
+ function at(t, e, n, i, s, m, r, o, h) {
519
+ if (s === null || m === null || !o && h === "none")
520
+ return { x: n, y: i };
521
+ let y = n, d = i;
522
+ const c = s - t, a = m - e, l = c * c + a * a, u = Math.sqrt(l);
523
+ if (o && !r && l < 3e4) {
524
+ const P = (3e4 - l) / 3e4;
525
+ y += c * P * 0.15, d += a * P * 0.15;
59
526
  }
60
- if (x && u !== "none") {
61
- if (u === "attract") {
62
- if (f < 3e4) {
63
- const v = (3e4 - f) / 3e4;
64
- g += i * v * 0.8, h += d * v * 0.8;
527
+ if (r && h !== "none") {
528
+ if (h === "attract") {
529
+ if (l < 3e4) {
530
+ const P = (3e4 - l) / 3e4;
531
+ y += c * P * 0.8, d += a * P * 0.8;
65
532
  }
66
- } else if (u === "repel" && f < 5e4 && p > 0) {
67
- const v = Math.pow(Math.max(0, 5e4 - f) / 5e4, 1.2);
68
- g -= i / p * v * 400, h -= d / p * v * 400;
533
+ } else if (h === "repel" && l < 5e4 && u > 0) {
534
+ const P = Math.pow(Math.max(0, 5e4 - l) / 5e4, 1.2);
535
+ y -= c / u * P * 400, d -= a / u * P * 400;
69
536
  }
70
537
  }
71
- return { x: g, y: h };
538
+ return { x: y, y: d };
72
539
  }
73
- class O {
74
- constructor(t, e, r = "255, 255, 255") {
75
- y(this, "x");
76
- y(this, "y");
77
- y(this, "vx");
78
- y(this, "vy");
79
- y(this, "targetX");
80
- y(this, "targetY");
81
- y(this, "baseColor");
82
- y(this, "opacity");
83
- y(this, "size");
84
- y(this, "sizeMultiplier");
85
- y(this, "friction");
86
- y(this, "ease");
87
- y(this, "easeMultiplier");
88
- y(this, "floatSpeed");
89
- y(this, "floatOffset");
90
- this.x = Math.random() * t, this.y = Math.random() * e, this.targetX = this.x, this.targetY = this.y, this.vx = 0, this.vy = 0, this.size = Math.random() * 1.8 + 0.5, this.sizeMultiplier = 1, this.baseColor = Array.isArray(r) ? r[Math.floor(Math.random() * r.length)] : r, this.opacity = 0.4 + Math.random() * 0.6, this.friction = 0.82 + Math.random() * 0.1, this.ease = 0.03 + Math.random() * 0.05, this.easeMultiplier = 1, this.floatSpeed = Math.random() * 0.02 + 5e-3, this.floatOffset = Math.random() * Math.PI * 2;
540
+ class H {
541
+ constructor(e, n, i = "255, 255, 255") {
542
+ g(this, "x");
543
+ g(this, "y");
544
+ g(this, "vx");
545
+ g(this, "vy");
546
+ g(this, "targetX");
547
+ g(this, "targetY");
548
+ g(this, "baseColor");
549
+ g(this, "opacity");
550
+ g(this, "size");
551
+ g(this, "sizeMultiplier");
552
+ g(this, "friction");
553
+ g(this, "ease");
554
+ g(this, "easeMultiplier");
555
+ g(this, "floatSpeed");
556
+ g(this, "floatOffset");
557
+ g(this, "randomSpeed");
558
+ this.x = Math.random() * e, this.y = Math.random() * n, this.targetX = this.x, this.targetY = this.y, this.vx = 0, this.vy = 0, this.size = Math.random() * 1.8 + 0.5, this.sizeMultiplier = 1, this.baseColor = Array.isArray(i) ? i[Math.floor(Math.random() * i.length)] : i, this.opacity = 0.4 + Math.random() * 0.6, this.friction = 0.82 + Math.random() * 0.1, this.ease = 0.03 + Math.random() * 0.05, this.easeMultiplier = 1, this.floatSpeed = Math.random() * 0.02 + 5e-3, this.floatOffset = Math.random() * Math.PI * 2, this.randomSpeed = Math.random();
91
559
  }
92
- update(t, e, r = null, a = null, l = !1, x = !0, D = "none") {
93
- const { x: u, y: g } = U(
560
+ update(e, n, i = null, s = null, m = !1, r = !0, o = "none") {
561
+ const { x: h, y } = at(
94
562
  this.x,
95
563
  this.y,
96
564
  this.targetX,
97
565
  this.targetY,
566
+ i,
567
+ s,
568
+ m,
98
569
  r,
99
- a,
100
- l,
101
- x,
102
- D
103
- ), h = u - this.x, i = g - this.y, d = e ? 0 : Math.cos(t * 0.01 + this.y * 0.01) * 0.5, f = e ? 0 : Math.sin(t * 0.01 + this.x * 0.01) * 0.5;
104
- this.vx += h * (this.ease * this.easeMultiplier) + d, this.vy += i * (this.ease * this.easeMultiplier) + f, this.vx *= this.friction, this.vy *= this.friction, this.x += this.vx, this.y += this.vy;
105
- const p = e ? 0.2 : 2;
106
- this.x += Math.cos(t * this.floatSpeed + this.floatOffset) * p, this.y += Math.sin(t * this.floatSpeed + this.floatOffset) * p;
570
+ o
571
+ ), d = h - this.x, c = y - this.y, a = n ? 0 : Math.cos(e * 0.01 + this.y * 0.01) * 0.5, l = n ? 0 : Math.sin(e * 0.01 + this.x * 0.01) * 0.5;
572
+ this.vx += d * (this.ease * this.easeMultiplier) + a, this.vy += c * (this.ease * this.easeMultiplier) + l, this.vx *= this.friction, this.vy *= this.friction, this.x += this.vx, this.y += this.vy;
573
+ const u = n ? 0.2 : 2;
574
+ this.x += Math.cos(e * this.floatSpeed + this.floatOffset) * u, this.y += Math.sin(e * this.floatSpeed + this.floatOffset) * u;
107
575
  }
108
- draw(t, e = "circle") {
109
- t.fillStyle = `rgba(${this.baseColor}, ${this.opacity})`;
110
- const r = Math.max(0.1, this.size * this.sizeMultiplier);
111
- e === "square" ? t.fillRect(this.x - r, this.y - r, r * 2, r * 2) : (t.beginPath(), t.arc(this.x, this.y, r, 0, Math.PI * 2), t.fill());
576
+ draw(e, n = "circle", i = 0) {
577
+ e.fillStyle = `rgba(${this.baseColor}, ${this.opacity})`;
578
+ const s = Math.max(0.1, this.size * this.sizeMultiplier);
579
+ if (n === "square")
580
+ e.fillRect(this.x - s, this.y - s, s * 2, s * 2);
581
+ else if (n === "bean") {
582
+ const m = 6 + this.size * 2 * this.sizeMultiplier, r = Math.sin(i * 0.05 + this.x * 0.01 + this.randomSpeed * 5), o = 0.4 + 0.6 * ((r + 1) / 2), h = m * 0.5 * o, y = Math.max(0.8, s * 1.5 * (0.8 + 0.2 * r)), d = this.vx !== 0 || this.vy !== 0 ? Math.atan2(this.vy, this.vx) : 0;
583
+ e.beginPath(), e.ellipse(this.x, this.y, h, y, d, 0, Math.PI * 2), e.fill();
584
+ } else
585
+ e.beginPath(), e.arc(this.x, this.y, s, 0, Math.PI * 2), e.fill();
112
586
  }
113
587
  }
114
- function A(n, t, e) {
115
- if (t <= 0 || e <= 0) return [];
116
- const r = document.createElement("canvas");
117
- r.width = t, r.height = e;
118
- const a = r.getContext("2d", { willReadFrequently: !0 });
119
- if (!a) return [];
120
- a.clearRect(0, 0, t, e);
121
- let l = Math.min(t, e) * 0.65;
122
- a.font = `bold ${l}px "Georgia", serif`;
123
- const x = a.measureText(n);
124
- x.width > t * 0.9 && (l = l * (t * 0.9) / x.width, a.font = `bold ${l}px "Georgia", serif`), a.fillStyle = "white", a.textAlign = "center", a.textBaseline = "middle", a.fillText(n, t / 2, e / 2.05);
125
- const u = a.getImageData(0, 0, t, e).data, g = [], h = window.innerWidth < 600 ? 6 : 8;
126
- for (let i = 0; i < e; i += h)
127
- for (let d = 0; d < t; d += h) {
128
- const f = (i * t + d) * 4;
129
- u[f + 3] > 128 && g.push({
130
- x: d + (Math.random() - 0.5) * 4,
131
- y: i + (Math.random() - 0.5) * 4
588
+ function j(t, e, n) {
589
+ if (e <= 0 || n <= 0) return [];
590
+ const i = document.createElement("canvas");
591
+ i.width = e, i.height = n;
592
+ const s = i.getContext("2d", { willReadFrequently: !0 });
593
+ if (!s) return [];
594
+ s.clearRect(0, 0, e, n);
595
+ let m = Math.min(e, n) * 0.65;
596
+ s.font = `bold ${m}px "Georgia", serif`;
597
+ const r = s.measureText(t);
598
+ r.width > e * 0.9 && (m = m * (e * 0.9) / r.width, s.font = `bold ${m}px "Georgia", serif`), s.fillStyle = "white", s.textAlign = "center", s.textBaseline = "middle", s.fillText(t, e / 2, n / 2.05);
599
+ const h = s.getImageData(0, 0, e, n).data, y = [], d = window.innerWidth < 600 ? 6 : 8;
600
+ for (let c = 0; c < n; c += d)
601
+ for (let a = 0; a < e; a += d) {
602
+ const l = (c * e + a) * 4;
603
+ h[l + 3] > 128 && y.push({
604
+ x: a + (Math.random() - 0.5) * 4,
605
+ y: c + (Math.random() - 0.5) * 4
132
606
  });
133
607
  }
134
- return g;
608
+ return y;
135
609
  }
136
- function J(n, t, e) {
137
- const r = E(n);
138
- return z(() => {
139
- r.current = n;
140
- }, [n]), { getPixelsForText: A, updateTextTargets: (l, x, D) => {
141
- var S, X;
142
- const u = x || ((S = e.current) == null ? void 0 : S.offsetWidth) || window.innerWidth, g = D || ((X = e.current) == null ? void 0 : X.offsetHeight) || window.innerHeight;
143
- if (!l) {
144
- t.current.forEach((o) => {
145
- const M = 50 + Math.random() * (u - 100), b = 50 + Math.random() * (g - 100);
146
- (Math.abs(M - o.x) > 20 || Math.abs(b - o.y) > 20) && (o.vx += (Math.random() - 0.5) * 20, o.vy += (Math.random() - 0.5) * 20), o.targetX = M, o.targetY = b;
610
+ function lt(t, e, n) {
611
+ const i = I(t);
612
+ return L(() => {
613
+ i.current = t;
614
+ }, [t]), { getPixelsForText: j, updateTextTargets: (m, r, o) => {
615
+ var q, b;
616
+ const h = r || ((q = n.current) == null ? void 0 : q.offsetWidth) || window.innerWidth, y = o || ((b = n.current) == null ? void 0 : b.offsetHeight) || window.innerHeight;
617
+ if (!m) {
618
+ e.current.forEach((f) => {
619
+ const p = 50 + Math.random() * (h - 100), R = 50 + Math.random() * (y - 100);
620
+ (Math.abs(p - f.x) > 20 || Math.abs(R - f.y) > 20) && (f.vx += (Math.random() - 0.5) * 20, f.vy += (Math.random() - 0.5) * 20), f.targetX = p, f.targetY = R;
147
621
  });
148
622
  return;
149
623
  }
150
- const h = A(l, u, g);
151
- if (h.length === 0) return;
152
- const i = u * 0.15, d = h.map((s) => ({ pt: s, key: s.x + (Math.random() - 0.5) * i }));
153
- d.sort((s, o) => s.key - o.key);
154
- const f = d.map((s) => s.pt), p = t.current.map((s, o) => ({ i: o, key: s.x + (Math.random() - 0.5) * i }));
155
- p.sort((s, o) => s.key - o.key);
156
- const P = p.map((s) => s.i), v = Math.ceil(Math.sqrt(P.length));
157
- for (let s = 0; s < P.length; s += v) {
158
- const o = Math.min(s + v, P.length), M = P.slice(s, o), b = [];
159
- for (let c = s; c < o; c++)
160
- b.push(f[c % f.length]);
161
- M.sort((c, w) => t.current[c].y - t.current[w].y), b.sort((c, w) => c.y - w.y);
162
- for (let c = 0; c < M.length; c++) {
163
- const w = M[c], m = t.current[w], R = b[c], T = R.x - m.x, C = R.y - m.y;
164
- if (Math.abs(T) > 20 || Math.abs(C) > 20) {
165
- m.vx += (Math.random() - 0.5) * 20, m.vy += (Math.random() - 0.5) * 20;
166
- const I = (Math.random() > 0.5 ? 1 : -1) * (Math.random() * 10 + 5);
167
- m.vx += Math.sign(C) * I, m.vy -= Math.sign(T) * I;
624
+ const d = j(m, h, y);
625
+ if (d.length === 0) return;
626
+ const c = h * 0.15, a = d.map((C) => ({ pt: C, key: C.x + (Math.random() - 0.5) * c }));
627
+ a.sort((C, f) => C.key - f.key);
628
+ const l = a.map((C) => C.pt), u = e.current.map((C, f) => ({ i: f, key: C.x + (Math.random() - 0.5) * c }));
629
+ u.sort((C, f) => C.key - f.key);
630
+ const w = u.map((C) => C.i), P = Math.ceil(Math.sqrt(w.length));
631
+ for (let C = 0; C < w.length; C += P) {
632
+ const f = Math.min(C + P, w.length), p = w.slice(C, f), R = [];
633
+ for (let S = C; S < f; S++)
634
+ R.push(l[S % l.length]);
635
+ p.sort((S, D) => e.current[S].y - e.current[D].y), R.sort((S, D) => S.y - D.y);
636
+ for (let S = 0; S < p.length; S++) {
637
+ const D = p[S], z = e.current[D], v = R[S], X = v.x - z.x, M = v.y - z.y;
638
+ if (Math.abs(X) > 20 || Math.abs(M) > 20) {
639
+ z.vx += (Math.random() - 0.5) * 20, z.vy += (Math.random() - 0.5) * 20;
640
+ const x = (Math.random() > 0.5 ? 1 : -1) * (Math.random() * 10 + 5);
641
+ z.vx += Math.sign(M) * x, z.vy -= Math.sign(X) * x;
168
642
  }
169
- m.targetX = R.x, m.targetY = R.y;
643
+ z.targetX = v.x, z.targetY = v.y;
170
644
  }
171
645
  }
172
- }, textRef: r };
646
+ }, textRef: i };
173
647
  }
174
- const N = (n) => {
175
- if (!n || typeof n != "string") return "0, 0, 0";
648
+ const k = (t) => {
649
+ if (!t || typeof t != "string") return "0, 0, 0";
176
650
  try {
177
- let t = 0, e = 0, r = 0;
178
- return n.length === 4 ? (t = parseInt(n[1] + n[1], 16), e = parseInt(n[2] + n[2], 16), r = parseInt(n[3] + n[3], 16)) : n.length === 7 && (t = parseInt(n.substring(1, 3), 16), e = parseInt(n.substring(3, 5), 16), r = parseInt(n.substring(5, 7), 16)), `${t}, ${e}, ${r}`;
651
+ let e = 0, n = 0, i = 0;
652
+ if (t.length === 4)
653
+ e = parseInt(t[1] + t[1], 16), n = parseInt(t[2] + t[2], 16), i = parseInt(t[3] + t[3], 16);
654
+ else if (t.length === 7)
655
+ e = parseInt(t.substring(1, 3), 16), n = parseInt(t.substring(3, 5), 16), i = parseInt(t.substring(5, 7), 16);
656
+ else
657
+ return t;
658
+ return `${e}, ${n}, ${i}`;
179
659
  } catch {
180
660
  return "0, 0, 0";
181
661
  }
182
662
  };
183
- function tt({
184
- text: n,
185
- particleColor: t = "255, 255, 255",
186
- particleSize: e = 1,
187
- particleDensity: r = 1,
188
- particleEase: a = 1,
189
- isMagnet: l = !0,
190
- clickMode: x = "none",
191
- particleShape: D = "circle",
192
- backgroundColor: u = "#050505"
663
+ function yt({
664
+ text: t,
665
+ particleColor: e = "255, 255, 255",
666
+ particleSize: n = 1,
667
+ particleDensity: i = 1,
668
+ particleEase: s = 1,
669
+ isMagnet: m = !0,
670
+ clickMode: r = "none",
671
+ particleShape: o = "circle",
672
+ backgroundColor: h = "#050505"
193
673
  }) {
194
- const g = E(null), h = E(null), i = E([]), d = E(0), f = E(0), p = K(h), P = E({ isMagnet: l, clickMode: x, particleShape: D, backgroundColor: u });
195
- P.current = { isMagnet: l, clickMode: x, particleShape: D, backgroundColor: u };
196
- const { updateTextTargets: v, textRef: S } = J(n, i, h), X = (s, o, M = 1) => {
197
- const b = window.innerWidth < 600 ? 1500 : 3e3, c = Math.floor(b * M), w = [];
198
- for (let m = 0; m < c; m++) {
199
- const R = new O(s, o, t);
200
- R.sizeMultiplier = e, R.easeMultiplier = a, w.push(R);
674
+ const y = I(null), d = I(null), c = I([]), a = I(0), l = I(0), u = ct(d), w = I({ isMagnet: m, clickMode: r, particleShape: o, backgroundColor: h });
675
+ w.current = { isMagnet: m, clickMode: r, particleShape: o, backgroundColor: h };
676
+ const { updateTextTargets: P, textRef: q } = lt(
677
+ t,
678
+ c,
679
+ d
680
+ ), b = () => Array.isArray(e) ? e.map((f) => k(f)) : k(e), C = (f, p, R = 1) => {
681
+ const S = window.innerWidth < 600 ? 1500 : 3e3, D = Math.floor(S * R), z = [], v = b();
682
+ for (let X = 0; X < D; X++) {
683
+ const M = new H(f, p, v);
684
+ M.sizeMultiplier = n, M.easeMultiplier = s, z.push(M);
201
685
  }
202
- i.current = w;
686
+ c.current = z;
203
687
  };
204
- return z(() => {
205
- i.current.length > 0 && i.current.forEach((s) => {
206
- s.baseColor = Array.isArray(t) ? t[Math.floor(Math.random() * t.length)] : t;
207
- });
208
- }, [t]), z(() => {
209
- i.current.length > 0 && i.current.forEach((s) => {
210
- s.sizeMultiplier = e;
688
+ return L(() => {
689
+ if (c.current.length > 0) {
690
+ const f = b();
691
+ c.current.forEach((p) => {
692
+ p.baseColor = Array.isArray(f) ? f[Math.floor(Math.random() * f.length)] : f;
693
+ });
694
+ }
695
+ }, [e]), L(() => {
696
+ c.current.length > 0 && c.current.forEach((f) => {
697
+ f.sizeMultiplier = n;
211
698
  });
212
- }, [e]), z(() => {
213
- i.current.length > 0 && i.current.forEach((s) => {
214
- s.easeMultiplier = a;
699
+ }, [n]), L(() => {
700
+ c.current.length > 0 && c.current.forEach((f) => {
701
+ f.easeMultiplier = s;
215
702
  });
216
- }, [a]), z(() => {
217
- if (i.current.length > 0 && g.current && h.current) {
218
- const s = window.innerWidth < 600 ? 1500 : 3e3, o = Math.floor(s * r), M = i.current.length;
219
- if (o > M) {
220
- const b = h.current.getBoundingClientRect();
221
- for (let c = 0; c < o - M; c++) {
222
- const w = new O(b.width, b.height, t);
223
- w.sizeMultiplier = e, i.current.push(w);
703
+ }, [s]), L(() => {
704
+ if (c.current.length > 0 && y.current && d.current) {
705
+ const f = window.innerWidth < 600 ? 1500 : 3e3, p = Math.floor(f * i), R = c.current.length;
706
+ if (p > R) {
707
+ const S = d.current.getBoundingClientRect(), D = b();
708
+ for (let z = 0; z < p - R; z++) {
709
+ const v = new H(S.width, S.height, D);
710
+ v.sizeMultiplier = n, c.current.push(v);
224
711
  }
225
- v(n);
226
- } else o < M && i.current.splice(o);
712
+ P(t);
713
+ } else p < R && c.current.splice(p);
227
714
  }
228
- }, [r]), z(() => {
229
- const s = h.current, o = g.current;
230
- if (!s || !o) return;
231
- const M = (m) => {
232
- for (const R of m) {
233
- const { width: T, height: C } = R.contentRect, I = window.devicePixelRatio || 1;
234
- o.width = T * I, o.height = C * I, o.style.width = `${T}px`, o.style.height = `${C}px`;
235
- const Y = o.getContext("2d");
236
- Y && Y.scale(I, I), i.current.length === 0 && X(T, C, r), v(n, T, C);
715
+ }, [i]), L(() => {
716
+ const f = d.current, p = y.current;
717
+ if (!f || !p) return;
718
+ const R = (v) => {
719
+ for (const X of v) {
720
+ const { width: M, height: x } = X.contentRect, Y = window.devicePixelRatio || 1;
721
+ p.width = M * Y, p.height = x * Y, p.style.width = `${M}px`, p.style.height = `${x}px`;
722
+ const E = p.getContext("2d");
723
+ E && E.scale(Y, Y), c.current.length === 0 && C(M, x, i), P(t, M, x);
724
+ }
725
+ }, S = new ResizeObserver(R);
726
+ S.observe(f);
727
+ const D = p.getContext("2d"), z = () => {
728
+ l.current++;
729
+ const v = f.getBoundingClientRect(), { isMagnet: X, clickMode: M, particleShape: x, backgroundColor: Y } = w.current;
730
+ if (Y === "transparent")
731
+ D.clearRect(0, 0, v.width, v.height), D.globalCompositeOperation = "source-over";
732
+ else {
733
+ const A = k(Y);
734
+ D.fillStyle = `rgba(${A}, 0.25)`, D.fillRect(0, 0, v.width, v.height), D.globalCompositeOperation = "screen";
237
735
  }
238
- }, b = new ResizeObserver(M);
239
- b.observe(s);
240
- const c = o.getContext("2d"), w = () => {
241
- f.current++;
242
- const m = s.getBoundingClientRect(), { isMagnet: R, clickMode: T, particleShape: C, backgroundColor: I } = P.current, Y = N(I);
243
- c.fillStyle = `rgba(${Y}, 0.25)`, c.fillRect(0, 0, m.width, m.height), c.globalCompositeOperation = "screen";
244
- const W = S.current !== "", q = p.current.active ? p.current.x : null, B = p.current.active ? p.current.y : null, F = p.current.isDown;
245
- for (let $ = 0; $ < i.current.length; $++) {
246
- const k = i.current[$];
247
- k.update(f.current, !!W, q, B, F, R, T), k.draw(c, C);
736
+ const E = q.current !== "", T = u.current.active ? u.current.x : null, F = u.current.active ? u.current.y : null, W = u.current.isDown;
737
+ for (let A = 0; A < c.current.length; A++) {
738
+ const O = c.current[A];
739
+ O.update(l.current, !!E, T, F, W, X, M), O.draw(D, x, l.current);
248
740
  }
249
- c.globalCompositeOperation = "source-over", d.current = requestAnimationFrame(w);
741
+ D.globalCompositeOperation = "source-over", a.current = requestAnimationFrame(z);
250
742
  };
251
- return w(), () => {
252
- b.disconnect(), cancelAnimationFrame(d.current);
743
+ return z(), () => {
744
+ S.disconnect(), cancelAnimationFrame(a.current);
253
745
  };
254
- }, []), z(() => {
255
- v(n);
256
- }, [n]), /* @__PURE__ */ L(
746
+ }, []), L(() => {
747
+ P(t);
748
+ }, [t]), /* @__PURE__ */ $(
257
749
  "div",
258
750
  {
259
- ref: h,
751
+ ref: d,
260
752
  style: { position: "absolute", inset: 0, zIndex: 0, overflow: "hidden" },
261
- children: /* @__PURE__ */ L(
753
+ children: /* @__PURE__ */ $(
262
754
  "canvas",
263
755
  {
264
- ref: g,
756
+ ref: y,
265
757
  style: { display: "block", width: "100%", height: "100%" }
266
758
  }
267
759
  )
@@ -269,9 +761,9 @@ function tt({
269
761
  );
270
762
  }
271
763
  export {
272
- _ as ParticleCanvas,
273
- tt as TextParticleEngine,
274
- U as getMagnetTarget,
275
- K as useParticleInteraction,
276
- J as useTextParticles
764
+ ft as ParticleCanvas,
765
+ yt as TextParticleEngine,
766
+ at as getMagnetTarget,
767
+ ct as useParticleInteraction,
768
+ lt as useTextParticles
277
769
  };