@factorialco/f0-react 1.438.4 → 1.444.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.
Files changed (47) hide show
  1. package/dist/{F0AiChat-DPDtak5l.js → F0AiChat-RHHqqqMC.js} +155298 -138847
  2. package/dist/F0AiChat.css +1 -1
  3. package/dist/ai.d.ts +593 -12
  4. package/dist/ai.js +12 -10
  5. package/dist/experimental.d.ts +108 -8
  6. package/dist/experimental.js +3581 -3861
  7. package/dist/f0.css +1 -0
  8. package/dist/f0.d.ts +375 -42
  9. package/dist/f0.js +14479 -10522
  10. package/dist/i18n-provider-defaults.d.ts +21 -5
  11. package/dist/i18n-provider-defaults.js +18 -2
  12. package/dist/index-D_fn_du2.js +44284 -0
  13. package/dist/index.css +1 -1
  14. package/dist/styles.css +1 -1
  15. package/dist/types-99qPm9SM.js +2354 -0
  16. package/icons/app/Basket.d.ts +4 -0
  17. package/icons/app/Basket.d.ts.map +1 -0
  18. package/icons/app/Basket.js +5 -0
  19. package/icons/app/Bookmark.d.ts.map +1 -1
  20. package/icons/app/Bookmark.js +1 -1
  21. package/icons/app/BookmarkFilled.d.ts +4 -0
  22. package/icons/app/BookmarkFilled.d.ts.map +1 -0
  23. package/icons/app/BookmarkFilled.js +5 -0
  24. package/icons/app/ChartFunnel.d.ts +4 -0
  25. package/icons/app/ChartFunnel.d.ts.map +1 -0
  26. package/icons/app/ChartFunnel.js +5 -0
  27. package/icons/app/ChartHorizontalBars.d.ts +4 -0
  28. package/icons/app/ChartHorizontalBars.d.ts.map +1 -0
  29. package/icons/app/ChartHorizontalBars.js +5 -0
  30. package/icons/app/ChartLine.d.ts.map +1 -1
  31. package/icons/app/ChartLine.js +2 -2
  32. package/icons/app/ChartPie.d.ts.map +1 -1
  33. package/icons/app/ChartPie.js +2 -2
  34. package/icons/app/ChartVerticalBars.d.ts +4 -0
  35. package/icons/app/ChartVerticalBars.d.ts.map +1 -0
  36. package/icons/app/ChartVerticalBars.js +5 -0
  37. package/icons/app/UserProtected.d.ts +4 -0
  38. package/icons/app/UserProtected.d.ts.map +1 -0
  39. package/icons/app/UserProtected.js +5 -0
  40. package/icons/app/Watch.d.ts.map +1 -1
  41. package/icons/app/Watch.js +1 -1
  42. package/icons/app/index.d.ts +15 -9
  43. package/icons/app/index.d.ts.map +1 -1
  44. package/icons/app/index.js +15 -9
  45. package/package.json +3 -2
  46. package/dist/F0HILActionConfirmation-DShSXZqM.js +0 -1912
  47. package/dist/index-iuTQ3Ph9.js +0 -63101
