cos-design 2.1.0 → 2.4.0

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.
package/dist/index.js CHANGED
@@ -1,428 +1,852 @@
1
- import { jsx as o, jsxs as N } from "react/jsx-runtime";
2
- import { useRef as P, useCallback as X, useEffect as w, useState as $ } from "react";
3
- import './index.css';const et = "cos-canvasClock", nt = "cos-canvasTarget", G = {
4
- canvasClock: et,
5
- canvasTarget: nt
6
- }, Gt = ({ width: e = 400, height: s = 400 }) => {
7
- const d = P(null), l = Math.min(e, s), r = l / 2 - 16, m = l / 2, y = X(
8
- (t) => {
9
- t.clearRect(0, 0, l, l), t.save(), t.translate(m, m), t.beginPath(), t.arc(0, 0, r, 0, Math.PI * 2), t.fillStyle = "#fff", t.fill(), t.strokeStyle = "#d1d5db", t.lineWidth = 2, t.stroke();
10
- for (let x = 0; x < 60; x++) {
11
- const i = x / 60 * Math.PI * 2, h = r - (x % 5 === 0 ? 14 : 8);
12
- t.beginPath(), t.moveTo(Math.cos(i) * h, Math.sin(i) * h), t.lineTo(Math.cos(i) * r, Math.sin(i) * r), t.strokeStyle = x % 5 === 0 ? "#374151" : "#9ca3af", t.lineWidth = x % 5 === 0 ? 2 : 1, t.stroke();
13
- }
14
- t.fillStyle = "#111827", t.font = `bold ${Math.floor(l / 22)}px system-ui, sans-serif`, t.textAlign = "center", t.textBaseline = "middle";
15
- for (let x = 1; x <= 12; x++) {
16
- const i = x / 12 * Math.PI * 2 - Math.PI / 2, h = r - 32;
17
- t.fillText(String(x), Math.cos(i) * h, Math.sin(i) * h);
18
- }
19
- const c = /* @__PURE__ */ new Date(), g = c.getHours() % 12, f = c.getMinutes(), v = c.getSeconds(), M = c.getMilliseconds(), a = (x, i, h, p, n) => {
20
- t.save(), t.rotate(x), t.beginPath(), t.moveTo(0, h), t.lineTo(i, 0), t.lineTo(0, -h), t.closePath(), t.fillStyle = p, t.shadowColor = n, t.shadowBlur = 4, t.fill(), t.restore();
21
- }, u = (g + f / 60) / 12 * Math.PI * 2 - Math.PI / 2, T = (f + v / 60) / 60 * Math.PI * 2 - Math.PI / 2, b = (v + M / 1e3) / 60 * Math.PI * 2 - Math.PI / 2;
22
- a(u, r * 0.5, 4, "#111827", "rgb(0 0 0 / 40%)"), a(T, r * 0.72, 3, "#1e80ff", "rgb(30 128 255 / 40%)"), a(b, r * 0.85, 2, "#e9686b", "rgb(233 104 107 / 40%)"), t.beginPath(), t.arc(0, 0, 5, 0, Math.PI * 2), t.fillStyle = "#111827", t.fill(), t.restore();
23
- },
24
- [m, r, l]
25
- );
26
- return w(() => {
27
- const t = d.current;
28
- if (!t) return;
29
- const c = window.devicePixelRatio || 1;
30
- t.width = l * c, t.height = l * c;
31
- const g = t.getContext("2d");
32
- if (!g) return;
33
- g.setTransform(c, 0, 0, c, 0, 0);
34
- let f = 0;
35
- const v = () => {
36
- y(g), f = requestAnimationFrame(v);
37
- };
38
- return v(), () => cancelAnimationFrame(f);
39
- }, [y, l]), /* @__PURE__ */ o("div", { className: G.canvasClock, style: { width: l, height: l }, children: /* @__PURE__ */ o("canvas", { ref: d, className: G.canvasTarget, style: { width: l, height: l } }) });
40
- }, st = "cos-chargeContainer", at = "cos-contrast", ot = "cos-text", rt = "cos-circle", ct = "cos-button", E = {
41
- chargeContainer: st,
42
- contrast: at,
43
- text: ot,
44
- circle: rt,
45
- button: ct
46
- }, Jt = (e) => {
47
- const { initQuantity: s = 0 } = e, [d, l] = $(s);
48
- return w(() => {
49
- let r = d;
50
- setInterval(() => {
51
- r = Number(Number(r += 0.01).toFixed(2)), l(r);
52
- }, 500);
53
- }, []), /* @__PURE__ */ o("div", { className: E.chargeContainer, children: /* @__PURE__ */ N("div", { className: E.contrast, children: [
54
- /* @__PURE__ */ N("div", { className: E.text, children: [
55
- d ? d.toString().padEnd(4, "0") : 0,
56
- "%"
57
- ] }),
58
- /* @__PURE__ */ o("span", {}),
59
- /* @__PURE__ */ o("span", {}),
60
- /* @__PURE__ */ o("span", {}),
61
- /* @__PURE__ */ o("span", {}),
62
- /* @__PURE__ */ o("span", {}),
63
- /* @__PURE__ */ o("span", {}),
64
- /* @__PURE__ */ o("span", {}),
65
- /* @__PURE__ */ o("span", {}),
66
- /* @__PURE__ */ o("span", {}),
67
- /* @__PURE__ */ o("span", {}),
68
- /* @__PURE__ */ o("span", {}),
69
- /* @__PURE__ */ o("span", {}),
70
- /* @__PURE__ */ o("span", {}),
71
- /* @__PURE__ */ o("span", {}),
72
- /* @__PURE__ */ o("span", {}),
73
- /* @__PURE__ */ o("div", { className: E.circle }),
74
- /* @__PURE__ */ o("div", { className: E.button })
75
- ] }) });
76
- }, lt = "cos-fireworks", it = "cos-canvas", dt = "cos-hint", Q = {
77
- fireworks: lt,
78
- canvas: it,
79
- hint: dt
80
- }, J = ["#ff6b6b", "#ffd93d", "#6bcb77", "#4d96ff", "#a66cff", "#ff85c0"], z = () => J[Math.floor(Math.random() * J.length)], ft = (e, s, d) => {
81
- const l = 60 + Math.floor(Math.random() * 30);
82
- return Array.from({ length: l }, () => {
83
- const r = Math.random() * Math.PI * 2, m = Math.random() * 4 + 2;
84
- return {
85
- x: e,
86
- y: s,
87
- vx: Math.cos(r) * m,
88
- vy: Math.sin(r) * m,
89
- alpha: 1,
90
- color: Math.random() > 0.3 ? d : z(),
91
- decay: Math.random() * 0.015 + 0.01
92
- };
93
- });
94
- }, Kt = ({ width: e = 800, height: s = 500, auto: d = !0 }) => {
95
- const l = P(null), r = P([]), m = P(0), y = X(
96
- (c) => {
97
- const g = c ?? Math.random() * e * 0.6 + e * 0.2;
98
- r.current.push({
99
- x: g,
100
- y: s,
101
- vy: -(Math.random() * 4 + 6),
102
- targetY: Math.random() * s * 0.4 + s * 0.1,
103
- color: z(),
104
- exploded: !1,
105
- particles: []
106
- });
107
- },
108
- [s, e]
109
- );
110
- w(() => {
111
- const c = l.current;
112
- if (!c) return;
113
- const g = window.devicePixelRatio || 1;
114
- c.width = e * g, c.height = s * g;
115
- const f = c.getContext("2d");
116
- if (!f) return;
117
- f.setTransform(g, 0, 0, g, 0, 0);
118
- let v = 0;
119
- const M = () => {
120
- m.current = requestAnimationFrame(M), f.fillStyle = "rgb(15 23 42 / 25%)", f.fillRect(0, 0, e, s), d && Math.random() < 0.03 && y(), r.current = r.current.filter((a) => a.exploded ? (a.particles = a.particles.filter((u) => (u.x += u.vx, u.y += u.vy, u.vy += 0.06, u.alpha -= u.decay, u.alpha <= 0 ? !1 : (f.beginPath(), f.arc(u.x, u.y, 2, 0, Math.PI * 2), f.fillStyle = u.color, f.globalAlpha = u.alpha, f.fill(), f.globalAlpha = 1, !0))), a.particles.length > 0) : (a.y += a.vy, a.vy *= 0.98, f.beginPath(), f.arc(a.x, a.y, 2.5, 0, Math.PI * 2), f.fillStyle = a.color, f.fill(), (a.vy >= 0 || a.y <= a.targetY) && (a.exploded = !0, a.particles = ft(a.x, a.y, a.color)), !0));
121
- };
122
- return M(), d && (v = window.setInterval(() => y(), 1200)), () => {
123
- cancelAnimationFrame(m.current), clearInterval(v);
124
- };
125
- }, [d, s, y, e]);
126
- const t = (c) => {
127
- const g = c.currentTarget.getBoundingClientRect();
128
- y(c.clientX - g.left);
129
- };
130
- return /* @__PURE__ */ N("div", { className: Q.fireworks, style: { width: e, height: s }, children: [
131
- /* @__PURE__ */ o("canvas", { ref: l, className: Q.canvas, style: { width: e, height: s }, onClick: t }),
132
- /* @__PURE__ */ o("p", { className: Q.hint, children: "点击画布燃放烟花" })
133
- ] });
134
- }, ut = "cos-matrixRain", mt = "cos-canvas", ht = "cos-overlay", yt = "cos-title", vt = "cos-subtitle", q = {
135
- matrixRain: ut,
136
- canvas: mt,
137
- overlay: ht,
138
- title: yt,
139
- subtitle: vt
140
- }, K = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*アイウエオカキクケコ", Vt = ({ width: e = 800, height: s = 500, density: d = 0.6, color: l = "#00ff41" }) => {
141
- const r = P(null);
142
- return w(() => {
143
- const m = r.current;
144
- if (!m) return;
145
- const y = window.devicePixelRatio || 1;
146
- m.width = e * y, m.height = s * y;
147
- const t = m.getContext("2d");
148
- if (!t) return;
149
- t.setTransform(y, 0, 0, y, 0, 0);
150
- const c = 16, g = Math.floor(e / c * d), f = Array.from({ length: g }, () => Math.random() * -50);
151
- let v = 0;
152
- const M = () => {
153
- t.fillStyle = "rgb(0 0 0 / 8%)", t.fillRect(0, 0, e, s), t.fillStyle = l, t.font = `${c}px monospace`, f.forEach((a, u) => {
154
- const T = K[Math.floor(Math.random() * K.length)], b = u / d * c;
155
- t.fillStyle = l, t.fillText(T, b, a * c), a * c > s && Math.random() > 0.975 && (f[u] = 0), f[u] += 1;
156
- }), v = requestAnimationFrame(M);
157
- };
158
- return M(), () => cancelAnimationFrame(v);
159
- }, [l, d, s, e]), /* @__PURE__ */ N("div", { className: q.matrixRain, style: { width: e, height: s }, children: [
160
- /* @__PURE__ */ o("canvas", { ref: r, className: q.canvas, style: { width: e, height: s } }),
161
- /* @__PURE__ */ N("div", { className: q.overlay, children: [
162
- /* @__PURE__ */ o("h2", { className: q.title, children: "MATRIX" }),
163
- /* @__PURE__ */ o("p", { className: q.subtitle, children: "数字雨效果" })
164
- ] })
165
- ] });
166
- }, gt = "cos-neonText", pt = "cos-text", Mt = "cos-flicker", bt = "cos-reflection", O = {
167
- neonText: gt,
168
- text: pt,
169
- flicker: Mt,
170
- reflection: bt
171
- }, zt = ({ text: e = "NEON", color: s = "#ff00de", fontSize: d = 72, flicker: l = !0 }) => /* @__PURE__ */ N("div", { className: O.neonText, children: [
172
- /* @__PURE__ */ o(
173
- "h1",
174
- {
175
- className: `${O.text} ${l ? O.flicker : ""}`,
176
- style: {
177
- fontSize: d,
178
- "--neon-color": s
179
- },
180
- children: e
181
- }
182
- ),
183
- /* @__PURE__ */ o("p", { className: O.reflection, style: { fontSize: d * 0.35, color: s }, children: e })
184
- ] }), xt = "cos-particleNetwork", Nt = "cos-canvas", Ct = "cos-hint", U = {
185
- particleNetwork: xt,
186
- canvas: Nt,
187
- hint: Ct
188
- }, te = ({
189
- width: e = 800,
190
- height: s = 500,
191
- particleCount: d = 60,
192
- linkDistance: l = 120,
193
- color: r = "#38bdf8"
194
- }) => {
195
- const m = P(null), y = P([]), t = P({ x: -1e3, y: -1e3 }), c = X(() => {
196
- y.current = Array.from({ length: d }, () => ({
197
- x: Math.random() * e,
198
- y: Math.random() * s,
199
- vx: (Math.random() - 0.5) * 1.2,
200
- vy: (Math.random() - 0.5) * 1.2,
201
- radius: Math.random() * 2 + 1
202
- }));
203
- }, [s, d, e]);
204
- w(() => {
205
- c();
206
- }, [c]), w(() => {
207
- const v = m.current;
208
- if (!v) return;
209
- const M = window.devicePixelRatio || 1;
210
- v.width = e * M, v.height = s * M;
211
- const a = v.getContext("2d");
212
- if (!a) return;
213
- a.setTransform(M, 0, 0, M, 0, 0);
214
- let u = 0;
215
- const T = () => {
216
- a.fillStyle = "#0f172a", a.fillRect(0, 0, e, s);
217
- const b = y.current, x = t.current;
218
- b.forEach((i) => {
219
- i.x += i.vx, i.y += i.vy, (i.x < 0 || i.x > e) && (i.vx *= -1), (i.y < 0 || i.y > s) && (i.vy *= -1);
220
- const h = x.x - i.x, p = x.y - i.y;
221
- Math.sqrt(h * h + p * p) < 150 && (i.vx -= h * 3e-4, i.vy -= p * 3e-4);
222
- });
223
- for (let i = 0; i < b.length; i++)
224
- for (let h = i + 1; h < b.length; h++) {
225
- const p = b[i].x - b[h].x, n = b[i].y - b[h].y, C = Math.sqrt(p * p + n * n);
226
- C < l && (a.beginPath(), a.moveTo(b[i].x, b[i].y), a.lineTo(b[h].x, b[h].y), a.strokeStyle = r, a.globalAlpha = 1 - C / l, a.lineWidth = 0.8, a.stroke(), a.globalAlpha = 1);
227
- }
228
- b.forEach((i) => {
229
- a.beginPath(), a.arc(i.x, i.y, i.radius, 0, Math.PI * 2), a.fillStyle = r, a.fill();
230
- }), u = requestAnimationFrame(T);
231
- };
232
- return T(), () => cancelAnimationFrame(u);
233
- }, [r, s, c, l, e]);
234
- const g = (v) => {
235
- const M = v.currentTarget.getBoundingClientRect();
236
- t.current = { x: v.clientX - M.left, y: v.clientY - M.top };
237
- }, f = () => {
238
- t.current = { x: -1e3, y: -1e3 };
239
- };
240
- return /* @__PURE__ */ N("div", { className: U.particleNetwork, style: { width: e, height: s }, children: [
241
- /* @__PURE__ */ o(
242
- "canvas",
243
- {
244
- ref: m,
245
- className: U.canvas,
246
- style: { width: e, height: s },
247
- onMouseMove: g,
248
- onMouseLeave: f
249
- }
250
- ),
251
- /* @__PURE__ */ o("p", { className: U.hint, children: "移动鼠标与粒子互动" })
252
- ] });
253
- }, Pt = "cos-returnCityContainer", It = "cos-star", wt = "cos-glassWrap", Tt = "cos-glassItem", H = {
254
- returnCityContainer: Pt,
255
- star: It,
256
- glassWrap: wt,
257
- glassItem: Tt
258
- }, ee = () => {
259
- const e = (d, l) => {
260
- for (let r = 0; r < l; r++)
261
- setTimeout(function() {
262
- const m = document.createElement("div");
263
- m.className = H.star;
264
- const y = document.body.clientWidth, t = document.body.clientHeight, c = Math.random() * y + "px", g = Math.random() * t + "px";
265
- m.style.top = g, m.style.left = c, d.append(m);
266
- }, Math.random() * 2e3);
267
- }, s = () => {
268
- const l = "150px", r = document.getElementById("glassWrap");
269
- if (r)
270
- for (let m = 0; m < 6; m++) {
271
- const y = document.createElement("div");
272
- y.className = H.glassItem, y.style.transform = `rotateY(${m * 60}deg) translateZ(${l})`, r.appendChild(y), setTimeout(() => {
273
- y.style.top = "0px", y.style.opacity = "1";
274
- }, m * 300);
275
- }
276
- };
277
- return w(() => {
278
- const d = document.getElementById("returnCityContainer");
279
- d && e(d, document.documentElement.clientWidth / 20), s();
280
- }, []), /* @__PURE__ */ o("div", { id: "returnCityContainer", className: H.returnCityContainer, children: /* @__PURE__ */ o("div", { id: "glassWrap", className: H.glassWrap }) });
281
- }, Rt = "cos-turntable", At = "cos-wheelWrap", St = "cos-canvas", Ft = "cos-pointer", Bt = "cos-spinBtn", $t = "cos-result", F = {
282
- turntable: Rt,
283
- wheelWrap: At,
284
- canvas: St,
285
- pointer: Ft,
286
- spinBtn: Bt,
287
- result: $t
288
- }, V = ["#FF6B6B", "#4ECDC4", "#FFE66D", "#A78BFA", "#60A5FA", "#F472B6", "#34D399", "#FB923C"], Wt = [
289
- { label: "一等奖" },
290
- { label: "二等奖" },
291
- { label: "三等奖" },
292
- { label: "谢谢参与" },
293
- { label: "优惠券" },
294
- { label: "再来一次" }
295
- ], kt = (e) => 1 - Math.pow(1 - e, 3), ne = ({
296
- prizes: e = Wt,
297
- size: s = 360,
298
- spinDuration: d = 4e3,
299
- spinRounds: l = 5,
300
- buttonText: r = "开始抽奖",
301
- onSpinEnd: m
302
- }) => {
303
- const y = P(null), t = P(0), c = P(0), g = P(1), [f, v] = $(!1), [M, a] = $(null), u = s + 48, T = (h, p) => p.color ?? V[h % V.length], b = X(
304
- (h) => {
305
- const p = y.current;
306
- if (!p) return;
307
- const n = p.getContext("2d");
308
- if (!n) return;
309
- const C = u / 2, R = s / 2, W = Math.PI * 2 / e.length;
310
- n.clearRect(0, 0, u, u), n.save(), n.translate(C, C), n.rotate(h), e.forEach((I, S) => {
311
- const A = S * W - Math.PI / 2, k = A + W, Y = T(S, I);
312
- n.beginPath(), n.moveTo(0, 0), n.arc(0, 0, R, A, k), n.closePath(), n.fillStyle = Y, n.fill(), n.strokeStyle = "rgb(255 255 255 / 35%)", n.lineWidth = 2, n.stroke(), n.save(), n.rotate(A + W / 2), n.textAlign = "right", n.fillStyle = "#fff", n.font = `bold ${Math.max(12, Math.floor(s / 22))}px system-ui, sans-serif`, n.shadowColor = "rgb(0 0 0 / 30%)", n.shadowBlur = 4, n.fillText(I.label, R - 18, 6), n.restore();
313
- }), n.beginPath(), n.arc(0, 0, R, 0, Math.PI * 2), n.strokeStyle = "#fbbf24", n.lineWidth = 6, n.stroke(), n.beginPath(), n.arc(0, 0, R - 4, 0, Math.PI * 2), n.strokeStyle = "#f59e0b", n.lineWidth = 2, n.stroke(), n.restore(), n.save(), n.translate(C, C);
314
- for (let I = 0; I < 12; I++) {
315
- const S = I / 12 * Math.PI * 2, A = Math.cos(S) * (R + 14), k = Math.sin(S) * (R + 14);
316
- n.beginPath(), n.arc(A, k, 3, 0, Math.PI * 2), n.fillStyle = I % 2 === 0 ? "#fde68a" : "#f59e0b", n.fill();
317
- }
318
- n.restore();
319
- },
320
- [u, e, s]
321
- );
322
- w(() => {
323
- const h = y.current;
324
- if (!h) return;
325
- const p = window.devicePixelRatio || 1;
326
- g.current = p, h.width = u * p, h.height = u * p;
327
- const n = h.getContext("2d");
328
- n && n.setTransform(p, 0, 0, p, 0, 0), b(t.current);
329
- }, [u, b]), w(() => () => {
330
- c.current && cancelAnimationFrame(c.current);
331
- }, []);
332
- const x = (h) => {
333
- const p = 360 / e.length, n = (h * (180 / Math.PI) % 360 + 360) % 360;
334
- return Math.floor((360 - n + p / 2) % 360 / p) % e.length;
335
- }, i = () => {
336
- if (f || e.length === 0) return;
337
- v(!0), a(null);
338
- const h = Math.PI * 2 / e.length, n = Math.floor(Math.random() * e.length) * h + h / 2, C = t.current, R = l * Math.PI * 2, W = C + R + (Math.PI * 2 - n) - C % (Math.PI * 2), I = C, S = performance.now(), A = (k) => {
339
- const Y = k - S, j = Math.min(Y / d, 1), tt = kt(j), L = I + (W - I) * tt;
340
- if (t.current = L, b(L), j < 1)
341
- c.current = requestAnimationFrame(A);
342
- else {
343
- const Z = x(L), _ = e[Z];
344
- t.current = L, v(!1), a(_), m == null || m(_, Z);
345
- }
346
- };
347
- c.current = requestAnimationFrame(A);
348
- };
349
- return /* @__PURE__ */ N("div", { className: F.turntable, style: { width: u, height: u + 80 }, children: [
350
- /* @__PURE__ */ N("div", { className: F.wheelWrap, style: { width: u, height: u }, children: [
351
- /* @__PURE__ */ o("div", { className: F.pointer }),
352
- /* @__PURE__ */ o("canvas", { ref: y, className: F.canvas, style: { width: u, height: u } }),
353
- /* @__PURE__ */ o("button", { type: "button", className: F.spinBtn, onClick: i, disabled: f, children: f ? "抽奖中..." : r })
354
- ] }),
355
- M && !f && /* @__PURE__ */ N("p", { className: F.result, children: [
356
- "恭喜获得:",
357
- /* @__PURE__ */ o("strong", { children: M.label })
358
- ] })
359
- ] });
360
- }, Et = "cos-typewriter", qt = "cos-terminal", Dt = "cos-dots", Lt = "cos-text", Ot = "cos-prompt", Ht = "cos-cursor", B = {
361
- typewriter: Et,
362
- terminal: qt,
363
- dots: Dt,
364
- text: Lt,
365
- prompt: Ot,
366
- cursor: Ht
367
- }, Xt = ["Hello, cos-design!", "欢迎来到组件库 ✨", "Build something fun 🚀"], se = ({
368
- texts: e = Xt,
369
- speed: s = 100,
370
- deleteSpeed: d = 50,
371
- pause: l = 2e3
372
- }) => {
373
- const [r, m] = $(""), [y, t] = $(0), [c, g] = $(!1);
374
- return w(() => {
375
- const f = e[y % e.length];
376
- let v;
377
- if (!c && r === f)
378
- v = setTimeout(() => g(!0), l);
379
- else if (c && r === "")
380
- g(!1), t((M) => (M + 1) % e.length);
381
- else {
382
- const M = c ? f.slice(0, r.length - 1) : f.slice(0, r.length + 1);
383
- v = setTimeout(() => m(M), c ? d : s);
384
- }
385
- return () => clearTimeout(v);
386
- }, [r, c, y, e, s, d, l]), /* @__PURE__ */ o("div", { className: B.typewriter, children: /* @__PURE__ */ N("div", { className: B.terminal, children: [
387
- /* @__PURE__ */ N("div", { className: B.dots, children: [
388
- /* @__PURE__ */ o("span", {}),
389
- /* @__PURE__ */ o("span", {}),
390
- /* @__PURE__ */ o("span", {})
391
- ] }),
392
- /* @__PURE__ */ N("p", { className: B.text, children: [
393
- /* @__PURE__ */ o("span", { className: B.prompt, children: ">" }),
394
- r,
395
- /* @__PURE__ */ o("span", { className: B.cursor, children: "|" })
396
- ] })
397
- ] }) });
398
- }, Yt = "cos-waveButton", Qt = "cos-btn", Ut = "cos-label", jt = "cos-wave", D = {
399
- waveButton: Yt,
400
- btn: Qt,
401
- label: Ut,
402
- wave: jt
403
- }, ae = ({ text: e = "点我试试", onClick: s, color: d = "#38bdf8" }) => /* @__PURE__ */ o("div", { className: D.waveButton, children: /* @__PURE__ */ N(
404
- "button",
405
- {
406
- type: "button",
407
- className: D.btn,
408
- style: { "--wave-color": d },
409
- onClick: s,
410
- children: [
411
- /* @__PURE__ */ o("span", { className: D.wave }),
412
- /* @__PURE__ */ o("span", { className: D.wave }),
413
- /* @__PURE__ */ o("span", { className: D.label, children: e })
414
- ]
415
- }
416
- ) });
417
- export {
418
- Gt as CanvasClock,
419
- Jt as Charge,
420
- Kt as Fireworks,
421
- Vt as MatrixRain,
422
- zt as NeonText,
423
- te as ParticleNetwork,
424
- ee as ReturnCity,
425
- ne as Turntable,
426
- se as Typewriter,
427
- ae as WaveButton
428
- };
1
+ import { forwardRef as e, useCallback as t, useEffect as n, useImperativeHandle as r, useMemo as i, useRef as a, useState as o } from "react";
2
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
3
+ import './index.css';var u = {
4
+ canvasClock: "cos-canvasClock-QvdV3",
5
+ canvasTarget: "cos-canvasTarget-x-odC"
6
+ }, d = ({ width: e = 400, height: r = 400 }) => {
7
+ let i = a(null), o = Math.min(e, r), s = o / 2 - 16, l = o / 2, d = t((e) => {
8
+ e.clearRect(0, 0, o, o), e.save(), e.translate(l, l), e.beginPath(), e.arc(0, 0, s, 0, Math.PI * 2), e.fillStyle = "#fff", e.fill(), e.strokeStyle = "#d1d5db", e.lineWidth = 2, e.stroke();
9
+ for (let t = 0; t < 60; t++) {
10
+ let n = t / 60 * Math.PI * 2, r = s - (t % 5 == 0 ? 14 : 8);
11
+ e.beginPath(), e.moveTo(Math.cos(n) * r, Math.sin(n) * r), e.lineTo(Math.cos(n) * s, Math.sin(n) * s), e.strokeStyle = t % 5 == 0 ? "#374151" : "#9ca3af", e.lineWidth = t % 5 == 0 ? 2 : 1, e.stroke();
12
+ }
13
+ e.fillStyle = "#111827", e.font = `bold ${Math.floor(o / 22)}px system-ui, sans-serif`, e.textAlign = "center", e.textBaseline = "middle";
14
+ for (let t = 1; t <= 12; t++) {
15
+ let n = t / 12 * Math.PI * 2 - Math.PI / 2, r = s - 32;
16
+ e.fillText(String(t), Math.cos(n) * r, Math.sin(n) * r);
17
+ }
18
+ let t = /* @__PURE__ */ new Date(), n = t.getHours() % 12, r = t.getMinutes(), i = t.getSeconds(), a = t.getMilliseconds(), c = (t, n, r, i, a) => {
19
+ e.save(), e.rotate(t), e.beginPath(), e.moveTo(0, r), e.lineTo(n, 0), e.lineTo(0, -r), e.closePath(), e.fillStyle = i, e.shadowColor = a, e.shadowBlur = 4, e.fill(), e.restore();
20
+ }, u = (n + r / 60) / 12 * Math.PI * 2 - Math.PI / 2, d = (r + i / 60) / 60 * Math.PI * 2 - Math.PI / 2, f = (i + a / 1e3) / 60 * Math.PI * 2 - Math.PI / 2;
21
+ c(u, s * .5, 4, "#111827", "rgb(0 0 0 / 40%)"), c(d, s * .72, 3, "#1e80ff", "rgb(30 128 255 / 40%)"), c(f, s * .85, 2, "#e9686b", "rgb(233 104 107 / 40%)"), e.beginPath(), e.arc(0, 0, 5, 0, Math.PI * 2), e.fillStyle = "#111827", e.fill(), e.restore();
22
+ }, [
23
+ l,
24
+ s,
25
+ o
26
+ ]);
27
+ return n(() => {
28
+ let e = i.current;
29
+ if (!e) return;
30
+ let t = window.devicePixelRatio || 1;
31
+ e.width = o * t, e.height = o * t;
32
+ let n = e.getContext("2d");
33
+ if (!n) return;
34
+ n.setTransform(t, 0, 0, t, 0, 0);
35
+ let r = 0, a = () => {
36
+ d(n), r = requestAnimationFrame(a);
37
+ };
38
+ return a(), () => cancelAnimationFrame(r);
39
+ }, [d, o]), /* @__PURE__ */ c("div", {
40
+ className: u.canvasClock,
41
+ style: {
42
+ width: o,
43
+ height: o
44
+ },
45
+ children: /* @__PURE__ */ c("canvas", {
46
+ ref: i,
47
+ className: u.canvasTarget,
48
+ style: {
49
+ width: o,
50
+ height: o
51
+ }
52
+ })
53
+ });
54
+ }, f = {
55
+ chargeContainer: "cos-chargeContainer-4t9qo",
56
+ contrast: "cos-contrast-PNep9",
57
+ hueRotate: "cos-hueRotate-bMJ-k",
58
+ text: "cos-text-2k7eH",
59
+ moveUp: "cos-moveUp-1Vz9j",
60
+ circle: "cos-circle-m4vwX",
61
+ circleRotate: "cos-circleRotate-bgFw5",
62
+ button: "cos-button-myCst"
63
+ }, p = (e) => {
64
+ let { initQuantity: t = 0, value: r, onChange: i, autoCharge: s = !0, interval: u = 500, step: d = .01 } = e, p = r !== void 0, [m, h] = o(t), g = p ? r : m, _ = a(g);
65
+ n(() => {
66
+ _.current = g;
67
+ }, [g]), n(() => {
68
+ if (!s) return;
69
+ let e = window.setInterval(() => {
70
+ let e = Number((_.current + d).toFixed(2));
71
+ p ? i?.(e) : h(e);
72
+ }, u);
73
+ return () => clearInterval(e);
74
+ }, [
75
+ s,
76
+ u,
77
+ p,
78
+ i,
79
+ d
80
+ ]);
81
+ let v = g ? g.toString().padEnd(4, "0") : "0";
82
+ return /* @__PURE__ */ c("div", {
83
+ className: f.chargeContainer,
84
+ children: /* @__PURE__ */ l("div", {
85
+ className: f.contrast,
86
+ children: [
87
+ /* @__PURE__ */ l("div", {
88
+ className: f.text,
89
+ children: [v, "%"]
90
+ }),
91
+ /* @__PURE__ */ c("span", {}),
92
+ /* @__PURE__ */ c("span", {}),
93
+ /* @__PURE__ */ c("span", {}),
94
+ /* @__PURE__ */ c("span", {}),
95
+ /* @__PURE__ */ c("span", {}),
96
+ /* @__PURE__ */ c("span", {}),
97
+ /* @__PURE__ */ c("span", {}),
98
+ /* @__PURE__ */ c("span", {}),
99
+ /* @__PURE__ */ c("span", {}),
100
+ /* @__PURE__ */ c("span", {}),
101
+ /* @__PURE__ */ c("span", {}),
102
+ /* @__PURE__ */ c("span", {}),
103
+ /* @__PURE__ */ c("span", {}),
104
+ /* @__PURE__ */ c("span", {}),
105
+ /* @__PURE__ */ c("div", { className: f.circle }),
106
+ /* @__PURE__ */ c("div", { className: f.button })
107
+ ]
108
+ })
109
+ });
110
+ }, m = {
111
+ confetti: "cos-confetti-MeNtU",
112
+ canvas: "cos-canvas-0T3Vs",
113
+ hint: "cos-hint-sGHEi"
114
+ }, h = [
115
+ "#ff6b6b",
116
+ "#ffd93d",
117
+ "#6bcb77",
118
+ "#4d96ff",
119
+ "#a66cff",
120
+ "#ff85c0",
121
+ "#38bdf8"
122
+ ], g = () => h[Math.floor(Math.random() * h.length)], _ = (e, t, n) => {
123
+ let r = e / 2, i = t * .6;
124
+ return Array.from({ length: n }, () => {
125
+ let e = (Math.random() - .5) * Math.PI, t = Math.random() * 12 + 6;
126
+ return {
127
+ x: r + (Math.random() - .5) * 40,
128
+ y: i,
129
+ vx: Math.cos(e) * t,
130
+ vy: Math.sin(e) * t - Math.random() * 8,
131
+ rotation: Math.random() * 360,
132
+ rotationSpeed: (Math.random() - .5) * 12,
133
+ color: g(),
134
+ width: Math.random() * 8 + 4,
135
+ height: Math.random() * 6 + 3,
136
+ alpha: 1,
137
+ gravity: Math.random() * .15 + .12
138
+ };
139
+ });
140
+ }, v = e(({ width: e = 800, height: i = 400, auto: o = !0, particleCount: s = 120 }, u) => {
141
+ let d = a(null), f = a([]), p = a(0), h = t(() => {
142
+ f.current.push(..._(e, i, s));
143
+ }, [
144
+ i,
145
+ s,
146
+ e
147
+ ]);
148
+ return r(u, () => ({ burst: h }), [h]), n(() => {
149
+ let t = d.current;
150
+ if (!t) return;
151
+ let n = window.devicePixelRatio || 1;
152
+ t.width = e * n, t.height = i * n;
153
+ let r = t.getContext("2d");
154
+ if (!r) return;
155
+ r.setTransform(n, 0, 0, n, 0, 0), o && h();
156
+ let a = () => {
157
+ p.current = requestAnimationFrame(a), r.clearRect(0, 0, e, i), f.current = f.current.filter((e) => (e.x += e.vx, e.y += e.vy, e.vy += e.gravity, e.vx *= .99, e.rotation += e.rotationSpeed, e.alpha -= .008, e.alpha <= 0 || e.y > i + 20 ? !1 : (r.save(), r.translate(e.x, e.y), r.rotate(e.rotation * Math.PI / 180), r.globalAlpha = e.alpha, r.fillStyle = e.color, r.fillRect(-e.width / 2, -e.height / 2, e.width, e.height), r.restore(), !0)));
158
+ };
159
+ return a(), () => cancelAnimationFrame(p.current);
160
+ }, [
161
+ o,
162
+ h,
163
+ i,
164
+ e
165
+ ]), /* @__PURE__ */ l("div", {
166
+ className: m.confetti,
167
+ style: {
168
+ width: e,
169
+ height: i
170
+ },
171
+ children: [/* @__PURE__ */ c("canvas", {
172
+ ref: d,
173
+ className: m.canvas,
174
+ style: {
175
+ width: e,
176
+ height: i
177
+ },
178
+ onClick: h
179
+ }), /* @__PURE__ */ c("p", {
180
+ className: m.hint,
181
+ children: "点击画布再次喷射"
182
+ })]
183
+ });
184
+ });
185
+ v.displayName = "Confetti";
186
+ var y = {
187
+ countdown: "cos-countdown-5ZKKP",
188
+ unit: "cos-unit-dth8N",
189
+ value: "cos-value-yVzcP",
190
+ label: "cos-label-pAMEs",
191
+ ended: "cos-ended-c0dsD",
192
+ pulse: "cos-pulse-krQd-"
193
+ }, b = (e) => e instanceof Date ? e.getTime() : typeof e == "number" ? e : new Date(e).getTime(), x = (e) => {
194
+ let t = Math.max(0, e - Date.now()), n = Math.floor(t / 1e3);
195
+ return {
196
+ total: t,
197
+ days: Math.floor(n / 86400),
198
+ hours: Math.floor(n % 86400 / 3600),
199
+ minutes: Math.floor(n % 3600 / 60),
200
+ seconds: n % 60
201
+ };
202
+ }, S = [
203
+ {
204
+ key: "days",
205
+ label: "天"
206
+ },
207
+ {
208
+ key: "hours",
209
+ label: "时"
210
+ },
211
+ {
212
+ key: "minutes",
213
+ label: "分"
214
+ },
215
+ {
216
+ key: "seconds",
217
+ label: "秒"
218
+ }
219
+ ], C = ({ targetDate: e, onEnd: t, showLabels: r = !0, color: s = "#f472b6" }) => {
220
+ let u = i(() => b(e), [e]), [, d] = o(0), f = a(!1), p = x(u);
221
+ return n(() => {
222
+ f.current = !1;
223
+ let e = window.setInterval(() => d((e) => e + 1), 1e3);
224
+ return () => clearInterval(e);
225
+ }, [u]), n(() => {
226
+ p.total <= 0 && !f.current && (f.current = !0, t?.());
227
+ }, [p.total, t]), /* @__PURE__ */ l("div", {
228
+ className: y.countdown,
229
+ style: { "--countdown-color": s },
230
+ children: [S.map(({ key: e, label: t }) => /* @__PURE__ */ l("div", {
231
+ className: y.unit,
232
+ children: [/* @__PURE__ */ c("div", {
233
+ className: y.value,
234
+ children: String(p[e]).padStart(2, "0")
235
+ }), r && /* @__PURE__ */ c("span", {
236
+ className: y.label,
237
+ children: t
238
+ })]
239
+ }, e)), p.total <= 0 && /* @__PURE__ */ c("p", {
240
+ className: y.ended,
241
+ children: "时间到!"
242
+ })]
243
+ });
244
+ }, w = {
245
+ fireworks: "cos-fireworks-fsSqL",
246
+ canvas: "cos-canvas-spL8G",
247
+ hint: "cos-hint-5XDRH"
248
+ }, T = [
249
+ "#ff6b6b",
250
+ "#ffd93d",
251
+ "#6bcb77",
252
+ "#4d96ff",
253
+ "#a66cff",
254
+ "#ff85c0"
255
+ ], E = .12, D = 240, O = () => T[Math.floor(Math.random() * T.length)], k = (e, t, n) => {
256
+ let r = 60 + Math.floor(Math.random() * 30);
257
+ return Array.from({ length: r }, () => {
258
+ let r = Math.random() * Math.PI * 2, i = Math.random() * 4 + 2;
259
+ return {
260
+ x: e,
261
+ y: t,
262
+ vx: Math.cos(r) * i,
263
+ vy: Math.sin(r) * i,
264
+ alpha: 1,
265
+ color: Math.random() > .3 ? n : O(),
266
+ decay: Math.random() * .015 + .01
267
+ };
268
+ });
269
+ }, A = e(({ width: e = 800, height: i = 500, auto: o = !0 }, s) => {
270
+ let u = a(null), d = a([]), f = a(0), p = t((t) => {
271
+ let n = t ?? Math.random() * e * .6 + e * .2;
272
+ d.current.push({
273
+ x: n,
274
+ y: i,
275
+ vy: -(Math.random() * 4 + 6),
276
+ targetY: Math.random() * i * .35 + i * .15,
277
+ color: O(),
278
+ exploded: !1,
279
+ particles: [],
280
+ age: 0
281
+ });
282
+ }, [i, e]);
283
+ return r(s, () => ({ launch: p }), [p]), n(() => {
284
+ let t = u.current;
285
+ if (!t) return;
286
+ let n = window.devicePixelRatio || 1;
287
+ t.width = e * n, t.height = i * n;
288
+ let r = t.getContext("2d");
289
+ if (!r) return;
290
+ r.setTransform(n, 0, 0, n, 0, 0);
291
+ let a = 0, s = () => {
292
+ f.current = requestAnimationFrame(s), r.fillStyle = "rgb(15 23 42 / 25%)", r.fillRect(0, 0, e, i), o && Math.random() < .03 && p(), d.current = d.current.filter((e) => {
293
+ if (!e.exploded) {
294
+ e.age += 1, e.y += e.vy, e.vy += E, r.beginPath(), r.arc(e.x, e.y, 2.5, 0, Math.PI * 2), r.fillStyle = e.color, r.fill();
295
+ let t = e.vy >= 0, n = e.y <= e.targetY, i = e.y < 0, a = e.age >= D;
296
+ return (t || n || i || a) && (e.exploded = !0, e.particles = k(e.x, e.y, e.color)), !0;
297
+ }
298
+ return e.particles = e.particles.filter((e) => (e.x += e.vx, e.y += e.vy, e.vy += .06, e.alpha -= e.decay, e.alpha <= 0 ? !1 : (r.beginPath(), r.arc(e.x, e.y, 2, 0, Math.PI * 2), r.fillStyle = e.color, r.globalAlpha = e.alpha, r.fill(), r.globalAlpha = 1, !0))), e.particles.length > 0;
299
+ });
300
+ };
301
+ return s(), o && (a = window.setInterval(() => p(), 1200)), () => {
302
+ cancelAnimationFrame(f.current), clearInterval(a);
303
+ };
304
+ }, [
305
+ o,
306
+ i,
307
+ p,
308
+ e
309
+ ]), /* @__PURE__ */ l("div", {
310
+ className: w.fireworks,
311
+ style: {
312
+ width: e,
313
+ height: i
314
+ },
315
+ children: [/* @__PURE__ */ c("canvas", {
316
+ ref: u,
317
+ className: w.canvas,
318
+ style: {
319
+ width: e,
320
+ height: i
321
+ },
322
+ onClick: (e) => {
323
+ let t = e.currentTarget.getBoundingClientRect();
324
+ p(e.clientX - t.left);
325
+ }
326
+ }), /* @__PURE__ */ c("p", {
327
+ className: w.hint,
328
+ children: "点击画布燃放烟花"
329
+ })]
330
+ });
331
+ });
332
+ A.displayName = "Fireworks";
333
+ var j = {
334
+ flipCounter: "cos-flipCounter-3LuI0",
335
+ digit: "cos-digit-yJRPy",
336
+ digitCard: "cos-digitCard-zZUzt",
337
+ staticTop: "cos-staticTop-aLQcm",
338
+ staticBottom: "cos-staticBottom-9y0gu",
339
+ flap: "cos-flap-i3YKR",
340
+ flapTop: "cos-flapTop-70z-k",
341
+ flapBottom: "cos-flapBottom-zhMZe",
342
+ isFlipping: "cos-isFlipping-EVEdI",
343
+ "fold-top": "cos-fold-top-v-6XJ",
344
+ "unfold-bottom": "cos-unfold-bottom-e2gzU"
345
+ }, M = (e, t) => Math.max(0, Math.floor(e)).toString().padStart(t, "0").slice(-t), N = ({ digit: e, color: t, duration: r }) => {
346
+ let i = a(e), [u, d] = o(!1), [f, p] = o(e);
347
+ n(() => {
348
+ if (e === i.current) return;
349
+ p(i.current), d(!0), i.current = e;
350
+ let t = window.setTimeout(() => d(!1), r);
351
+ return () => clearTimeout(t);
352
+ }, [e, r]);
353
+ let m = u ? f : e;
354
+ return /* @__PURE__ */ c("div", {
355
+ className: j.digit,
356
+ style: {
357
+ "--flip-color": t,
358
+ "--flip-duration": `${r}ms`
359
+ },
360
+ children: /* @__PURE__ */ l("div", {
361
+ className: `${j.digitCard} ${u ? j.isFlipping : ""}`,
362
+ children: [
363
+ /* @__PURE__ */ c("div", {
364
+ className: j.staticTop,
365
+ children: /* @__PURE__ */ c("span", { children: m })
366
+ }),
367
+ /* @__PURE__ */ c("div", {
368
+ className: j.staticBottom,
369
+ children: /* @__PURE__ */ c("span", { children: m })
370
+ }),
371
+ u && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("div", {
372
+ className: `${j.flap} ${j.flapTop}`,
373
+ children: /* @__PURE__ */ c("span", { children: f })
374
+ }), /* @__PURE__ */ c("div", {
375
+ className: `${j.flap} ${j.flapBottom}`,
376
+ children: /* @__PURE__ */ c("span", { children: e })
377
+ })] })
378
+ ]
379
+ })
380
+ });
381
+ }, P = ({ value: e, digits: t = 4, color: n = "#38bdf8", duration: r = 600 }) => {
382
+ let i = M(e, t).split("");
383
+ return /* @__PURE__ */ c("div", {
384
+ className: j.flipCounter,
385
+ children: i.map((e, t) => /* @__PURE__ */ c(N, {
386
+ digit: e,
387
+ color: n,
388
+ duration: r
389
+ }, t))
390
+ });
391
+ }, F = {
392
+ glitchText: "cos-glitchText-dZ-sR",
393
+ text: "cos-text-JsPHN",
394
+ "glitch-1": "cos-glitch-1-s9pqH",
395
+ "glitch-2": "cos-glitch-2-GhFB-"
396
+ }, I = ({ text: e = "GLITCH", color: t = "#f8fafc", glitchColor1: n = "#ff00de", glitchColor2: r = "#00f0ff", fontSize: i = 64 }) => /* @__PURE__ */ c("div", {
397
+ className: F.glitchText,
398
+ children: /* @__PURE__ */ c("h1", {
399
+ className: F.text,
400
+ "data-text": e,
401
+ style: {
402
+ fontSize: i,
403
+ "--glitch-color": t,
404
+ "--glitch-c1": n,
405
+ "--glitch-c2": r
406
+ },
407
+ children: e
408
+ })
409
+ }), L = {
410
+ matrixRain: "cos-matrixRain-qg9HC",
411
+ canvas: "cos-canvas--AvpG",
412
+ overlay: "cos-overlay-knj3b",
413
+ title: "cos-title-sDfhs",
414
+ flicker: "cos-flicker-smHxl",
415
+ subtitle: "cos-subtitle-CWheW"
416
+ }, R = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*アイウエオカキクケコ", z = ({ width: e = 800, height: t = 500, density: r = .6, color: i = "#00ff41" }) => {
417
+ let o = a(null);
418
+ return n(() => {
419
+ let n = o.current;
420
+ if (!n) return;
421
+ let a = window.devicePixelRatio || 1;
422
+ n.width = e * a, n.height = t * a;
423
+ let s = n.getContext("2d");
424
+ if (!s) return;
425
+ s.setTransform(a, 0, 0, a, 0, 0);
426
+ let c = Math.floor(e / 16 * r), l = Array.from({ length: c }, () => Math.random() * -50), u = 0, d = () => {
427
+ s.fillStyle = "rgb(0 0 0 / 8%)", s.fillRect(0, 0, e, t), s.fillStyle = i, s.font = "16px monospace", l.forEach((e, n) => {
428
+ let a = R[Math.floor(Math.random() * 53)], o = n / r * 16;
429
+ s.fillStyle = i, s.fillText(a, o, e * 16), e * 16 > t && Math.random() > .975 && (l[n] = 0), l[n] += 1;
430
+ }), u = requestAnimationFrame(d);
431
+ };
432
+ return d(), () => cancelAnimationFrame(u);
433
+ }, [
434
+ i,
435
+ r,
436
+ t,
437
+ e
438
+ ]), /* @__PURE__ */ l("div", {
439
+ className: L.matrixRain,
440
+ style: {
441
+ width: e,
442
+ height: t
443
+ },
444
+ children: [/* @__PURE__ */ c("canvas", {
445
+ ref: o,
446
+ className: L.canvas,
447
+ style: {
448
+ width: e,
449
+ height: t
450
+ }
451
+ }), /* @__PURE__ */ l("div", {
452
+ className: L.overlay,
453
+ children: [/* @__PURE__ */ c("h2", {
454
+ className: L.title,
455
+ children: "MATRIX"
456
+ }), /* @__PURE__ */ c("p", {
457
+ className: L.subtitle,
458
+ children: "数字雨效果"
459
+ })]
460
+ })]
461
+ });
462
+ }, B = {
463
+ meteorRain: "cos-meteorRain-v8RNI",
464
+ canvas: "cos-canvas-hyFMr"
465
+ }, V = ({ width: e = 800, height: t = 500, meteorCount: r = 8 }) => {
466
+ let i = a(null), o = a([]), s = a(0);
467
+ return n(() => {
468
+ o.current = Array.from({ length: r }, () => ({
469
+ x: Math.random() * e,
470
+ y: Math.random() * t * .5,
471
+ length: Math.random() * 60 + 40,
472
+ speed: Math.random() * 6 + 4,
473
+ opacity: Math.random() * .5 + .3
474
+ }));
475
+ }, [
476
+ t,
477
+ r,
478
+ e
479
+ ]), n(() => {
480
+ let n = i.current;
481
+ if (!n) return;
482
+ let r = window.devicePixelRatio || 1;
483
+ n.width = e * r, n.height = t * r;
484
+ let a = n.getContext("2d");
485
+ if (!a) return;
486
+ a.setTransform(r, 0, 0, r, 0, 0);
487
+ let c = () => {
488
+ s.current = requestAnimationFrame(c), a.fillStyle = "rgb(15 23 42 / 15%)", a.fillRect(0, 0, e, t), o.current.forEach((n) => {
489
+ n.x += n.speed, n.y += n.speed * .6, (n.x > e + n.length || n.y > t + n.length) && (n.x = -n.length, n.y = Math.random() * t * .4, n.length = Math.random() * 60 + 40, n.speed = Math.random() * 6 + 4, n.opacity = Math.random() * .5 + .3);
490
+ let r = a.createLinearGradient(n.x, n.y, n.x - n.length, n.y - n.length * .6);
491
+ r.addColorStop(0, `rgb(255 255 255 / ${n.opacity})`), r.addColorStop(1, "rgb(255 255 255 / 0)"), a.beginPath(), a.strokeStyle = r, a.lineWidth = 2, a.moveTo(n.x, n.y), a.lineTo(n.x - n.length, n.y - n.length * .6), a.stroke();
492
+ });
493
+ };
494
+ return c(), () => cancelAnimationFrame(s.current);
495
+ }, [t, e]), /* @__PURE__ */ c("div", {
496
+ className: B.meteorRain,
497
+ style: {
498
+ width: e,
499
+ height: t
500
+ },
501
+ children: /* @__PURE__ */ c("canvas", {
502
+ ref: i,
503
+ className: B.canvas,
504
+ style: {
505
+ width: e,
506
+ height: t
507
+ }
508
+ })
509
+ });
510
+ }, H = {
511
+ neonText: "cos-neonText-JMP7i",
512
+ text: "cos-text-GTO-0",
513
+ flicker: "cos-flicker-nXceV",
514
+ "neon-flicker": "cos-neon-flicker-uDkmM",
515
+ reflection: "cos-reflection-aEYj6"
516
+ }, U = ({ text: e = "NEON", color: t = "#ff00de", fontSize: n = 72, flicker: r = !0 }) => /* @__PURE__ */ l("div", {
517
+ className: H.neonText,
518
+ children: [/* @__PURE__ */ c("h1", {
519
+ className: `${H.text} ${r ? H.flicker : ""}`,
520
+ style: {
521
+ fontSize: n,
522
+ "--neon-color": t
523
+ },
524
+ children: e
525
+ }), /* @__PURE__ */ c("p", {
526
+ className: H.reflection,
527
+ style: {
528
+ fontSize: n * .35,
529
+ color: t
530
+ },
531
+ children: e
532
+ })]
533
+ }), W = {
534
+ particleNetwork: "cos-particleNetwork-GSZq-",
535
+ canvas: "cos-canvas-E-BGP",
536
+ hint: "cos-hint-LEO5o"
537
+ }, G = ({ width: e = 800, height: r = 500, particleCount: i = 60, linkDistance: o = 120, color: s = "#38bdf8" }) => {
538
+ let u = a(null), d = a([]), f = a({
539
+ x: -1e3,
540
+ y: -1e3
541
+ }), p = t(() => {
542
+ d.current = Array.from({ length: i }, () => ({
543
+ x: Math.random() * e,
544
+ y: Math.random() * r,
545
+ vx: (Math.random() - .5) * 1.2,
546
+ vy: (Math.random() - .5) * 1.2,
547
+ radius: Math.random() * 2 + 1
548
+ }));
549
+ }, [
550
+ r,
551
+ i,
552
+ e
553
+ ]);
554
+ return n(() => {
555
+ p();
556
+ }, [p]), n(() => {
557
+ let t = u.current;
558
+ if (!t) return;
559
+ let n = window.devicePixelRatio || 1;
560
+ t.width = e * n, t.height = r * n;
561
+ let i = t.getContext("2d");
562
+ if (!i) return;
563
+ i.setTransform(n, 0, 0, n, 0, 0);
564
+ let a = 0, c = () => {
565
+ i.fillStyle = "#0f172a", i.fillRect(0, 0, e, r);
566
+ let t = d.current, n = f.current;
567
+ t.forEach((t) => {
568
+ t.x += t.vx, t.y += t.vy, (t.x < 0 || t.x > e) && (t.vx *= -1), (t.y < 0 || t.y > r) && (t.vy *= -1);
569
+ let i = n.x - t.x, a = n.y - t.y;
570
+ Math.sqrt(i * i + a * a) < 150 && (t.vx -= i * 3e-4, t.vy -= a * 3e-4);
571
+ });
572
+ for (let e = 0; e < t.length; e++) for (let n = e + 1; n < t.length; n++) {
573
+ let r = t[e].x - t[n].x, a = t[e].y - t[n].y, c = Math.sqrt(r * r + a * a);
574
+ c < o && (i.beginPath(), i.moveTo(t[e].x, t[e].y), i.lineTo(t[n].x, t[n].y), i.strokeStyle = s, i.globalAlpha = 1 - c / o, i.lineWidth = .8, i.stroke(), i.globalAlpha = 1);
575
+ }
576
+ t.forEach((e) => {
577
+ i.beginPath(), i.arc(e.x, e.y, e.radius, 0, Math.PI * 2), i.fillStyle = s, i.fill();
578
+ }), a = requestAnimationFrame(c);
579
+ };
580
+ return c(), () => cancelAnimationFrame(a);
581
+ }, [
582
+ s,
583
+ r,
584
+ p,
585
+ o,
586
+ e
587
+ ]), /* @__PURE__ */ l("div", {
588
+ className: W.particleNetwork,
589
+ style: {
590
+ width: e,
591
+ height: r
592
+ },
593
+ children: [/* @__PURE__ */ c("canvas", {
594
+ ref: u,
595
+ className: W.canvas,
596
+ style: {
597
+ width: e,
598
+ height: r
599
+ },
600
+ onMouseMove: (e) => {
601
+ let t = e.currentTarget.getBoundingClientRect();
602
+ f.current = {
603
+ x: e.clientX - t.left,
604
+ y: e.clientY - t.top
605
+ };
606
+ },
607
+ onMouseLeave: () => {
608
+ f.current = {
609
+ x: -1e3,
610
+ y: -1e3
611
+ };
612
+ }
613
+ }), /* @__PURE__ */ c("p", {
614
+ className: W.hint,
615
+ children: "移动鼠标与粒子互动"
616
+ })]
617
+ });
618
+ }, K = {
619
+ returnCityContainer: "cos-returnCityContainer-6XTxj",
620
+ star: "cos-star-a59Dx",
621
+ glassWrap: "cos-glassWrap-golMO",
622
+ rotate: "cos-rotate-7X9Jj",
623
+ glassItem: "cos-glassItem-OwlFI"
624
+ }, q = ({ starCount: e, glassCount: t = 6, glassRadius: r = 150 }) => {
625
+ let i = a(null), o = a(null);
626
+ return n(() => {
627
+ let n = i.current, a = o.current;
628
+ if (!n || !a) return;
629
+ let s = [], c = [], l = [], u = e ?? Math.floor(document.documentElement.clientWidth / 20);
630
+ for (let e = 0; e < u; e++) {
631
+ let e = window.setTimeout(() => {
632
+ let e = document.createElement("div");
633
+ e.className = K.star;
634
+ let t = document.body.clientWidth, r = document.body.clientHeight;
635
+ e.style.top = `${Math.random() * r}px`, e.style.left = `${Math.random() * t}px`, n.append(e), c.push(e);
636
+ }, Math.random() * 2e3);
637
+ s.push(e);
638
+ }
639
+ for (let e = 0; e < t; e++) {
640
+ let n = document.createElement("div");
641
+ n.className = K.glassItem, n.style.transform = `rotateY(${360 / t * e}deg) translateZ(${r}px)`, a.appendChild(n), l.push(n);
642
+ let i = window.setTimeout(() => {
643
+ n.style.top = "0px", n.style.opacity = "1";
644
+ }, e * 300);
645
+ s.push(i);
646
+ }
647
+ return () => {
648
+ s.forEach(clearTimeout), c.forEach((e) => e.remove()), l.forEach((e) => e.remove());
649
+ };
650
+ }, [
651
+ e,
652
+ t,
653
+ r
654
+ ]), /* @__PURE__ */ c("div", {
655
+ ref: i,
656
+ className: K.returnCityContainer,
657
+ children: /* @__PURE__ */ c("div", {
658
+ ref: o,
659
+ className: K.glassWrap
660
+ })
661
+ });
662
+ }, J = {
663
+ turntable: "cos-turntable-dkc32",
664
+ wheelWrap: "cos-wheelWrap-n7lhc",
665
+ canvas: "cos-canvas-A1-4x",
666
+ pointer: "cos-pointer-Rk1S9",
667
+ spinBtn: "cos-spinBtn-l9JIC",
668
+ result: "cos-result-H8q2c",
669
+ "fade-in": "cos-fade-in-U9bUC"
670
+ }, Y = [
671
+ "#FF6B6B",
672
+ "#4ECDC4",
673
+ "#FFE66D",
674
+ "#A78BFA",
675
+ "#60A5FA",
676
+ "#F472B6",
677
+ "#34D399",
678
+ "#FB923C"
679
+ ], X = [
680
+ { label: "一等奖" },
681
+ { label: "二等奖" },
682
+ { label: "三等奖" },
683
+ { label: "谢谢参与" },
684
+ { label: "优惠券" },
685
+ { label: "再来一次" }
686
+ ], Z = (e) => 1 - (1 - e) ** 3, ee = ({ prizes: e = X, size: r = 360, spinDuration: i = 4e3, spinRounds: s = 5, buttonText: u = "开始抽奖", onSpinEnd: d }) => {
687
+ let f = a(null), p = a(0), m = a(0), h = a(1), [g, _] = o(!1), [v, y] = o(null), b = r + 48, x = (e, t) => t.color ?? Y[e % Y.length], S = t((t) => {
688
+ let n = f.current;
689
+ if (!n) return;
690
+ let i = n.getContext("2d");
691
+ if (!i) return;
692
+ let a = b / 2, o = r / 2, s = Math.PI * 2 / e.length;
693
+ i.clearRect(0, 0, b, b), i.save(), i.translate(a, a), i.rotate(t), e.forEach((e, t) => {
694
+ let n = t * s - Math.PI / 2, a = n + s, c = x(t, e);
695
+ i.beginPath(), i.moveTo(0, 0), i.arc(0, 0, o, n, a), i.closePath(), i.fillStyle = c, i.fill(), i.strokeStyle = "rgb(255 255 255 / 35%)", i.lineWidth = 2, i.stroke(), i.save(), i.rotate(n + s / 2), i.textAlign = "right", i.fillStyle = "#fff", i.font = `bold ${Math.max(12, Math.floor(r / 22))}px system-ui, sans-serif`, i.shadowColor = "rgb(0 0 0 / 30%)", i.shadowBlur = 4, i.fillText(e.label, o - 18, 6), i.restore();
696
+ }), i.beginPath(), i.arc(0, 0, o, 0, Math.PI * 2), i.strokeStyle = "#fbbf24", i.lineWidth = 6, i.stroke(), i.beginPath(), i.arc(0, 0, o - 4, 0, Math.PI * 2), i.strokeStyle = "#f59e0b", i.lineWidth = 2, i.stroke(), i.restore(), i.save(), i.translate(a, a);
697
+ for (let e = 0; e < 12; e++) {
698
+ let t = e / 12 * Math.PI * 2, n = Math.cos(t) * (o + 14), r = Math.sin(t) * (o + 14);
699
+ i.beginPath(), i.arc(n, r, 3, 0, Math.PI * 2), i.fillStyle = e % 2 == 0 ? "#fde68a" : "#f59e0b", i.fill();
700
+ }
701
+ i.restore();
702
+ }, [
703
+ b,
704
+ e,
705
+ r
706
+ ]);
707
+ n(() => {
708
+ let e = f.current;
709
+ if (!e) return;
710
+ let t = window.devicePixelRatio || 1;
711
+ h.current = t, e.width = b * t, e.height = b * t;
712
+ let n = e.getContext("2d");
713
+ n && n.setTransform(t, 0, 0, t, 0, 0), S(p.current);
714
+ }, [b, S]), n(() => () => {
715
+ m.current && cancelAnimationFrame(m.current);
716
+ }, []);
717
+ let C = (t) => {
718
+ let n = 360 / e.length, r = (180 / Math.PI * t % 360 + 360) % 360;
719
+ return Math.floor((360 - r + n / 2) % 360 / n) % e.length;
720
+ };
721
+ return /* @__PURE__ */ l("div", {
722
+ className: J.turntable,
723
+ style: {
724
+ width: b,
725
+ height: b + 80
726
+ },
727
+ children: [/* @__PURE__ */ l("div", {
728
+ className: J.wheelWrap,
729
+ style: {
730
+ width: b,
731
+ height: b
732
+ },
733
+ children: [
734
+ /* @__PURE__ */ c("div", { className: J.pointer }),
735
+ /* @__PURE__ */ c("canvas", {
736
+ ref: f,
737
+ className: J.canvas,
738
+ style: {
739
+ width: b,
740
+ height: b
741
+ }
742
+ }),
743
+ /* @__PURE__ */ c("button", {
744
+ type: "button",
745
+ className: J.spinBtn,
746
+ onClick: () => {
747
+ if (g || e.length === 0) return;
748
+ _(!0), y(null);
749
+ let t = Math.PI * 2 / e.length, n = Math.floor(Math.random() * e.length) * t + t / 2, r = p.current, a = r + s * Math.PI * 2 + (Math.PI * 2 - n) - r % (Math.PI * 2), o = r, c = performance.now(), l = (t) => {
750
+ let n = t - c, r = Math.min(n / i, 1), s = Z(r), u = o + (a - o) * s;
751
+ if (p.current = u, S(u), r < 1) m.current = requestAnimationFrame(l);
752
+ else {
753
+ let t = C(u), n = e[t];
754
+ p.current = u, _(!1), y(n), d?.(n, t);
755
+ }
756
+ };
757
+ m.current = requestAnimationFrame(l);
758
+ },
759
+ disabled: g,
760
+ children: g ? "抽奖中..." : u
761
+ })
762
+ ]
763
+ }), v && !g && /* @__PURE__ */ l("p", {
764
+ className: J.result,
765
+ children: ["恭喜获得:", /* @__PURE__ */ c("strong", { children: v.label })]
766
+ })]
767
+ });
768
+ }, Q = {
769
+ typewriter: "cos-typewriter-7UhOL",
770
+ terminal: "cos-terminal-NWNVN",
771
+ dots: "cos-dots-oulNg",
772
+ text: "cos-text-ICV5T",
773
+ prompt: "cos-prompt-Y4hVD",
774
+ cursor: "cos-cursor-m8hGi",
775
+ blink: "cos-blink-XykM7"
776
+ }, te = [
777
+ "Hello, cos-design!",
778
+ "欢迎来到组件库 ✨",
779
+ "Build something fun 🚀"
780
+ ], ne = ({ texts: e = te, speed: t = 100, deleteSpeed: r = 50, pause: i = 2e3 }) => {
781
+ let [a, s] = o(""), [u, d] = o(0), [f, p] = o(!1);
782
+ return n(() => {
783
+ let n = e[u % e.length], o;
784
+ if (!f && a === n) o = setTimeout(() => p(!0), i);
785
+ else if (f && a === "") o = setTimeout(() => {
786
+ p(!1), d((t) => (t + 1) % e.length);
787
+ }, 0);
788
+ else {
789
+ let e = f ? n.slice(0, a.length - 1) : n.slice(0, a.length + 1);
790
+ o = setTimeout(() => s(e), f ? r : t);
791
+ }
792
+ return () => clearTimeout(o);
793
+ }, [
794
+ a,
795
+ f,
796
+ u,
797
+ e,
798
+ t,
799
+ r,
800
+ i
801
+ ]), /* @__PURE__ */ c("div", {
802
+ className: Q.typewriter,
803
+ children: /* @__PURE__ */ l("div", {
804
+ className: Q.terminal,
805
+ children: [/* @__PURE__ */ l("div", {
806
+ className: Q.dots,
807
+ children: [
808
+ /* @__PURE__ */ c("span", {}),
809
+ /* @__PURE__ */ c("span", {}),
810
+ /* @__PURE__ */ c("span", {})
811
+ ]
812
+ }), /* @__PURE__ */ l("p", {
813
+ className: Q.text,
814
+ children: [
815
+ /* @__PURE__ */ c("span", {
816
+ className: Q.prompt,
817
+ children: ">"
818
+ }),
819
+ a,
820
+ /* @__PURE__ */ c("span", {
821
+ className: Q.cursor,
822
+ children: "|"
823
+ })
824
+ ]
825
+ })]
826
+ })
827
+ });
828
+ }, $ = {
829
+ waveButton: "cos-waveButton-Aa7G-",
830
+ btn: "cos-btn-WJrEN",
831
+ label: "cos-label-9BHOU",
832
+ wave: "cos-wave-GycLU",
833
+ ripple: "cos-ripple-5ZFpr"
834
+ }, re = ({ text: e = "点我试试", onClick: t, color: n = "#38bdf8" }) => /* @__PURE__ */ c("div", {
835
+ className: $.waveButton,
836
+ children: /* @__PURE__ */ l("button", {
837
+ type: "button",
838
+ className: $.btn,
839
+ style: { "--wave-color": n },
840
+ onClick: t,
841
+ children: [
842
+ /* @__PURE__ */ c("span", { className: $.wave }),
843
+ /* @__PURE__ */ c("span", { className: $.wave }),
844
+ /* @__PURE__ */ c("span", {
845
+ className: $.label,
846
+ children: e
847
+ })
848
+ ]
849
+ })
850
+ });
851
+ //#endregion
852
+ export { d as CanvasClock, p as Charge, v as Confetti, C as Countdown, A as Fireworks, P as FlipCounter, I as GlitchText, z as MatrixRain, V as MeteorRain, U as NeonText, G as ParticleNetwork, q as ReturnCity, ee as Turntable, ne as Typewriter, re as WaveButton };