@@ -1,1912 +0,0 @@
1
- import { defaultTranslations as ke } from "./i18n-provider-defaults.js";
2
- import { jsx as q, jsxs as le } from "react/jsx-runtime";
3
- import { useInsertionEffect as Xe, createContext as Ye, useContext as $e, useRef as B, useEffect as ie, useState as Ue, useCallback as qe, useMemo as He } from "react";
4
- import { r as Ke, l as je, m as Qe, n as Je, o as Me, p as Ze, q as et, s as tt, t as rt, v as nt, w as Ne, x as ot, V as it, y as st, z as at, A as ct, S as ut, H as lt, B as se, D as ft, E as dt, G as ht, J as mt, K as pt, L as vt, M as fe, N as gt } from "./F0AiChat-DPDtak5l.js";
5
- import { useTrackVolume as wt } from "@livekit/components-react";
6
- function Tt(t, e, r) {
7
- Xe(() => t.on(e, r), [t, e, r]);
8
- }
9
- function ue(t) {
10
- return typeof t == "object" && !Array.isArray(t);
11
- }
12
- function Oe(t, e, r, n) {
13
- return typeof t == "string" && ue(e) ? Ke(t, r, n) : t instanceof NodeList ? Array.from(t) : Array.isArray(t) ? t : [t];
14
- }
15
- function yt(t, e, r) {
16
- return t * (e + 1);
17
- }
18
- function de(t, e, r, n) {
19
- return typeof e == "number" ? e : e.startsWith("-") || e.startsWith("+") ? Math.max(0, t + parseFloat(e)) : e === "<" ? r : n.get(e) ?? t;
20
- }
21
- const Et = (t, e, r) => {
22
- const n = e - t;
23
- return ((r - t) % n + n) % n + t;
24
- };
25
- function Be(t, e) {
26
- return je(t) ? t[Et(0, t.length, e)] : t;
27
- }
28
- function At(t, e, r) {
29
- for (let n = 0; n < t.length; n++) {
30
- const o = t[n];
31
- o.at > e && o.at < r && (Je(t, o), n--);
32
- }
33
- }
34
- function bt(t, e, r, n, o, c) {
35
- At(t, o, c);
36
- for (let m = 0; m < e.length; m++)
37
- t.push({
38
- value: e[m],
39
- at: Qe(o, c, n[m]),
40
- easing: Be(r, m)
41
- });
42
- }
43
- function Rt(t, e) {
44
- for (let r = 0; r < t.length; r++)
45
- t[r] = t[r] / (e + 1);
46
- }
47
- function xt(t, e) {
48
- return t.at === e.at ? t.value === null ? 1 : e.value === null ? -1 : 0 : t.at - e.at;
49
- }
50
- const Lt = "easeInOut", St = 20;
51
- function It(t, { defaultTransition: e = {}, ...r } = {}, n, o) {
52
- const c = e.duration || 0.3, m = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), v = {}, R = /* @__PURE__ */ new Map();
53
- let p = 0, g = 0, x = 0;
54
- for (let l = 0; l < t.length; l++) {
55
- const T = t[l];
56
- if (typeof T == "string") {
57
- R.set(T, g);
58
- continue;
59
- } else if (!Array.isArray(T)) {
60
- R.set(T.name, de(g, T.at, p, R));
61
- continue;
62
- }
63
- let [C, h, L = {}] = T;
64
- L.at !== void 0 && (g = de(g, L.at, p, R));
65
- let I = 0;
66
- const U = (y, w, _, P = 0, V = 0) => {
67
- const b = _t(y), { delay: f = 0, times: F = Ze(b), type: O = "keyframes", repeat: z, repeatType: W, repeatDelay: H = 0, ...k } = w;
68
- let { ease: M = e.ease || "easeOut", duration: S } = w;
69
- const N = typeof f == "function" ? f(P, V) : f, K = b.length, Z = rt(O) ? O : o?.[O];
70
- if (K <= 2 && Z) {
71
- let j = 100;
72
- if (K === 2 && Pt(b)) {
73
- const J = b[1] - b[0];
74
- j = Math.abs(J);
75
- }
76
- const Q = { ...k };
77
- S !== void 0 && (Q.duration = nt(S));
78
- const ee = et(Q, j, Z);
79
- M = ee.ease, S = ee.duration;
80
- }
81
- S ?? (S = c);
82
- const $ = g + N;
83
- F.length === 1 && F[0] === 0 && (F[1] = 1);
84
- const re = F.length - b.length;
85
- if (re > 0 && tt(F, re), b.length === 1 && b.unshift(null), z) {
86
- Ne(z < St, "Repeat count too high, must be less than 20"), S = yt(S, z);
87
- const j = [...b], Q = [...F];
88
- M = Array.isArray(M) ? [...M] : [M];
89
- const ee = [...M];
90
- for (let J = 0; J < z; J++) {
91
- b.push(...j);
92
- for (let i = 0; i < j.length; i++)
93
- F.push(Q[i] + (J + 1)), M.push(i === 0 ? "linear" : Be(ee, i - 1));
94
- }
95
- Rt(F, z);
96
- }
97
- const ne = $ + S;
98
- bt(_, b, M, F, $, ne), I = Math.max(N + S, I), x = Math.max(ne, x);
99
- };
100
- if (Me(C)) {
101
- const y = he(C, E);
102
- U(h, L, me("default", y));
103
- } else {
104
- const y = Oe(C, h, n, v), w = y.length;
105
- for (let _ = 0; _ < w; _++) {
106
- h = h, L = L;
107
- const P = y[_], V = he(P, E);
108
- for (const b in h)
109
- U(h[b], Ft(L, b), me(b, V), _, w);
110
- }
111
- }
112
- p = g, g += I;
113
- }
114
- return E.forEach((l, T) => {
115
- for (const C in l) {
116
- const h = l[C];
117
- h.sort(xt);
118
- const L = [], I = [], U = [];
119
- for (let w = 0; w < h.length; w++) {
120
- const { at: _, value: P, easing: V } = h[w];
121
- L.push(P), I.push(ot(0, x, _)), U.push(V || "easeOut");
122
- }
123
- I[0] !== 0 && (I.unshift(0), L.unshift(L[0]), U.unshift(Lt)), I[I.length - 1] !== 1 && (I.push(1), L.push(null)), m.has(T) || m.set(T, {
124
- keyframes: {},
125
- transition: {}
126
- });
127
- const y = m.get(T);
128
- y.keyframes[C] = L, y.transition[C] = {
129
- ...e,
130
- duration: x,
131
- ease: U,
132
- times: I,
133
- ...r
134
- };
135
- }
136
- }), m;
137
- }
138
- function he(t, e) {
139
- return !e.has(t) && e.set(t, {}), e.get(t);
140
- }
141
- function me(t, e) {
142
- return e[t] || (e[t] = []), e[t];
143
- }
144
- function _t(t) {
145
- return Array.isArray(t) ? t : [t];
146
- }
147
- function Ft(t, e) {
148
- return t && t[e] ? {
149
- ...t,
150
- ...t[e]
151
- } : { ...t };
152
- }
153
- const Ct = (t) => typeof t == "number", Pt = (t) => t.every(Ct);
154
- function Ut(t, e) {
155
- return t in e;
156
- }
157
- class Mt extends it {
158
- constructor() {
159
- super(...arguments), this.type = "object";
160
- }
161
- readValueFromInstance(e, r) {
162
- if (Ut(r, e)) {
163
- const n = e[r];
164
- if (typeof n == "string" || typeof n == "number")
165
- return n;
166
- }
167
- }
168
- getBaseTargetFromProps() {
169
- }
170
- removeValueFromRenderState(e, r) {
171
- delete r.output[e];
172
- }
173
- measureInstanceViewportBox() {
174
- return st();
175
- }
176
- build(e, r) {
177
- Object.assign(e.output, r);
178
- }
179
- renderInstance(e, { output: r }) {
180
- Object.assign(e, r);
181
- }
182
- sortInstanceNodePosition() {
183
- return 0;
184
- }
185
- }
186
- function Nt(t) {
187
- const e = {
188
- presenceContext: null,
189
- props: {},
190
- visualState: {
191
- renderState: {
192
- transform: {},
193
- transformOrigin: {},
194
- style: {},
195
- vars: {},
196
- attrs: {}
197
- },
198
- latestValues: {}
199
- }
200
- }, r = at(t) && !ct(t) ? new ut(e) : new lt(e);
201
- r.mount(t), se.set(t, r);
202
- }
203
- function Ot(t) {
204
- const e = {
205
- presenceContext: null,
206
- props: {},
207
- visualState: {
208
- renderState: {
209
- output: {}
210
- },
211
- latestValues: {}
212
- }
213
- }, r = new Mt(e);
214
- r.mount(t), se.set(t, r);
215
- }
216
- function Bt(t, e) {
217
- return Me(t) || typeof t == "number" || typeof t == "string" && !ue(e);
218
- }
219
- function Ve(t, e, r, n) {
220
- const o = [];
221
- if (Bt(t, e))
222
- o.push(ft(t, ue(e) && e.default || e, r && (r.default || r)));
223
- else {
224
- const c = Oe(t, e, n), m = c.length;
225
- Ne(!!m, "No valid elements provided.");
226
- for (let E = 0; E < m; E++) {
227
- const v = c[E], R = v instanceof Element ? Nt : Ot;
228
- se.has(v) || R(v);
229
- const p = se.get(v), g = { ...r };
230
- "delay" in g && typeof g.delay == "function" && (g.delay = g.delay(E, m)), o.push(...dt(p, { ...e, transition: g }, {}));
231
- }
232
- }
233
- return o;
234
- }
235
- function Vt(t, e, r) {
236
- const n = [];
237
- return It(t, e, r, { spring: ht }).forEach(({ keyframes: c, transition: m }, E) => {
238
- n.push(...Ve(E, c, m));
239
- }), n;
240
- }
241
- class Dt {
242
- constructor(e) {
243
- this.stop = () => this.runAll("stop"), this.animations = e.filter(Boolean);
244
- }
245
- get finished() {
246
- return Promise.all(this.animations.map((e) => e.finished));
247
- }
248
- /**
249
- * TODO: Filter out cancelled or stopped animations before returning
250
- */
251
- getAll(e) {
252
- return this.animations[0][e];
253
- }
254
- setAll(e, r) {
255
- for (let n = 0; n < this.animations.length; n++)
256
- this.animations[n][e] = r;
257
- }
258
- attachTimeline(e) {
259
- const r = this.animations.map((n) => n.attachTimeline(e));
260
- return () => {
261
- r.forEach((n, o) => {
262
- n && n(), this.animations[o].stop();
263
- });
264
- };
265
- }
266
- get time() {
267
- return this.getAll("time");
268
- }
269
- set time(e) {
270
- this.setAll("time", e);
271
- }
272
- get speed() {
273
- return this.getAll("speed");
274
- }
275
- set speed(e) {
276
- this.setAll("speed", e);
277
- }
278
- get state() {
279
- return this.getAll("state");
280
- }
281
- get startTime() {
282
- return this.getAll("startTime");
283
- }
284
- get duration() {
285
- let e = 0;
286
- for (let r = 0; r < this.animations.length; r++)
287
- e = Math.max(e, this.animations[r].duration);
288
- return e;
289
- }
290
- runAll(e) {
291
- this.animations.forEach((r) => r[e]());
292
- }
293
- play() {
294
- this.runAll("play");
295
- }
296
- pause() {
297
- this.runAll("pause");
298
- }
299
- cancel() {
300
- this.runAll("cancel");
301
- }
302
- complete() {
303
- this.runAll("complete");
304
- }
305
- }
306
- class Gt extends Dt {
307
- then(e, r) {
308
- return this.finished.finally(e).then(() => {
309
- });
310
- }
311
- }
312
- function Wt(t) {
313
- return Array.isArray(t) && t.some(Array.isArray);
314
- }
315
- function zt(t) {
316
- function e(r, n, o) {
317
- let c = [];
318
- return Wt(r) ? c = Vt(r, n, t) : c = Ve(r, n, o, t), new Gt(c);
319
- }
320
- return e;
321
- }
322
- const kt = zt(), Er = ["xs", "sm", "md", "lg"], Ar = [
323
- "inProgress",
324
- "executing",
325
- "completed"
326
- ], br = {
327
- ai: ke.ai
328
- }, De = Ye(null);
329
- function Rr({
330
- children: t,
331
- translations: e
332
- }) {
333
- return /* @__PURE__ */ q(De.Provider, { value: e, children: t });
334
- }
335
- function xr() {
336
- const t = $e(De);
337
- if (t === null)
338
- throw new Error(
339
- "useAiChatTranslations must be used within an AiChatTranslationsProvider"
340
- );
341
- return t;
342
- }
343
- function pe(t, e, r, n) {
344
- const o = Math.max(1, Math.min(t, e)), c = Math.min(r, 20), E = Math.min(c + n, o), v = Math.min(E, Math.floor(t / 2)), R = Math.min(E, Math.floor(e / 2)), p = ($) => $ / t * 2 - 1, g = ($) => $ / e * 2 - 1, x = 0, l = t, T = 0, C = e, h = v, L = t - v, I = R, U = e - R, y = p(x), w = p(l), _ = g(T), P = g(C), V = p(h), b = p(L), f = g(I), F = g(U), O = 0, z = 0, W = 1, H = 1, k = v / t, M = 1 - v / t, S = R / e, N = 1 - R / e, K = new Float32Array([
345
- // Top strip
346
- y,
347
- _,
348
- w,
349
- _,
350
- y,
351
- f,
352
- y,
353
- f,
354
- w,
355
- _,
356
- w,
357
- f,
358
- // Bottom strip
359
- y,
360
- F,
361
- w,
362
- F,
363
- y,
364
- P,
365
- y,
366
- P,
367
- w,
368
- F,
369
- w,
370
- P,
371
- // Left strip
372
- y,
373
- f,
374
- V,
375
- f,
376
- y,
377
- F,
378
- y,
379
- F,
380
- V,
381
- f,
382
- V,
383
- F,
384
- // Right strip
385
- b,
386
- f,
387
- w,
388
- f,
389
- b,
390
- F,
391
- b,
392
- F,
393
- w,
394
- f,
395
- w,
396
- F
397
- ]), Z = new Float32Array([
398
- // Top strip
399
- O,
400
- z,
401
- W,
402
- z,
403
- O,
404
- S,
405
- O,
406
- S,
407
- W,
408
- z,
409
- W,
410
- S,
411
- // Bottom strip
412
- O,
413
- N,
414
- W,
415
- N,
416
- O,
417
- H,
418
- O,
419
- H,
420
- W,
421
- N,
422
- W,
423
- H,
424
- // Left strip
425
- O,
426
- S,
427
- k,
428
- S,
429
- O,
430
- N,
431
- O,
432
- N,
433
- k,
434
- S,
435
- k,
436
- N,
437
- // Right strip
438
- M,
439
- S,
440
- W,
441
- S,
442
- M,
443
- N,
444
- M,
445
- N,
446
- W,
447
- S,
448
- W,
449
- N
450
- ]);
451
- return { positions: K, uvs: Z };
452
- }
453
- function ve(t, e, r) {
454
- const n = t.createShader(e);
455
- if (!n) throw new Error("Failed to create shader");
456
- if (t.shaderSource(n, r), t.compileShader(n), !t.getShaderParameter(n, t.COMPILE_STATUS)) {
457
- const o = t.getShaderInfoLog(n) || "Unknown shader error";
458
- throw t.deleteShader(n), new Error(o);
459
- }
460
- return n;
461
- }
462
- function Xt(t, e, r) {
463
- const n = ve(t, t.VERTEX_SHADER, e), o = ve(t, t.FRAGMENT_SHADER, r), c = t.createProgram();
464
- if (!c) throw new Error("Failed to create program");
465
- if (t.attachShader(c, n), t.attachShader(c, o), t.linkProgram(c), !t.getProgramParameter(c, t.LINK_STATUS)) {
466
- const m = t.getProgramInfoLog(c) || "Unknown link error";
467
- throw t.deleteProgram(c), t.deleteShader(n), t.deleteShader(o), new Error(m);
468
- }
469
- return t.deleteShader(n), t.deleteShader(o), c;
470
- }
471
- const Yt = `#version 300 es
472
- precision lowp float;
473
-
474
- in vec2 vUV;
475
- out vec4 outColor;
476
-
477
- uniform vec2 uResolution;
478
- uniform float uTime;
479
- uniform float uBorderWidth;
480
- uniform float uGlowWidth;
481
- uniform float uBorderRadius;
482
- uniform vec3 uColors[4];
483
-
484
- // dark/light mode
485
- uniform float uGlowExponent;
486
- uniform float uGlowFactor;
487
-
488
- const float PI = 3.14159265359;
489
- const float TWO_PI = 2.0 * PI;
490
- const float HALF_PI = 0.5 * PI;
491
-
492
- // Light source parameters (constants)
493
- const vec4 startPositions = vec4(0.0, PI, HALF_PI, 1.5 * PI);
494
- const vec4 speeds = vec4(-1.9, -1.9, -1.5, 2.1);
495
- const vec4 innerRadius = vec4(PI * 0.8, PI * 0.7, PI * 0.3, PI * 0.1);
496
- const vec4 outerRadius = vec4(PI * 1.2, PI * 0.9, PI * 0.6, PI * 0.4);
497
-
498
- /**
499
- * @brief Generates a random float value based on the input 2D coordinates.
500
- * @param st The input 2D coordinates.
501
- * @return float A random float value.
502
- */
503
- float random(vec2 st) {
504
- return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
505
- }
506
-
507
- vec2 random2(vec2 st) {
508
- return vec2(random(st), random(st + 1.0));
509
- }
510
-
511
- /**
512
- * Derivative-based Anti-aliasing
513
- */
514
- float aaStep(float edge, float d) {
515
- // Calculate the width of the anti-aliasing transition
516
- // This is the distance the value changes over one pixel.
517
- float width = fwidth(d);
518
- return smoothstep(edge - width * 0.5, edge + width * 0.5, d);
519
- }
520
-
521
- /**
522
- * @brief Provides an anti-aliased version of fract().
523
- * @param x The input value.
524
- * @return float The anti-aliased fractional part of x.
525
- */
526
- float aaFract(float x) {
527
- float f = fract(x);
528
- float w = fwidth(x); // Get the width of the transition band for one pixel.
529
-
530
- // Use smoothstep to fade the line out as it approaches the 1.0 boundary.
531
- // The fade happens over a distance equal to the pixel width 'w'.
532
- float smooth_f = f * (1.0 - smoothstep(1.0 - w, 1.0, f));
533
-
534
- return smooth_f;
535
- }
536
-
537
- /**
538
- * @name sdRoundedBox
539
- * @description Calculates the signed distance from a point to a rounded rectangle.
540
- * @param {vec2} p - The point coordinates.
541
- * @param {vec2} b - Half the size of the rectangle (half width and half height).
542
- * @param {float} r - The corner radius.
543
- * @returns {float} - Signed distance to the surface of the rounded rectangle.
544
- */
545
- float sdRoundedBox(in vec2 p, in vec2 b, in float r) {
546
- vec2 q = abs(p) - b + r;
547
- return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
548
- }
549
-
550
- /**
551
- * @brief Calculates the smooth inner glow intensity for a rectangle.
552
- * @param p The current pixel coordinate, centered at (0,0).
553
- * @param b The half-dimensions of the rectangle.
554
- * @param radius The radius of the glow/blur.
555
- * @return float The glow intensity, from 0.0 to 1.0.
556
- */
557
- float getInnerGlow(vec2 p, vec2 b, float radius) {
558
- // Check if the pixel is outside the rectangle.
559
- // vec2 d_out = abs(p) - b;
560
- // if (max(d_out.x, d_out.y) > 0.0) {
561
- // return 0.0;
562
- // }
563
-
564
- // Calculate the distance to the nearest vertical and horizontal edges (positive inwards).
565
- float dist_x = b.x - abs(p.x);
566
- float dist_y = b.y - abs(p.y);
567
-
568
- // Calculate the horizontal and vertical glow intensities independently.
569
- float glow_x = smoothstep(radius, 0.0, dist_x);
570
- float glow_y = smoothstep(radius, 0.0, dist_y);
571
-
572
- // Combine the two directional glows using a screen blend mode: 1.0 - (1.0 - a) * (1.0 - b).
573
- return 1.0 - (1.0 - glow_x) * (1.0 - glow_y);
574
- }
575
-
576
- float getVignette(vec2 uv) {
577
- vec2 vignetteUv = uv;
578
- vignetteUv = vignetteUv * (1.0 - vignetteUv);
579
- float vignette = vignetteUv.x * vignetteUv.y * 25.0; // multiply with sth for intensity
580
- vignette = pow(vignette, 0.16); // change pow for modifying the extend of the vignette
581
- // vignette = smoothstep(0.0, 0.7, vignette); // smoothstep to avoid hard edges
582
- vignette = 1.0 - vignette;
583
-
584
- return vignette;
585
- }
586
-
587
- /**
588
- * Convert UV coordinates to angle (0 to 2π) around the border
589
- */
590
- float uvToAngle(vec2 uv) {
591
- vec2 center = vec2(0.5);
592
- vec2 dir = uv - center;
593
- return atan(dir.y, dir.x) + PI;
594
- }
595
-
596
- /**
597
- * Get current light center position (angle) based on start position, speed and time
598
- */
599
- // float getLightCenter(float startPos, float speed, float time) {
600
- // return mod(startPos + speed * time, TWO_PI);
601
- // }
602
-
603
- void main() {
604
- vec2 uv = vUV;
605
- vec2 pos = uv * uResolution;
606
- vec2 centeredPos = pos - uResolution * 0.5;
607
- vec2 size = uResolution - uBorderWidth;
608
- vec2 halfSize = size * 0.5;
609
-
610
- // Calculate the signed distance from the rounded rectangle
611
- float dBorderBox = sdRoundedBox(centeredPos, halfSize, uBorderRadius);
612
- float border = aaStep(0.0, dBorderBox);
613
-
614
- // This will create a gradient mask to safely fade out from borders to inner edges.
615
- float glow = getInnerGlow(centeredPos, halfSize, uGlowWidth);
616
- // glow = smoothstep(0.0, 0.5, glow);
617
- // glow = aaFract(glow * 10.0);
618
-
619
- float vignette = getVignette(uv);
620
- glow *= vignette;
621
-
622
- float posAngle = uvToAngle(uv);
623
-
624
- // vec4 lightCenter = vec4(
625
- // getLightCenter(startPositions.x, speeds.x, uTime),
626
- // getLightCenter(startPositions.y, speeds.y, uTime),
627
- // getLightCenter(startPositions.z, speeds.z, uTime),
628
- // getLightCenter(startPositions.w, speeds.w, uTime)
629
- // );
630
- vec4 lightCenter = mod(startPositions + speeds * uTime, TWO_PI);
631
-
632
- vec4 angleDist = abs(posAngle - lightCenter);
633
-
634
- // Calculate shortest angular distance (considering wrap-around)
635
- vec4 disToLight = min(angleDist, TWO_PI - angleDist) / TWO_PI;
636
-
637
- float intensityBorder[4];
638
- intensityBorder[0] = 1.0;
639
- intensityBorder[1] = smoothstep(0.4, 0.0, disToLight.y);
640
- intensityBorder[2] = smoothstep(0.4, 0.0, disToLight.z);
641
- intensityBorder[3] = smoothstep(0.2, 0.0, disToLight.w) * 0.5;
642
-
643
- // mix these 4 colors with distance
644
- vec3 borderColor = vec3(0.0);
645
- for(int i = 0; i < 4; i++) {
646
- borderColor = mix(borderColor, uColors[i], intensityBorder[i]);
647
- }
648
- borderColor *= 1.1;
649
-
650
- borderColor = clamp(borderColor, 0.0, 1.0);
651
-
652
- float intensityGlow[4];
653
- intensityGlow[0] = smoothstep(0.9, 0.0, disToLight.x);
654
- intensityGlow[1] = smoothstep(0.7, 0.0, disToLight.y);
655
- intensityGlow[2] = smoothstep(0.4, 0.0, disToLight.z);
656
- intensityGlow[3] = smoothstep(0.1, 0.0, disToLight.w) * 0.7;
657
-
658
- // timely breathing effect
659
- vec4 breath = smoothstep(0.0, 1.0, sin(uTime * 1.0 + startPositions * PI) * 0.2 + 0.8);
660
-
661
- vec3 glowColor = vec3(0.0);
662
- glowColor += uColors[0] * intensityGlow[0] * breath.x;
663
- glowColor += uColors[1] * intensityGlow[1] * breath.y;
664
- glowColor += uColors[2] * intensityGlow[2] * breath.z;
665
- glowColor += uColors[3] * intensityGlow[3] * breath.w * glow; // fade it a little bit
666
-
667
- glow = pow(glow, uGlowExponent);
668
- glow *= random(pos + uTime) * 0.1 + 1.0;
669
- glowColor *= glow * uGlowFactor;
670
- glowColor = clamp(glowColor, 0.0, 1.0);
671
-
672
- vec3 color = mix(glowColor, borderColor + glowColor * 0.2, border);
673
-
674
- float alpha = mix(glow, 1.0, border);
675
-
676
- outColor = vec4(color, alpha);
677
- }
678
- `, $t = `#version 300 es
679
-
680
- in vec2 aPosition;
681
- in vec2 aUV;
682
- out vec2 vUV;
683
- void main() {
684
- vUV = aUV;
685
- gl_Position = vec4(aPosition, 0.0, 1.0);
686
- }
687
- `, qt = [
688
- "rgb(229, 25, 67)",
689
- // #E51943 red
690
- "rgb(229, 86, 25)",
691
- // #E55619 orange
692
- "rgb(229, 25, 67)",
693
- // #E51943 red
694
- "rgb(161, 173, 229)"
695
- // #A1ADE5 light blue
696
- ];
697
- function Ht(t) {
698
- const e = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
699
- if (!e)
700
- throw new Error(`Invalid color format: ${t}`);
701
- const [, r, n, o] = e;
702
- return [parseInt(r) / 255, parseInt(n) / 255, parseInt(o) / 255];
703
- }
704
- class Lr {
705
- element;
706
- canvas;
707
- options;
708
- running = !1;
709
- disposed = !1;
710
- startTime = 0;
711
- lastTime = 0;
712
- rafId = null;
713
- glr;
714
- observer;
715
- constructor(e = {}) {
716
- this.options = {
717
- width: e.width ?? 600,
718
- height: e.height ?? 600,
719
- ratio: e.ratio ?? window.devicePixelRatio ?? 1,
720
- borderWidth: e.borderWidth ?? 8,
721
- glowWidth: e.glowWidth ?? 200,
722
- borderRadius: e.borderRadius ?? 8,
723
- mode: e.mode ?? "light",
724
- ...e
725
- }, this.canvas = document.createElement("canvas"), this.options.classNames && (this.canvas.className = this.options.classNames), this.options.styles && Object.assign(this.canvas.style, this.options.styles), this.canvas.style.display = "block", this.canvas.style.transformOrigin = "center", this.canvas.style.pointerEvents = "none", this.element = this.canvas, this.setupGL();
726
- }
727
- start() {
728
- if (this.disposed) throw new Error("Mask instance has been disposed.");
729
- if (this.running) return;
730
- if (!this.glr) {
731
- console.error("WebGL resources are not initialized.");
732
- return;
733
- }
734
- this.running = !0, this.startTime = performance.now(), this.resize(
735
- this.options.width ?? 600,
736
- this.options.height ?? 600,
737
- this.options.ratio
738
- ), this.glr.gl.viewport(0, 0, this.canvas.width, this.canvas.height), this.glr.gl.useProgram(this.glr.program), this.glr.gl.uniform2f(
739
- this.glr.uResolution,
740
- this.canvas.width,
741
- this.canvas.height
742
- ), this.checkGLError(this.glr.gl, "start: after initial setup");
743
- const e = () => {
744
- if (!this.running || !this.glr) return;
745
- this.rafId = requestAnimationFrame(e);
746
- const r = performance.now();
747
- if (r - this.lastTime < 1e3 / 32) return;
748
- this.lastTime = r;
749
- const o = (r - this.startTime) * 1e-3;
750
- this.render(o);
751
- };
752
- this.rafId = requestAnimationFrame(e);
753
- }
754
- pause() {
755
- if (this.disposed) throw new Error("Mask instance has been disposed.");
756
- this.running = !1, this.rafId !== null && cancelAnimationFrame(this.rafId);
757
- }
758
- dispose() {
759
- if (this.disposed) return;
760
- this.disposed = !0, this.running = !1, this.rafId !== null && cancelAnimationFrame(this.rafId);
761
- const { gl: e, vao: r, positionBuffer: n, uvBuffer: o, program: c } = this.glr;
762
- r && e.deleteVertexArray(r), n && e.deleteBuffer(n), o && e.deleteBuffer(o), e.deleteProgram(c), this.observer && this.observer.disconnect(), this.canvas.remove();
763
- }
764
- resize(e, r, n) {
765
- if (this.disposed) throw new Error("Mask instance has been disposed.");
766
- if (this.options.width = e, this.options.height = r, n && (this.options.ratio = n), !this.running) return;
767
- const { gl: o, program: c, vao: m, positionBuffer: E, uvBuffer: v, uResolution: R } = this.glr, p = n ?? this.options.ratio ?? window.devicePixelRatio ?? 1, g = Math.max(1, Math.floor(e * p)), x = Math.max(1, Math.floor(r * p));
768
- this.canvas.style.width = `${e}px`, this.canvas.style.height = `${r}px`, (this.canvas.width !== g || this.canvas.height !== x) && (this.canvas.width = g, this.canvas.height = x), o.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(o, "resize: after viewport setup");
769
- const { positions: l, uvs: T } = pe(
770
- this.canvas.width,
771
- this.canvas.height,
772
- this.options.borderWidth * p,
773
- this.options.glowWidth * p
774
- );
775
- o.bindVertexArray(m), o.bindBuffer(o.ARRAY_BUFFER, E), o.bufferData(o.ARRAY_BUFFER, l, o.STATIC_DRAW);
776
- const C = o.getAttribLocation(c, "aPosition");
777
- o.enableVertexAttribArray(C), o.vertexAttribPointer(C, 2, o.FLOAT, !1, 0, 0), this.checkGLError(o, "resize: after position buffer update"), o.bindBuffer(o.ARRAY_BUFFER, v), o.bufferData(o.ARRAY_BUFFER, T, o.STATIC_DRAW);
778
- const h = o.getAttribLocation(c, "aUV");
779
- o.enableVertexAttribArray(h), o.vertexAttribPointer(h, 2, o.FLOAT, !1, 0, 0), this.checkGLError(o, "resize: after UV buffer update"), o.useProgram(c), o.uniform2f(R, this.canvas.width, this.canvas.height), o.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * p), o.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * p), o.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * p), this.checkGLError(o, "resize: after uniform updates");
780
- const L = performance.now();
781
- this.lastTime = L;
782
- const I = (L - this.startTime) * 1e-3;
783
- this.render(I);
784
- }
785
- /**
786
- * Automatically resizes the canvas to match the dimensions of the given element.
787
- * @note using ResizeObserver
788
- */
789
- autoResize(e) {
790
- this.observer && this.observer.disconnect(), this.observer = new ResizeObserver(() => {
791
- const r = e.getBoundingClientRect();
792
- this.resize(r.width, r.height);
793
- }), this.observer.observe(e);
794
- }
795
- fadeIn() {
796
- if (this.disposed) throw new Error("Mask instance has been disposed.");
797
- return new Promise((e, r) => {
798
- const n = this.canvas.animate(
799
- [
800
- { opacity: 0, transform: "scale(1.2)" },
801
- { opacity: 1, transform: "scale(1)" }
802
- ],
803
- { duration: 300, easing: "ease-out", fill: "forwards" }
804
- );
805
- n.onfinish = () => e(), n.oncancel = () => r("canceled");
806
- });
807
- }
808
- fadeOut() {
809
- if (this.disposed) throw new Error("Mask instance has been disposed.");
810
- return new Promise((e, r) => {
811
- const n = this.canvas.animate(
812
- [
813
- { opacity: 1, transform: "scale(1)" },
814
- { opacity: 0, transform: "scale(1.2)" }
815
- ],
816
- { duration: 300, easing: "ease-in", fill: "forwards" }
817
- );
818
- n.onfinish = () => e(), n.oncancel = () => r("canceled");
819
- });
820
- }
821
- checkGLError(e, r) {
822
- let n = e.getError();
823
- if (n !== e.NO_ERROR)
824
- for (console.error(`WebGL Error in ${r}`); n !== e.NO_ERROR; ) {
825
- const o = this.getGLErrorName(e, n);
826
- console.error(`${o} (0x${n.toString(16)})`), n = e.getError();
827
- }
828
- }
829
- getGLErrorName(e, r) {
830
- switch (r) {
831
- case e.INVALID_ENUM:
832
- return "INVALID_ENUM";
833
- case e.INVALID_VALUE:
834
- return "INVALID_VALUE";
835
- case e.INVALID_OPERATION:
836
- return "INVALID_OPERATION";
837
- case e.INVALID_FRAMEBUFFER_OPERATION:
838
- return "INVALID_FRAMEBUFFER_OPERATION";
839
- case e.OUT_OF_MEMORY:
840
- return "OUT_OF_MEMORY";
841
- case e.CONTEXT_LOST_WEBGL:
842
- return "CONTEXT_LOST_WEBGL";
843
- default:
844
- return "UNKNOWN_ERROR";
845
- }
846
- }
847
- setupGL() {
848
- const e = this.canvas.getContext("webgl2", {
849
- antialias: !1,
850
- alpha: !0
851
- });
852
- if (!e)
853
- throw new Error("WebGL2 is required but not available.");
854
- const r = Xt(e, $t, Yt);
855
- this.checkGLError(e, "setupGL: after createProgram");
856
- const n = e.createVertexArray();
857
- e.bindVertexArray(n), this.checkGLError(e, "setupGL: after VAO creation");
858
- const o = this.canvas.width || 2, c = this.canvas.height || 2, { positions: m, uvs: E } = pe(
859
- o,
860
- c,
861
- this.options.borderWidth,
862
- this.options.glowWidth
863
- ), v = e.createBuffer();
864
- e.bindBuffer(e.ARRAY_BUFFER, v), e.bufferData(e.ARRAY_BUFFER, m, e.STATIC_DRAW);
865
- const R = e.getAttribLocation(r, "aPosition");
866
- e.enableVertexAttribArray(R), e.vertexAttribPointer(R, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
867
- const p = e.createBuffer();
868
- e.bindBuffer(e.ARRAY_BUFFER, p), e.bufferData(e.ARRAY_BUFFER, E, e.STATIC_DRAW);
869
- const g = e.getAttribLocation(r, "aUV");
870
- e.enableVertexAttribArray(g), e.vertexAttribPointer(g, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
871
- const x = e.getUniformLocation(r, "uResolution"), l = e.getUniformLocation(r, "uTime"), T = e.getUniformLocation(r, "uBorderWidth"), C = e.getUniformLocation(r, "uGlowWidth"), h = e.getUniformLocation(r, "uBorderRadius"), L = e.getUniformLocation(r, "uColors"), I = e.getUniformLocation(r, "uGlowExponent"), U = e.getUniformLocation(r, "uGlowFactor");
872
- e.useProgram(r), e.uniform1f(T, this.options.borderWidth), e.uniform1f(C, this.options.glowWidth), e.uniform1f(h, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(I, 2), e.uniform1f(U, 1.8)) : (e.uniform1f(I, 1), e.uniform1f(U, 1));
873
- const y = (this.options.colors || qt).map(Ht);
874
- for (let w = 0; w < y.length; w++)
875
- e.uniform3f(
876
- e.getUniformLocation(r, `uColors[${w}]`),
877
- ...y[w]
878
- );
879
- this.checkGLError(e, "setupGL: after uniform setup"), e.bindVertexArray(null), e.bindBuffer(e.ARRAY_BUFFER, null), this.glr = {
880
- gl: e,
881
- program: r,
882
- vao: n,
883
- positionBuffer: v,
884
- uvBuffer: p,
885
- uResolution: x,
886
- uTime: l,
887
- uBorderWidth: T,
888
- uGlowWidth: C,
889
- uBorderRadius: h,
890
- uColors: L
891
- };
892
- }
893
- render(e) {
894
- if (!this.glr) return;
895
- const { gl: r, program: n, vao: o, uTime: c } = this.glr;
896
- r.useProgram(n), r.bindVertexArray(o), r.uniform1f(c, e), r.disable(r.DEPTH_TEST), r.disable(r.CULL_FACE), r.disable(r.BLEND), r.clearColor(0, 0, 0, 0), r.clear(r.COLOR_BUFFER_BIT), r.drawArrays(r.TRIANGLES, 0, 24), this.checkGLError(r, "render: after draw call"), r.bindVertexArray(null);
897
- }
898
- }
899
- const ge = ["lowp", "mediump", "highp"], Kt = `
900
- void main(void){
901
- vec4 color = vec4(0.0,0.0,0.0,1.0);
902
- mainImage( color, gl_FragCoord.xy );
903
- gl_FragColor = color;
904
- }`, jt = `void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
905
- vec2 uv = fragCoord/iResolution.xy;
906
- vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4));
907
- fragColor = vec4(col,1.0);
908
- }`, we = `attribute vec3 aVertexPosition;
909
- void main(void) {
910
- gl_Position = vec4(aVertexPosition, 1.0);
911
- }`, Te = "iTime", ye = "iTimeDelta", Ee = "iDate", Ae = "iFrame", be = "iMouse", Re = "iResolution", Qt = "iChannel", xe = "iChannelResolution", Le = "iDeviceOrientation";
912
- function Jt(t, e) {
913
- return t.includes("Matrix") && Array.isArray(e);
914
- }
915
- function Zt(t, e) {
916
- return t.includes("v") && Array.isArray(e) && e.length > Number.parseInt(t.charAt(0));
917
- }
918
- function er(t, e) {
919
- return !t.includes("v") && Array.isArray(e) && e.length > Number.parseInt(t.charAt(0));
920
- }
921
- const tr = (t, e, r, n) => {
922
- if (er(r, n))
923
- switch (r) {
924
- case "2f":
925
- return t.uniform2f(e, n[0], n[1]);
926
- case "3f":
927
- return t.uniform3f(e, n[0], n[1], n[2]);
928
- case "4f":
929
- return t.uniform4f(e, n[0], n[1], n[2], n[3]);
930
- case "2i":
931
- return t.uniform2i(e, n[0], n[1]);
932
- case "3i":
933
- return t.uniform3i(e, n[0], n[1], n[2]);
934
- case "4i":
935
- return t.uniform4i(e, n[0], n[1], n[2], n[3]);
936
- }
937
- if (typeof n == "number")
938
- return r === "1i" ? t.uniform1i(e, n) : t.uniform1f(e, n);
939
- switch (r) {
940
- case "1iv":
941
- return t.uniform1iv(e, n);
942
- case "2iv":
943
- return t.uniform2iv(e, n);
944
- case "3iv":
945
- return t.uniform3iv(e, n);
946
- case "4iv":
947
- return t.uniform4iv(e, n);
948
- case "1fv":
949
- return t.uniform1fv(e, n);
950
- case "2fv":
951
- return t.uniform2fv(e, n);
952
- case "3fv":
953
- return t.uniform3fv(e, n);
954
- case "4fv":
955
- return t.uniform4fv(e, n);
956
- case "Matrix2fv":
957
- return t.uniformMatrix2fv(e, !1, n);
958
- case "Matrix3fv":
959
- return t.uniformMatrix3fv(e, !1, n);
960
- case "Matrix4fv":
961
- return t.uniformMatrix4fv(e, !1, n);
962
- }
963
- }, rr = (t) => {
964
- switch (t) {
965
- case "1f":
966
- return "float";
967
- case "2f":
968
- return "vec2";
969
- case "3f":
970
- return "vec3";
971
- case "4f":
972
- return "vec4";
973
- case "1i":
974
- return "int";
975
- case "2i":
976
- return "ivec2";
977
- case "3i":
978
- return "ivec3";
979
- case "4i":
980
- return "ivec4";
981
- case "1iv":
982
- return "int";
983
- case "2iv":
984
- return "ivec2";
985
- case "3iv":
986
- return "ivec3";
987
- case "4iv":
988
- return "ivec4";
989
- case "1fv":
990
- return "float";
991
- case "2fv":
992
- return "vec2";
993
- case "3fv":
994
- return "vec3";
995
- case "4fv":
996
- return "vec4";
997
- case "Matrix2fv":
998
- return "mat2";
999
- case "Matrix3fv":
1000
- return "mat3";
1001
- case "Matrix4fv":
1002
- return "mat4";
1003
- default:
1004
- console.error(
1005
- Y(
1006
- `The uniform type "${t}" is not valid, please make sure your uniform type is valid`
1007
- )
1008
- );
1009
- }
1010
- }, ce = 9729, Se = 9728, nr = 9987, Ie = 33071, _e = 10497;
1011
- class or {
1012
- gl;
1013
- url;
1014
- wrapS;
1015
- wrapT;
1016
- minFilter;
1017
- magFilter;
1018
- source;
1019
- pow2canvas;
1020
- isLoaded = !1;
1021
- isVideo = !1;
1022
- flipY = -1;
1023
- width = 0;
1024
- height = 0;
1025
- _webglTexture = null;
1026
- constructor(e) {
1027
- this.gl = e;
1028
- }
1029
- updateTexture = (e, r, n) => {
1030
- const { gl: o } = this, c = 0, m = o.RGBA, E = o.RGBA, v = o.UNSIGNED_BYTE;
1031
- o.bindTexture(o.TEXTURE_2D, e), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, n), o.texImage2D(
1032
- o.TEXTURE_2D,
1033
- c,
1034
- m,
1035
- E,
1036
- v,
1037
- r
1038
- );
1039
- };
1040
- setupVideo = (e) => {
1041
- const r = document.createElement("video");
1042
- let n = !1, o = !1;
1043
- r.autoplay = !0, r.muted = !0, r.loop = !0, r.crossOrigin = "anonymous";
1044
- const c = () => {
1045
- n && o && (this.isLoaded = !0);
1046
- };
1047
- return r.addEventListener(
1048
- "playing",
1049
- () => {
1050
- n = !0, this.width = r.videoWidth || 0, this.height = r.videoHeight || 0, c();
1051
- },
1052
- !0
1053
- ), r.addEventListener(
1054
- "timeupdate",
1055
- () => {
1056
- o = !0, c();
1057
- },
1058
- !0
1059
- ), r.src = e, r;
1060
- };
1061
- makePowerOf2 = (e) => e instanceof HTMLImageElement || e instanceof HTMLCanvasElement || e instanceof ImageBitmap ? (this.pow2canvas === void 0 && (this.pow2canvas = document.createElement("canvas")), this.pow2canvas.width = 2 ** Math.floor(Math.log(e.width) / Math.LN2), this.pow2canvas.height = 2 ** Math.floor(Math.log(e.height) / Math.LN2), this.pow2canvas.getContext("2d")?.drawImage(
1062
- e,
1063
- 0,
1064
- 0,
1065
- this.pow2canvas.width,
1066
- this.pow2canvas.height
1067
- ), console.warn(
1068
- Y(
1069
- `Image is not power of two ${e.width} x ${e.height}. Resized to ${this.pow2canvas.width} x ${this.pow2canvas.height};`
1070
- )
1071
- ), this.pow2canvas) : e;
1072
- load = async (e) => {
1073
- const { gl: r } = this, {
1074
- url: n,
1075
- wrapS: o,
1076
- wrapT: c,
1077
- minFilter: m,
1078
- magFilter: E,
1079
- flipY: v = -1
1080
- } = e;
1081
- if (!n)
1082
- return Promise.reject(
1083
- new Error(
1084
- Y(
1085
- "Missing url, please make sure to pass the url of your texture { url: ... }"
1086
- )
1087
- )
1088
- );
1089
- const R = /(\.jpg|\.jpeg|\.png|\.gif|\.bmp)$/i.exec(n), p = /(\.mp4|\.3gp|\.webm|\.ogv)$/i.exec(n);
1090
- if (R === null && p === null)
1091
- return Promise.reject(
1092
- new Error(
1093
- Y(
1094
- `Please upload a video or an image with a valid format (url: ${n})`
1095
- )
1096
- )
1097
- );
1098
- Object.assign(this, { url: n, wrapS: o, wrapT: c, minFilter: m, magFilter: E, flipY: v });
1099
- const g = 0, x = r.RGBA, l = 1, T = 1, C = 0, h = r.RGBA, L = r.UNSIGNED_BYTE, I = new Uint8Array([255, 255, 255, 0]), U = r.createTexture();
1100
- if (r.bindTexture(r.TEXTURE_2D, U), r.texImage2D(
1101
- r.TEXTURE_2D,
1102
- g,
1103
- x,
1104
- l,
1105
- T,
1106
- C,
1107
- h,
1108
- L,
1109
- I
1110
- ), p) {
1111
- const P = this.setupVideo(n);
1112
- return r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MIN_FILTER, r.LINEAR), this._webglTexture = U, this.source = P, this.isVideo = !0, P.play().then(() => this);
1113
- }
1114
- async function y() {
1115
- return new Promise((P, V) => {
1116
- const b = new Image();
1117
- b.crossOrigin = "anonymous", b.onload = () => {
1118
- P(b);
1119
- }, b.onerror = () => {
1120
- V(new Error(Y(`failed loading url: ${n}`)));
1121
- }, b.src = n ?? "";
1122
- });
1123
- }
1124
- let w = await y(), _ = (w.width & w.width - 1) === 0 && (w.height & w.height - 1) === 0;
1125
- return (e.wrapS !== Ie || e.wrapT !== Ie || e.minFilter !== Se && e.minFilter !== ce) && !_ && (w = this.makePowerOf2(w), _ = !0), r.bindTexture(r.TEXTURE_2D, U), r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, v), r.texImage2D(
1126
- r.TEXTURE_2D,
1127
- g,
1128
- x,
1129
- h,
1130
- L,
1131
- w
1132
- ), _ && e.minFilter !== Se && e.minFilter !== ce && r.generateMipmap(r.TEXTURE_2D), r.texParameteri(
1133
- r.TEXTURE_2D,
1134
- r.TEXTURE_WRAP_S,
1135
- this.wrapS || _e
1136
- ), r.texParameteri(
1137
- r.TEXTURE_2D,
1138
- r.TEXTURE_WRAP_T,
1139
- this.wrapT || _e
1140
- ), r.texParameteri(
1141
- r.TEXTURE_2D,
1142
- r.TEXTURE_MIN_FILTER,
1143
- this.minFilter || nr
1144
- ), r.texParameteri(
1145
- r.TEXTURE_2D,
1146
- r.TEXTURE_MAG_FILTER,
1147
- this.magFilter || ce
1148
- ), this._webglTexture = U, this.source = w, this.isVideo = !1, this.isLoaded = !0, this.width = w.width || 0, this.height = w.height || 0, this;
1149
- };
1150
- }
1151
- const Y = (t) => `react-shaders: ${t}`, Fe = (t) => {
1152
- if ("changedTouches" in t) {
1153
- const e = t.changedTouches[0];
1154
- return [e?.clientX ?? 0, e?.clientY ?? 0];
1155
- }
1156
- return [t.clientX, t.clientY];
1157
- }, Ce = (t, e, r) => t * (1 - r) + e * r, ir = (t, e, r) => r > 0 ? t.substring(0, r) + e + t.substring(r, t.length) : e + t;
1158
- function sr({
1159
- fs: t,
1160
- vs: e = we,
1161
- textures: r = [],
1162
- uniforms: n,
1163
- clearColor: o = [0, 0, 0, 1],
1164
- precision: c = "highp",
1165
- style: m,
1166
- contextAttributes: E = {},
1167
- lerp: v = 1,
1168
- devicePixelRatio: R = 1,
1169
- onDoneLoadingTextures: p,
1170
- onError: g = console.error,
1171
- onWarning: x = console.warn
1172
- }) {
1173
- const l = B(null), T = B(null), C = B(null), h = B(null), L = B(void 0), I = B(void 0), U = B(!1), y = B(void 0), w = B(0), _ = B([0, 0]), P = B([]), V = B(0), b = B(void 0), f = B({
1174
- [Te]: { type: "float", isNeeded: !1, value: 0 },
1175
- [ye]: { type: "float", isNeeded: !1, value: 0 },
1176
- [Ee]: { type: "vec4", isNeeded: !1, value: [0, 0, 0, 0] },
1177
- [be]: { type: "vec4", isNeeded: !1, value: [0, 0, 0, 0] },
1178
- [Re]: { type: "vec2", isNeeded: !1, value: [0, 0] },
1179
- [Ae]: { type: "int", isNeeded: !1, value: 0 },
1180
- [Le]: {
1181
- type: "vec4",
1182
- isNeeded: !1,
1183
- value: [0, 0, 0, 0]
1184
- }
1185
- }), F = B(n), O = (i, a) => {
1186
- const s = "width" in i ? i.width ?? 0 : 0, d = "height" in i ? i.height ?? 0 : 0, u = f.current.iChannelResolution;
1187
- if (!u) return;
1188
- const A = Array.isArray(u.value) ? u.value : u.value = [];
1189
- A[a * 3] = s * R, A[a * 3 + 1] = d * R, A[a * 3 + 2] = 0;
1190
- }, z = () => {
1191
- l.current && (T.current = l.current.getContext("webgl", E) || l.current.getContext(
1192
- "experimental-webgl",
1193
- E
1194
- ), T.current?.getExtension("OES_standard_derivatives"), T.current?.getExtension("EXT_shader_texture_lod"));
1195
- }, W = () => {
1196
- const i = T.current;
1197
- C.current = i?.createBuffer() ?? null, i?.bindBuffer(i.ARRAY_BUFFER, C.current);
1198
- const a = [
1199
- 1,
1200
- 1,
1201
- 0,
1202
- -1,
1203
- 1,
1204
- 0,
1205
- 1,
1206
- -1,
1207
- 0,
1208
- -1,
1209
- -1,
1210
- 0
1211
- ];
1212
- i?.bufferData(i.ARRAY_BUFFER, new Float32Array(a), i.STATIC_DRAW);
1213
- }, H = ({
1214
- alpha: i,
1215
- beta: a,
1216
- gamma: s
1217
- }) => {
1218
- f.current.iDeviceOrientation.value = [
1219
- i ?? 0,
1220
- a ?? 0,
1221
- s ?? 0,
1222
- window.orientation ?? 0
1223
- ];
1224
- }, k = (i) => {
1225
- const [a = 0, s = 0] = Fe(i), d = a - (y.current?.left ?? 0) - window.pageXOffset, u = (y.current?.height ?? 0) - s - (y.current?.top ?? 0) - window.pageYOffset;
1226
- U.current = !0;
1227
- const A = Array.isArray(f.current.iMouse?.value) ? f.current.iMouse.value : void 0;
1228
- A && (A[2] = d, A[3] = u), _.current[0] = d, _.current[1] = u;
1229
- }, M = (i) => {
1230
- y.current = l.current?.getBoundingClientRect();
1231
- const [a = 0, s = 0] = Fe(i), d = a - (y.current?.left ?? 0), u = (y.current?.height ?? 0) - s - (y.current?.top ?? 0);
1232
- if (v !== 1)
1233
- _.current[0] = d, _.current[1] = u;
1234
- else {
1235
- const A = Array.isArray(f.current.iMouse?.value) ? f.current.iMouse.value : void 0;
1236
- A && (A[0] = d, A[1] = u);
1237
- }
1238
- }, S = () => {
1239
- const i = Array.isArray(f.current.iMouse?.value) ? f.current.iMouse.value : void 0;
1240
- i && (i[2] = 0, i[3] = 0);
1241
- }, N = () => {
1242
- const i = T.current;
1243
- if (!i) return;
1244
- y.current = l.current?.getBoundingClientRect();
1245
- const a = R, s = Math.floor(
1246
- (y.current?.width ?? 1) * a
1247
- ), d = Math.floor(
1248
- (y.current?.height ?? 1) * a
1249
- );
1250
- if (i.canvas.width = s, i.canvas.height = d, f.current.iResolution?.isNeeded && h.current) {
1251
- const u = i.getUniformLocation(
1252
- h.current,
1253
- Re
1254
- );
1255
- i.uniform2fv(u, [i.canvas.width, i.canvas.height]);
1256
- }
1257
- }, K = (i, a) => {
1258
- const s = T.current;
1259
- if (!s) return null;
1260
- const d = s.createShader(i);
1261
- if (!d) return null;
1262
- if (s.shaderSource(d, a), s.compileShader(d), !s.getShaderParameter(d, s.COMPILE_STATUS)) {
1263
- x?.(Y(`Error compiling the shader:
1264
- ${a}`));
1265
- const u = s.getShaderInfoLog(d);
1266
- s.deleteShader(d), g?.(Y(`Shader compiler log: ${u}`));
1267
- }
1268
- return d;
1269
- }, Z = (i, a) => {
1270
- const s = T.current;
1271
- if (!s) return;
1272
- const d = K(s.FRAGMENT_SHADER, i), u = K(s.VERTEX_SHADER, a);
1273
- if (h.current = s.createProgram(), !(!h.current || !u || !d)) {
1274
- if (s.attachShader(h.current, u), s.attachShader(h.current, d), s.linkProgram(h.current), !s.getProgramParameter(h.current, s.LINK_STATUS)) {
1275
- g?.(
1276
- Y(
1277
- `Unable to initialize the shader program: ${s.getProgramInfoLog(
1278
- h.current
1279
- )}`
1280
- )
1281
- );
1282
- return;
1283
- }
1284
- s.useProgram(h.current), L.current = s.getAttribLocation(
1285
- h.current,
1286
- "aVertexPosition"
1287
- ), s.enableVertexAttribArray(L.current);
1288
- }
1289
- }, $ = () => {
1290
- if (n)
1291
- for (const i of Object.keys(n)) {
1292
- const a = n[i];
1293
- if (!a) continue;
1294
- const { value: s, type: d } = a, u = rr(d);
1295
- if (!u) continue;
1296
- const A = {};
1297
- if (Jt(d, s)) {
1298
- const D = d.length, X = Number.parseInt(d.charAt(D - 3)), te = Math.floor(s.length / (X * X));
1299
- s.length > X * X && (A.arraySize = `[${te}]`);
1300
- } else Zt(d, s) && (A.arraySize = `[${Math.floor(s.length / Number.parseInt(d.charAt(0)))}]`);
1301
- f.current[i] = {
1302
- type: u,
1303
- isNeeded: !1,
1304
- value: s,
1305
- ...A
1306
- };
1307
- }
1308
- }, re = () => {
1309
- const i = T.current;
1310
- if (i)
1311
- if (r && r.length > 0) {
1312
- f.current[`${xe}`] = {
1313
- type: "vec3",
1314
- isNeeded: !1,
1315
- arraySize: `[${r.length}]`,
1316
- value: []
1317
- };
1318
- const a = r.map(
1319
- (s, d) => (f.current[`${Qt}${d}`] = {
1320
- type: "sampler2D",
1321
- isNeeded: !1
1322
- }, O(s, d), P.current[d] = new or(i), P.current[d]?.load(s).then((u) => {
1323
- O(u, d);
1324
- }))
1325
- );
1326
- Promise.all(a).then(() => {
1327
- p && p();
1328
- }).catch((s) => {
1329
- g?.(s), p && p();
1330
- });
1331
- } else p && p();
1332
- }, ne = (i) => {
1333
- const a = ge.includes(c ?? "highp"), s = `precision ${a ? c : ge[1]} float;
1334
- `;
1335
- a || x?.(
1336
- Y(
1337
- `wrong precision type ${c}, please make sure to pass one of a valid precision lowp, mediump, highp, by default you shader precision will be set to highp.`
1338
- )
1339
- );
1340
- let d = s.concat(`#define DPR ${R.toFixed(1)}
1341
- `).concat(i.replace(/texture\(/g, "texture2D("));
1342
- for (const A of Object.keys(f.current))
1343
- if (i.includes(A)) {
1344
- const D = f.current[A];
1345
- if (!D) continue;
1346
- d = ir(
1347
- d,
1348
- `uniform ${D.type} ${A}${D.arraySize || ""};
1349
- `,
1350
- d.lastIndexOf(s) + s.length
1351
- ), D.isNeeded = !0;
1352
- }
1353
- return i.includes("mainImage") && (d = d.concat(Kt)), d;
1354
- }, j = (i) => {
1355
- const a = T.current;
1356
- if (!a || !h.current) return;
1357
- const s = V.current ? (i - V.current) / 1e3 : 0;
1358
- V.current = i;
1359
- const d = F.current;
1360
- if (d)
1361
- for (const u of Object.keys(d)) {
1362
- const A = d[u];
1363
- if (A && f.current[u]?.isNeeded) {
1364
- if (!h.current) return;
1365
- const D = a.getUniformLocation(
1366
- h.current,
1367
- u
1368
- );
1369
- if (!D) return;
1370
- tr(
1371
- a,
1372
- D,
1373
- A.type,
1374
- A.value
1375
- );
1376
- }
1377
- }
1378
- if (f.current.iMouse?.isNeeded) {
1379
- const u = a.getUniformLocation(
1380
- h.current,
1381
- be
1382
- );
1383
- a.uniform4fv(u, f.current.iMouse.value);
1384
- }
1385
- if (f.current.iChannelResolution?.isNeeded) {
1386
- const u = a.getUniformLocation(
1387
- h.current,
1388
- xe
1389
- );
1390
- a.uniform3fv(
1391
- u,
1392
- f.current.iChannelResolution.value
1393
- );
1394
- }
1395
- if (f.current.iDeviceOrientation?.isNeeded) {
1396
- const u = a.getUniformLocation(
1397
- h.current,
1398
- Le
1399
- );
1400
- a.uniform4fv(
1401
- u,
1402
- f.current.iDeviceOrientation.value
1403
- );
1404
- }
1405
- if (f.current.iTime?.isNeeded) {
1406
- const u = a.getUniformLocation(
1407
- h.current,
1408
- Te
1409
- );
1410
- a.uniform1f(u, w.current += s);
1411
- }
1412
- if (f.current.iTimeDelta?.isNeeded) {
1413
- const u = a.getUniformLocation(
1414
- h.current,
1415
- ye
1416
- );
1417
- a.uniform1f(u, s);
1418
- }
1419
- if (f.current.iDate?.isNeeded) {
1420
- const u = /* @__PURE__ */ new Date(), A = u.getMonth() + 1, D = u.getDate(), X = u.getFullYear(), te = u.getHours() * 60 * 60 + u.getMinutes() * 60 + u.getSeconds() + u.getMilliseconds() * 1e-3, ae = a.getUniformLocation(
1421
- h.current,
1422
- Ee
1423
- );
1424
- a.uniform4fv(ae, [X, A, D, te]);
1425
- }
1426
- if (f.current.iFrame?.isNeeded) {
1427
- const u = a.getUniformLocation(
1428
- h.current,
1429
- Ae
1430
- ), A = f.current.iFrame.value;
1431
- a.uniform1i(u, A), f.current.iFrame.value = A + 1;
1432
- }
1433
- if (P.current.length > 0)
1434
- for (let u = 0; u < P.current.length; u++) {
1435
- const A = P.current[u];
1436
- if (!A) return;
1437
- const { isVideo: D, _webglTexture: X, source: te, flipY: ae, isLoaded: We } = A;
1438
- if (!We || !X || !te) return;
1439
- if (f.current[`iChannel${u}`]?.isNeeded) {
1440
- if (!h.current) return;
1441
- const ze = a.getUniformLocation(
1442
- h.current,
1443
- `iChannel${u}`
1444
- );
1445
- a.activeTexture(a.TEXTURE0 + u), a.bindTexture(a.TEXTURE_2D, X), a.uniform1i(ze, u), D && A.updateTexture(
1446
- X,
1447
- te,
1448
- ae
1449
- );
1450
- }
1451
- }
1452
- }, Q = (i) => {
1453
- const a = T.current;
1454
- if (!a) return;
1455
- a.viewport(0, 0, a.drawingBufferWidth, a.drawingBufferHeight), a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT), a.bindBuffer(a.ARRAY_BUFFER, C.current), a.vertexAttribPointer(
1456
- L.current ?? 0,
1457
- 3,
1458
- a.FLOAT,
1459
- !1,
1460
- 0,
1461
- 0
1462
- ), j(i), a.drawArrays(a.TRIANGLE_STRIP, 0, 4);
1463
- const s = f.current.iMouse?.value;
1464
- if (f.current.iMouse?.isNeeded && v !== 1 && Array.isArray(s)) {
1465
- const d = s[0] ?? 0, u = s[1] ?? 0;
1466
- s[0] = Ce(d, _.current[0] ?? 0, v), s[1] = Ce(u, _.current[1] ?? 0, v);
1467
- }
1468
- I.current = requestAnimationFrame(Q);
1469
- }, ee = () => {
1470
- const i = { passive: !0 };
1471
- f.current.iMouse?.isNeeded && l.current && (l.current.addEventListener("mousemove", M, i), l.current.addEventListener("mouseout", S, i), l.current.addEventListener("mouseup", S, i), l.current.addEventListener("mousedown", k, i), l.current.addEventListener("touchmove", M, i), l.current.addEventListener("touchend", S, i), l.current.addEventListener("touchstart", k, i)), f.current.iDeviceOrientation?.isNeeded && window.addEventListener(
1472
- "deviceorientation",
1473
- H,
1474
- i
1475
- ), l.current && (b.current = new ResizeObserver(N), b.current.observe(l.current), window.addEventListener("resize", N, i));
1476
- }, J = () => {
1477
- const i = { passive: !0 };
1478
- f.current.iMouse?.isNeeded && l.current && (l.current.removeEventListener("mousemove", M, i), l.current.removeEventListener("mouseout", S, i), l.current.removeEventListener("mouseup", S, i), l.current.removeEventListener("mousedown", k, i), l.current.removeEventListener("touchmove", M, i), l.current.removeEventListener("touchend", S, i), l.current.removeEventListener("touchstart", k, i)), f.current.iDeviceOrientation?.isNeeded && window.removeEventListener(
1479
- "deviceorientation",
1480
- H,
1481
- i
1482
- ), b.current && (b.current.disconnect(), window.removeEventListener("resize", N, i));
1483
- };
1484
- return ie(() => {
1485
- F.current = n;
1486
- }, [n]), ie(() => {
1487
- const i = P.current;
1488
- function a() {
1489
- z();
1490
- const s = T.current;
1491
- s && l.current && (s.clearColor(...o), s.clearDepth(1), s.enable(s.DEPTH_TEST), s.depthFunc(s.LEQUAL), s.viewport(0, 0, l.current.width, l.current.height), l.current.height = l.current.clientHeight, l.current.width = l.current.clientWidth, $(), re(), Z(ne(t || jt), e || we), W(), requestAnimationFrame(Q), ee(), N());
1492
- }
1493
- return requestAnimationFrame(a), () => {
1494
- const s = T.current;
1495
- if (s) {
1496
- if (s.getExtension("WEBGL_lose_context")?.loseContext(), s.useProgram(null), s.deleteProgram(h.current ?? null), i.length > 0)
1497
- for (const d of i)
1498
- s.deleteTexture(d._webglTexture);
1499
- h.current = null;
1500
- }
1501
- J(), cancelAnimationFrame(I.current ?? 0);
1502
- };
1503
- }, []), /* @__PURE__ */ q(
1504
- "canvas",
1505
- {
1506
- ref: l,
1507
- style: { height: "100%", width: "100%", ...m }
1508
- }
1509
- );
1510
- }
1511
- const ar = `
1512
- const float TAU = 6.283185;
1513
-
1514
- // Noise for dithering
1515
- vec2 randFibo(vec2 p) {
1516
- p = fract(p * vec2(443.897, 441.423));
1517
- p += dot(p, p.yx + 19.19);
1518
- return fract((p.xx + p.yx) * p.xy);
1519
- }
1520
-
1521
- // Tonemap
1522
- vec3 Tonemap(vec3 x) {
1523
- x *= 4.0;
1524
- return x / (1.0 + x);
1525
- }
1526
-
1527
- // Luma for alpha
1528
- float luma(vec3 color) {
1529
- return dot(color, vec3(0.299, 0.587, 0.114));
1530
- }
1531
-
1532
- // RGB to HSV
1533
- vec3 rgb2hsv(vec3 c) {
1534
- vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
1535
- vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
1536
- vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
1537
- float d = q.x - min(q.w, q.y);
1538
- float e = 1.0e-10;
1539
- return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
1540
- }
1541
-
1542
- // HSV to RGB
1543
- vec3 hsv2rgb(vec3 c) {
1544
- vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
1545
- vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
1546
- return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
1547
- }
1548
-
1549
- // SDF shapes
1550
- float sdCircle(vec2 st, float r) {
1551
- return length(st) - r;
1552
- }
1553
-
1554
- float sdLine(vec2 p, float r) {
1555
- float halfLen = r * 2.0;
1556
- vec2 a = vec2(-halfLen, 0.0);
1557
- vec2 b = vec2(halfLen, 0.0);
1558
- vec2 pa = p - a;
1559
- vec2 ba = b - a;
1560
- float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
1561
- return length(pa - ba * h);
1562
- }
1563
-
1564
- float getSdf(vec2 st) {
1565
- if(uShape == 1.0) return sdCircle(st, uScale);
1566
- else if(uShape == 2.0) return sdLine(st, uScale);
1567
- return sdCircle(st, uScale); // Default
1568
- }
1569
-
1570
- vec2 turb(vec2 pos, float t, float it) {
1571
- // Initial rotation matrix for swirl direction
1572
- mat2 rotation = mat2(0.6, -0.25, 0.25, 0.9);
1573
- // Secondary rotation applied each iteration (approx 53 degree rotation)
1574
- mat2 layerRotation = mat2(0.6, -0.8, 0.8, 0.6);
1575
-
1576
- float frequency = mix(2.0, 15.0, uFrequency);
1577
- float amplitude = uAmplitude;
1578
- float frequencyGrowth = 1.4;
1579
- float animTime = t * 0.1 * uSpeed;
1580
-
1581
- const int LAYERS = 4;
1582
- for(int i = 0; i < LAYERS; i++) {
1583
- // Calculate wave displacement for this layer
1584
- vec2 rotatedPos = pos * rotation;
1585
- vec2 wave = sin(frequency * rotatedPos + float(i) * animTime + it);
1586
-
1587
- // Apply displacement along rotation direction
1588
- pos += (amplitude / frequency) * rotation[0] * wave;
1589
-
1590
- // Evolve parameters for next layer
1591
- rotation *= layerRotation;
1592
- amplitude *= mix(1.0, max(wave.x, wave.y), uVariance);
1593
- frequency *= frequencyGrowth;
1594
- }
1595
-
1596
- return pos;
1597
- }
1598
-
1599
- const float ITERATIONS = 36.0;
1600
-
1601
- void mainImage(out vec4 fragColor, in vec2 fragCoord) {
1602
- vec2 uv = fragCoord / iResolution.xy;
1603
-
1604
- vec3 pp = vec3(0.0);
1605
- vec3 bloom = vec3(0.0);
1606
- float t = iTime * 0.5;
1607
- vec2 pos = uv - 0.5;
1608
-
1609
- vec2 prevPos = turb(pos, t, 0.0 - 1.0 / ITERATIONS);
1610
- float spacing = mix(1.0, TAU, uSpacing);
1611
-
1612
- for(float i = 1.0; i < ITERATIONS + 1.0; i++) {
1613
- float iter = i / ITERATIONS;
1614
- vec2 st = turb(pos, t, iter * spacing);
1615
- float d = abs(getSdf(st));
1616
- float pd = distance(st, prevPos);
1617
- prevPos = st;
1618
- float dynamicBlur = exp2(pd * 2.0 * 1.4426950408889634) - 1.0;
1619
- float ds = smoothstep(0.0, uBlur * 0.05 + max(dynamicBlur * uSmoothing, 0.001), d);
1620
-
1621
- // Shift color based on iteration using uColorScale
1622
- vec3 color = uColor;
1623
- if(uColorShift > 0.01) {
1624
- vec3 hsv = rgb2hsv(color);
1625
- // Shift hue by iteration
1626
- hsv.x = fract(hsv.x + (1.0 - iter) * uColorShift * 0.3);
1627
- color = hsv2rgb(hsv);
1628
- }
1629
-
1630
- float invd = 1.0 / max(d + dynamicBlur, 0.001);
1631
- pp += (ds - 1.0) * color;
1632
- bloom += clamp(invd, 0.0, 250.0) * color;
1633
- }
1634
-
1635
- pp *= 1.0 / ITERATIONS;
1636
-
1637
- vec3 color;
1638
-
1639
- // Dark mode (default)
1640
- if(uMode < 0.5) {
1641
- // use bloom effect
1642
- bloom = bloom / (bloom + 2e4);
1643
- color = (-pp + bloom * 3.0 * uBloom) * 1.2;
1644
- color += (randFibo(fragCoord).x - 0.5) / 255.0;
1645
- color = Tonemap(color);
1646
- float alpha = luma(color) * uMix;
1647
- fragColor = vec4(color * uMix, alpha);
1648
- }
1649
-
1650
- // Light mode
1651
- else {
1652
- // no bloom effect
1653
- color = -pp;
1654
- color += (randFibo(fragCoord).x - 0.5) / 255.0;
1655
-
1656
- // Preserve hue by tone mapping brightness only
1657
- float brightness = length(color);
1658
- vec3 direction = brightness > 0.0 ? color / brightness : color;
1659
-
1660
- // Reinhard on brightness
1661
- float factor = 2.0;
1662
- float mappedBrightness = (brightness * factor) / (1.0 + brightness * factor);
1663
- color = direction * mappedBrightness;
1664
-
1665
- // Boost saturation to compensate for white background bleed-through
1666
- // When alpha < 1.0, white bleeds through making colors look desaturated
1667
- // So we increase saturation to maintain vibrant appearance
1668
- float gray = dot(color, vec3(0.2, 0.5, 0.1));
1669
- float saturationBoost = 3.0;
1670
- color = mix(vec3(gray), color, saturationBoost);
1671
-
1672
- // Clamp between 0-1
1673
- color = clamp(color, 0.0, 1.0);
1674
-
1675
- float alpha = mappedBrightness * clamp(uMix, 1.0, 2.0);
1676
- fragColor = vec4(color, alpha);
1677
- }
1678
- }`, cr = 10, ur = 2, lr = 0.5, fr = 0.2, dr = 1.5, G = {
1679
- duration: 0.5,
1680
- ease: "easeOut"
1681
- }, Pe = {
1682
- duration: 0.35,
1683
- ease: "easeOut",
1684
- repeat: 1 / 0,
1685
- repeatType: "mirror"
1686
- };
1687
- function oe(t) {
1688
- const [e, r] = Ue(t), n = mt(t), o = B(null);
1689
- Tt(n, "change", (m) => r(m));
1690
- const c = qe(
1691
- (m, E) => {
1692
- o.current = kt(n, m, E);
1693
- },
1694
- [n]
1695
- );
1696
- return { value: e, motionValue: n, controls: o, animate: c };
1697
- }
1698
- function hr(t, e) {
1699
- const [r, n] = Ue(cr), {
1700
- value: o,
1701
- animate: c,
1702
- motionValue: m
1703
- } = oe(fr), { value: E, animate: v } = oe(ur), { value: R, animate: p } = oe(lr), { value: g, animate: x } = oe(dr), l = wt(e, {
1704
- fftSize: 512,
1705
- smoothingTimeConstant: 0.55
1706
- });
1707
- return ie(() => {
1708
- switch (t) {
1709
- case "idle":
1710
- case "failed":
1711
- case "disconnected":
1712
- n(10), c(0.2, G), v(1.2, G), p(0.4, G), x(1, G);
1713
- return;
1714
- case "listening":
1715
- case "pre-connect-buffering":
1716
- n(20), c(0.3, { type: "spring", duration: 1, bounce: 0.35 }), v(1, G), p(0.7, G), x([1.5, 2], Pe);
1717
- return;
1718
- case "thinking":
1719
- case "connecting":
1720
- case "initializing":
1721
- n(30), c(0.3, G), v(0.5, G), p(1, G), x([0.5, 2.5], Pe);
1722
- return;
1723
- case "speaking":
1724
- n(70), c(0.3, G), v(0.75, G), p(1.25, G), x(1.5, G);
1725
- return;
1726
- }
1727
- }, [
1728
- t,
1729
- c,
1730
- v,
1731
- p,
1732
- x
1733
- ]), ie(() => {
1734
- t === "speaking" && l > 0 && !m.isAnimating() && c(0.2 + 0.2 * l, { duration: 0 });
1735
- }, [
1736
- t,
1737
- l,
1738
- m,
1739
- c,
1740
- v,
1741
- p,
1742
- x
1743
- ]), {
1744
- speed: r,
1745
- scale: o,
1746
- amplitude: E,
1747
- frequency: R,
1748
- brightness: g
1749
- };
1750
- }
1751
- const mr = vt({
1752
- base: "aspect-square",
1753
- variants: {
1754
- size: {
1755
- icon: "h-[24px]",
1756
- sm: "h-[56px]",
1757
- md: "h-[112px]",
1758
- lg: "h-[224px]",
1759
- xl: "h-[448px]"
1760
- }
1761
- },
1762
- defaultVariants: {
1763
- size: "lg"
1764
- }
1765
- });
1766
- function pr(t) {
1767
- const e = t.match(
1768
- /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1769
- );
1770
- if (e) {
1771
- const [, r, n, o] = e;
1772
- return [r, n, o].map((m = "00") => parseInt(m, 16) / 255);
1773
- }
1774
- }
1775
- function Ge({
1776
- shape: t = 1,
1777
- speed: e = 1,
1778
- amplitude: r = 0.5,
1779
- frequency: n = 0.5,
1780
- scale: o = 0.2,
1781
- blur: c = 1,
1782
- color: m = "#FF355E",
1783
- colorShift: E = 1,
1784
- brightness: v = 1,
1785
- themeMode: R = typeof window < "u" && document.documentElement.classList.contains("dark") ? "dark" : "light",
1786
- ref: p,
1787
- className: g,
1788
- ...x
1789
- }) {
1790
- const l = He(() => pr(m), [m]);
1791
- return /* @__PURE__ */ q("div", { ref: p, className: g, ...x, children: /* @__PURE__ */ q(
1792
- sr,
1793
- {
1794
- fs: ar,
1795
- devicePixelRatio: globalThis.devicePixelRatio ?? 1,
1796
- uniforms: {
1797
- // Aurora wave speed
1798
- uSpeed: { type: "1f", value: e },
1799
- // Edge blur/softness
1800
- uBlur: { type: "1f", value: c },
1801
- // Shape scale
1802
- uScale: { type: "1f", value: o },
1803
- // Shape type: 1=circle, 2=line
1804
- uShape: { type: "1f", value: t },
1805
- // Wave frequency and complexity
1806
- uFrequency: { type: "1f", value: n },
1807
- // Turbulence amplitude
1808
- uAmplitude: { type: "1f", value: r },
1809
- // Light intensity (bloom)
1810
- uBloom: { type: "1f", value: 0 },
1811
- // Brightness of the aurora (0-1)
1812
- uMix: { type: "1f", value: v },
1813
- // Color variation across layers (0-1)
1814
- uSpacing: { type: "1f", value: 0.5 },
1815
- // Color palette offset - shifts colors along the gradient (0-1)
1816
- uColorShift: { type: "1f", value: E },
1817
- // Color variation across layers (0-1)
1818
- uVariance: { type: "1f", value: 0.1 },
1819
- // Smoothing of the aurora (0-1)
1820
- uSmoothing: { type: "1f", value: 1 },
1821
- // Display mode: 0=dark background, 1=light background
1822
- uMode: { type: "1f", value: R === "light" ? 1 : 0 },
1823
- // Color
1824
- uColor: { type: "3fv", value: l ?? [0, 0.7, 1] }
1825
- },
1826
- onError: (T) => {
1827
- console.error("Shader error:", T);
1828
- },
1829
- onWarning: (T) => {
1830
- console.warn("Shader warning:", T);
1831
- },
1832
- style: { width: "100%", height: "100%" }
1833
- }
1834
- ) });
1835
- }
1836
- Ge.displayName = "AuraShader";
1837
- function Sr({
1838
- size: t = "lg",
1839
- state: e,
1840
- color: r,
1841
- colorShift: n = 0.05,
1842
- audioTrack: o,
1843
- themeMode: c,
1844
- className: m,
1845
- ref: E,
1846
- ...v
1847
- }) {
1848
- const { speed: R, scale: p, amplitude: g, frequency: x, brightness: l } = hr(e, o);
1849
- return /* @__PURE__ */ q(
1850
- Ge,
1851
- {
1852
- ref: E,
1853
- blur: 0.2,
1854
- color: r,
1855
- colorShift: n,
1856
- speed: R,
1857
- scale: p,
1858
- themeMode: c,
1859
- amplitude: g,
1860
- frequency: x,
1861
- brightness: l,
1862
- className: pt(
1863
- mr({ size: t }),
1864
- "overflow-hidden rounded-full",
1865
- m
1866
- ),
1867
- ...v
1868
- }
1869
- );
1870
- }
1871
- const Ir = ({
1872
- text: t,
1873
- confirmationText: e,
1874
- onConfirm: r,
1875
- cancelText: n,
1876
- onCancel: o
1877
- }) => /* @__PURE__ */ le("div", { className: "flex flex-col gap-2", children: [
1878
- t && /* @__PURE__ */ q("p", { children: t }),
1879
- /* @__PURE__ */ le("div", { className: "flex gap-2", children: [
1880
- /* @__PURE__ */ q(
1881
- fe,
1882
- {
1883
- type: "button",
1884
- variant: "outline",
1885
- size: "sm",
1886
- icon: gt,
1887
- onClick: r,
1888
- label: e
1889
- }
1890
- ),
1891
- /* @__PURE__ */ q(
1892
- fe,
1893
- {
1894
- type: "button",
1895
- variant: "ghost",
1896
- size: "sm",
1897
- onClick: o,
1898
- label: n
1899
- }
1900
- )
1901
- ] })
1902
- ] });
1903
- export {
1904
- Rr as A,
1905
- Lr as F,
1906
- br as a,
1907
- Ar as b,
1908
- Sr as c,
1909
- Ir as d,
1910
- Er as o,
1911
- xr as u
1912
- };