ai-wrapped 1.9.0 → 1.11.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.
@@ -0,0 +1,221 @@
1
+ import{r as k,j as Q}from"./index-BiLDfPwS.js";const He=`#version 300 es
2
+ in vec2 aPosition;
3
+ uniform vec2 uTexel;
4
+ out vec2 vUv;
5
+ out vec2 vL;
6
+ out vec2 vR;
7
+ out vec2 vT;
8
+ out vec2 vB;
9
+ void main() {
10
+ vUv = aPosition * 0.5 + 0.5;
11
+ vL = vUv - vec2(uTexel.x, 0.0);
12
+ vR = vUv + vec2(uTexel.x, 0.0);
13
+ vT = vUv + vec2(0.0, uTexel.y);
14
+ vB = vUv - vec2(0.0, uTexel.y);
15
+ gl_Position = vec4(aPosition, 0.0, 1.0);
16
+ }`,U=`#version 300 es
17
+ precision highp float;
18
+ precision highp sampler2D;
19
+ in vec2 vUv;
20
+ in vec2 vL;
21
+ in vec2 vR;
22
+ in vec2 vT;
23
+ in vec2 vB;
24
+ out vec4 outColor;
25
+ `,We=`${U}
26
+ uniform sampler2D uTarget;
27
+ uniform float uAspect;
28
+ uniform vec2 uA;
29
+ uniform vec2 uB;
30
+ uniform float uRadius;
31
+ uniform float uWide;
32
+ uniform vec3 uValue;
33
+ uniform float uMode;
34
+ uniform float uStrength;
35
+ float erf(float x) {
36
+ float x2 = x * x;
37
+ float a = 0.147;
38
+ return sign(x) * sqrt(1.0 - exp(-x2 * (1.2732395 + a * x2) / (1.0 + a * x2)));
39
+ }
40
+ float sweep(float along, float length, float across, float radius) {
41
+ return exp(-across * across / (radius * radius)) * 0.5 * (erf(along / radius) - erf((along - length) / radius));
42
+ }
43
+ void main() {
44
+ vec2 p = vec2(vUv.x * uAspect, vUv.y);
45
+ vec2 a = vec2(uA.x * uAspect, uA.y);
46
+ vec2 ab = vec2(uB.x * uAspect, uB.y) - a;
47
+ float len = length(ab);
48
+ vec2 dir = len > 1e-6 ? ab / len : vec2(1.0, 0.0);
49
+ vec2 ap = p - a;
50
+ vec3 base = texture(uTarget, vUv).xyz;
51
+ if (uMode > 1.5) {
52
+ float along = dot(ap, dir);
53
+ float across = dot(ap, vec2(-dir.y, dir.x));
54
+ if (uMode > 2.5) {
55
+ outColor = vec4(mix(base, uValue, sweep(along, len, across, uRadius) * uStrength), 1.0);
56
+ return;
57
+ }
58
+ vec3 add = vec3(uValue.xy * sweep(along, len, across, uRadius), uValue.z * sweep(along, len, across, uWide));
59
+ outColor = vec4(base + add, 1.0);
60
+ return;
61
+ }
62
+ float h = clamp(dot(ap, ab) / max(dot(ab, ab), 1e-9), 0.0, 1.0);
63
+ vec2 d = ap - ab * h;
64
+ float r2 = dot(d, d);
65
+ float falloff = exp(-r2 / (uRadius * uRadius));
66
+ float wide = exp(-r2 / (uWide * uWide));
67
+ vec3 result = uMode > 0.5 ? mix(base, uValue, falloff * uStrength) : base + vec3(uValue.xy * falloff, uValue.z * wide);
68
+ outColor = vec4(result, 1.0);
69
+ }`,ze=`${U}
70
+ uniform sampler2D uVelocity;
71
+ uniform sampler2D uSource;
72
+ uniform vec2 uVelocityTexel;
73
+ uniform float uDt;
74
+ uniform vec4 uDecay;
75
+ void main() {
76
+ vec2 coord = vUv - uDt * texture(uVelocity, vUv).xy * uVelocityTexel;
77
+ outColor = texture(uSource, coord) * uDecay;
78
+ }`,je=`${U}
79
+ uniform sampler2D uVelocity;
80
+ uniform sampler2D uSource;
81
+ uniform sampler2D uForward;
82
+ uniform sampler2D uBack;
83
+ uniform vec2 uVelocityTexel;
84
+ uniform vec2 uSourceTexel;
85
+ uniform float uDt;
86
+ uniform vec4 uDecay;
87
+ void main() {
88
+ vec2 coord = vUv - uDt * texture(uVelocity, vUv).xy * uVelocityTexel;
89
+ vec4 forward = texture(uForward, vUv);
90
+ vec4 corrected = forward + 0.5 * (texture(uSource, vUv) - texture(uBack, vUv));
91
+ vec2 base = (floor(coord / uSourceTexel - 0.5) + 0.5) * uSourceTexel;
92
+ vec4 a = texture(uSource, base);
93
+ vec4 b = texture(uSource, base + vec2(uSourceTexel.x, 0.0));
94
+ vec4 c = texture(uSource, base + vec2(0.0, uSourceTexel.y));
95
+ vec4 d = texture(uSource, base + uSourceTexel);
96
+ vec4 low = min(min(a, b), min(c, d));
97
+ vec4 high = max(max(a, b), max(c, d));
98
+ outColor = clamp(corrected, low, high) * uDecay;
99
+ }`,qe=`${U}
100
+ uniform sampler2D uVelocity;
101
+ void main() {
102
+ float left = texture(uVelocity, vL).x;
103
+ float right = texture(uVelocity, vR).x;
104
+ float top = texture(uVelocity, vT).y;
105
+ float bottom = texture(uVelocity, vB).y;
106
+ vec2 center = texture(uVelocity, vUv).xy;
107
+ if (vL.x < 0.0) left = -center.x;
108
+ if (vR.x > 1.0) right = -center.x;
109
+ if (vT.y > 1.0) top = -center.y;
110
+ if (vB.y < 0.0) bottom = -center.y;
111
+ outColor = vec4(0.5 * (right - left + top - bottom), 0.0, 0.0, 1.0);
112
+ }`,Ye=`${U}
113
+ uniform sampler2D uSource;
114
+ uniform float uValue;
115
+ void main() {
116
+ outColor = texture(uSource, vUv) * uValue;
117
+ }`,Ke=`${U}
118
+ uniform sampler2D uPressure;
119
+ uniform sampler2D uDivergence;
120
+ void main() {
121
+ float left = texture(uPressure, vL).x;
122
+ float right = texture(uPressure, vR).x;
123
+ float top = texture(uPressure, vT).x;
124
+ float bottom = texture(uPressure, vB).x;
125
+ float divergence = texture(uDivergence, vUv).x;
126
+ outColor = vec4((left + right + bottom + top - divergence) * 0.25, 0.0, 0.0, 1.0);
127
+ }`,Qe=`${U}
128
+ uniform sampler2D uPressure;
129
+ uniform sampler2D uVelocity;
130
+ void main() {
131
+ float left = texture(uPressure, vL).x;
132
+ float right = texture(uPressure, vR).x;
133
+ float top = texture(uPressure, vT).x;
134
+ float bottom = texture(uPressure, vB).x;
135
+ vec2 velocity = texture(uVelocity, vUv).xy - vec2(right - left, top - bottom);
136
+ outColor = vec4(velocity, 0.0, 1.0);
137
+ }`,Me=`
138
+ uniform vec3 uColor;
139
+ uniform vec3 uSecondary;
140
+ uniform float uIntensity;
141
+ uniform float uHotspot;
142
+ vec3 shade(vec3 dye) {
143
+ float energy = max(dye.x, 0.0);
144
+ float heat = clamp(dye.y, 0.0, energy);
145
+ float gas = max(dye.z, 0.0);
146
+ float fresh = heat / max(energy, 0.0001);
147
+ vec3 tint = mix(uSecondary, uColor, fresh);
148
+ return (tint * energy + uSecondary * gas + vec3(heat * heat * 0.3 * uHotspot)) * uIntensity;
149
+ }
150
+ `,Je=`${U}${Me}
151
+ uniform sampler2D uDye;
152
+ uniform vec2 uDyeTexel;
153
+ void main() {
154
+ vec2 o = uDyeTexel * 0.5;
155
+ vec3 light = shade(texture(uDye, vUv + vec2(-o.x, -o.y)).xyz);
156
+ light += shade(texture(uDye, vUv + vec2(o.x, -o.y)).xyz);
157
+ light += shade(texture(uDye, vUv + vec2(-o.x, o.y)).xyz);
158
+ light += shade(texture(uDye, vUv + vec2(o.x, o.y)).xyz);
159
+ outColor = vec4(light * 0.25, 1.0);
160
+ }`,Ze=`${U}
161
+ uniform sampler2D uSource;
162
+ uniform vec2 uSourceTexel;
163
+ void main() {
164
+ vec2 o = uSourceTexel;
165
+ vec3 color = texture(uSource, vUv).rgb * 4.0;
166
+ color += texture(uSource, vUv + vec2(-o.x, -o.y)).rgb;
167
+ color += texture(uSource, vUv + vec2(o.x, -o.y)).rgb;
168
+ color += texture(uSource, vUv + vec2(-o.x, o.y)).rgb;
169
+ color += texture(uSource, vUv + vec2(o.x, o.y)).rgb;
170
+ outColor = vec4(color / 8.0, 1.0);
171
+ }`,et=`${U}
172
+ uniform sampler2D uSource;
173
+ uniform vec2 uSourceTexel;
174
+ void main() {
175
+ vec2 o = uSourceTexel;
176
+ vec3 color = texture(uSource, vUv + vec2(-o.x * 2.0, 0.0)).rgb;
177
+ color += texture(uSource, vUv + vec2(o.x * 2.0, 0.0)).rgb;
178
+ color += texture(uSource, vUv + vec2(0.0, -o.y * 2.0)).rgb;
179
+ color += texture(uSource, vUv + vec2(0.0, o.y * 2.0)).rgb;
180
+ color += texture(uSource, vUv + vec2(-o.x, -o.y)).rgb * 2.0;
181
+ color += texture(uSource, vUv + vec2(o.x, -o.y)).rgb * 2.0;
182
+ color += texture(uSource, vUv + vec2(-o.x, o.y)).rgb * 2.0;
183
+ color += texture(uSource, vUv + vec2(o.x, o.y)).rgb * 2.0;
184
+ outColor = vec4(color / 12.0, 1.0);
185
+ }`,tt=`${U}${Me}
186
+ uniform sampler2D uDye;
187
+ uniform sampler2D uBloom;
188
+ uniform float uGlow;
189
+ uniform float uGrain;
190
+ uniform float uTime;
191
+ uniform float uLight;
192
+ float hash(vec2 p) {
193
+ p = fract(p * vec2(123.34, 456.21));
194
+ p += dot(p, p + 45.32);
195
+ return fract(p.x * p.y);
196
+ }
197
+ void main() {
198
+ vec3 dye = texture(uDye, vUv).xyz;
199
+ vec3 light = shade(dye);
200
+ vec3 bloom = texture(uBloom, vUv).rgb * uGlow;
201
+ float edge = smoothstep(0.0, 0.02, min(min(vUv.x, 1.0 - vUv.x), min(vUv.y, 1.0 - vUv.y)));
202
+ float grain = 1.0 + (hash(gl_FragCoord.xy + fract(uTime * 13.7) * 97.0) - 0.5) * uGrain * 2.0;
203
+ if (uLight > 0.5) {
204
+ float energy = max(dye.x, 0.0);
205
+ float heat = clamp(dye.y, 0.0, energy);
206
+ float gas = max(dye.z, 0.0);
207
+ float fresh = heat / max(energy, 0.0001);
208
+ vec3 tint = mix(uSecondary, uColor, fresh);
209
+ float halo = dot(bloom, vec3(0.2126, 0.7152, 0.0722));
210
+ float density = 1.0 - exp(-((energy * 1.1 + gas * 0.8) * uIntensity + halo * 0.25));
211
+ float tone = dot(tint, vec3(0.2126, 0.7152, 0.0722));
212
+ vec3 ink = tint * min(1.0, 0.5 / max(tone, 0.001)) * mix(0.95, 0.72, smoothstep(0.5, 3.0, energy));
213
+ ink = mix(ink, vec3(1.0), clamp(heat * heat * 0.05 * uHotspot, 0.0, 0.45));
214
+ density = clamp(density * grain, 0.0, 1.0) * edge;
215
+ outColor = vec4(ink * density, density);
216
+ } else {
217
+ vec3 color = 1.0 - exp(-(light + bloom) * grain);
218
+ color *= edge;
219
+ outColor = vec4(color, max(color.r, max(color.g, color.b)));
220
+ }
221
+ }`,De={low:{sim:96,dye:384},medium:{sim:128,dye:576},high:{sim:160,dye:768}},ot=20,rt=.75,Ae=5,J=(m,p,T)=>Math.min(T,Math.max(p,m)),Ue=(m,p,T)=>{const v=m.createShader(p);return v?(m.shaderSource(v,T),m.compileShader(v),m.getShaderParameter(v,m.COMPILE_STATUS)?v:(m.deleteShader(v),null)):null},it=([m,p,T])=>{const v=Math.max(m,p,T),w=Math.min(m,p,T),b=v-w;let M=0;return b>0&&(v===m?M=(p-T)/b%6:v===p?M=(T-m)/b+2:M=(m-p)/b+4),[(M*60+360)%360,v>0?b/v:0,v]},nt=(m,p,T)=>{const v=(m%360+360)%360/60,w=T*p,b=w*(1-Math.abs(v%2-1)),M=T-w,[$,X,H]=v<1?[w,b,0]:v<2?[b,w,0]:v<3?[0,w,b]:v<4?[0,b,w]:v<5?[b,0,w]:[w,0,b];return[$+M,X+M,H+M]},ut=({color:m="#5f8bff",secondaryColor:p,intensity:T=1.3,trailWidth:v=3,linger:w=1.4,glow:b=1.2,hotspot:M=.8,followSpeed:$=.6,grain:X=0,clickBurst:H=!0,quality:Z="high",theme:ee="dark",blendMode:Fe,maxDevicePixelRatio:Pe=2,enabled:Le=!0,children:te,className:Be="",style:Ce,...Ve})=>{const oe=k.useRef(null),re=k.useRef(null),V=k.useRef(null);V.current={color:String(m),secondaryColor:p?String(p):"",intensity:Math.max(0,T),trailWidth:J(v,.5,40),linger:J(w,.1,10),glow:Math.max(0,b),hotspot:Math.max(0,M),followSpeed:J($,0,1),grain:Math.max(0,X),clickBurst:H,quality:De[Z]?Z:"high",theme:ee,maxDevicePixelRatio:Pe,enabled:Le},k.useEffect(()=>{const P=oe.current,y=re.current,e=y?.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1});if(!P||!y||!e||!e.getExtension("EXT_color_buffer_float"))return;const W=Ue(e,e.VERTEX_SHADER,He);if(!W)return;const D=t=>{const i=Ue(e,e.FRAGMENT_SHADER,t),o=e.createProgram();if(!i||!o)return null;if(e.attachShader(o,W),e.attachShader(o,i),e.bindAttribLocation(o,0,"aPosition"),e.linkProgram(o),e.deleteShader(i),!e.getProgramParameter(o,e.LINK_STATUS))return e.deleteProgram(o),null;const r={},a=e.getProgramParameter(o,e.ACTIVE_UNIFORMS);for(let u=0;u<a;u++){const l=e.getActiveUniform(o,u);l&&(r[l.name]=e.getUniformLocation(o,l.name))}return{program:o,uniforms:r}},ie={splat:D(We),advect:D(ze),maccormack:D(je),divergence:D(qe),scale:D(Ye),pressure:D(Ke),gradient:D(Qe),prefilter:D(Je),down:D(Ze),up:D(et),display:D(tt)};if(Object.values(ie).some(t=>!t))return;const R=ie,z=e.createVertexArray(),ne=e.createBuffer();e.bindVertexArray(z),e.bindBuffer(e.ARRAY_BUFFER,ne),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0);const j=document.createElement("canvas");j.width=1,j.height=1;const L=j.getContext("2d",{willReadFrequently:!0}),_=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,n={width:1,height:1,ratio:1,colorKey:"",color:[.37,.55,1],secondary:[.25,.3,1],pointer:{x:0,y:0,inside:!1},emitter:{x:0,y:0,vx:0,vy:0,px:0,py:0},ready:!1,bursts:[],active:-1/0,time:0,allocated:"",targets:null};let I=0,B=0,q=!0,N=!0;const ae=(t,i)=>{if(!L||!t)return i;const o=/^[0-9a-f]{3,8}$/i.test(t)?`#${t}`:t;L.clearRect(0,0,1,1),L.fillStyle="#000000",L.fillStyle=o,L.fillRect(0,0,1,1);const[r,a,u]=L.getImageData(0,0,1,1).data;return[r/255,a/255,u/255]},Ie=t=>{const i=`${t.color}|${t.secondaryColor}`;if(i!==n.colorKey)if(n.colorKey=i,n.color=ae(t.color,[.37,.55,1]),t.secondaryColor)n.secondary=ae(t.secondaryColor,n.color);else{const[o,r,a]=it(n.color);n.secondary=nt(o+8,Math.min(1,r*1.1+.05),a)}},C=(t,i,o,r,a)=>{const u=e.createTexture();e.bindTexture(e.TEXTURE_2D,u),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,o,t,i,0,r,e.HALF_FLOAT,null);const l=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,l),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,u,0),e.viewport(0,0,t,i),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),{texture:u,fbo:l,width:t,height:i,texel:[1/t,1/i]}},Y=(t,i,o,r,a)=>{let u=C(t,i,o,r,a),l=C(t,i,o,r,a);return{get read(){return u},get write(){return l},swap(){const d=u;u=l,l=d},targets(){return[u,l]}}},Oe=t=>{e.deleteTexture(t.texture),e.deleteFramebuffer(t.fbo)},ue=()=>{const t=n.targets;t&&([...t.velocity.targets(),...t.dye.targets(),...t.pressure.targets(),t.divergence,t.forward,t.back,...t.bloom].forEach(Oe),n.targets=null)},Ge=()=>{const t=n.targets;t&&(e.clearColor(0,0,0,0),[...t.velocity.targets(),...t.dye.targets(),...t.pressure.targets()].forEach(i=>{e.bindFramebuffer(e.FRAMEBUFFER,i.fbo),e.clear(e.COLOR_BUFFER_BIT)}))},ce=()=>{const t=V.current,i=`${t.quality}|${n.width}|${n.height}|${y.width}|${y.height}`;if(i===n.allocated&&n.targets)return;ue(),n.allocated=i;const o=De[t.quality],r=n.width/n.height,a=g=>r>=1?[Math.round(g*r),g]:[g,Math.round(g/r)],[u,l]=a(o.sim);let[d,h]=a(o.dye);const s=Math.min(1,y.width/d,y.height/h);d=Math.max(2,Math.round(d*s)),h=Math.max(2,Math.round(h*s));const c=[];let x=d>>1,A=h>>1;for(let g=0;g<Ae;g++)c.push(C(Math.max(1,x),Math.max(1,A),e.RGBA16F,e.RGBA,e.LINEAR)),x>>=1,A>>=1;n.targets={velocity:Y(u,l,e.RG16F,e.RG,e.LINEAR),dye:Y(d,h,e.RGBA16F,e.RGBA,e.LINEAR),forward:C(d,h,e.RGBA16F,e.RGBA,e.LINEAR),back:C(d,h,e.RGBA16F,e.RGBA,e.LINEAR),pressure:Y(u,l,e.R16F,e.RED,e.NEAREST),divergence:C(u,l,e.R16F,e.RED,e.NEAREST),bloom:c}};let K=!1;const le=()=>{const t=V.current,i=Math.max(1,P.clientWidth),o=Math.max(1,P.clientHeight),r=Math.min(window.devicePixelRatio||1,Math.max(.5,t.maxDevicePixelRatio||2)),a=Math.max(1,Math.round(i*r)),u=Math.max(1,Math.round(o*r));(y.width!==a||y.height!==u)&&(y.width=a,y.height=u),n.width=i,n.height=o,n.ratio=r,ce()},se=()=>{K=!0,F()},E=t=>{t?(e.bindFramebuffer(e.FRAMEBUFFER,t.fbo),e.viewport(0,0,t.width,t.height)):(e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,y.width,y.height)),e.drawArrays(e.TRIANGLES,0,3)},S=(t,i)=>(e.useProgram(t.program),t.uniforms.uTexel&&e.uniform2f(t.uniforms.uTexel,i[0],i[1]),t.uniforms),f=(t,i)=>(e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,i.texture),t),O=(t,i,o,r,a,u,l,d,h,s=u)=>{const c=S(R.splat,t.read.texel);e.uniform1i(c.uTarget,f(0,t.read)),e.uniform1f(c.uAspect,n.width/n.height),e.uniform2f(c.uA,i/n.width,1-o/n.height),e.uniform2f(c.uB,r/n.width,1-a/n.height),e.uniform1f(c.uRadius,u/n.height),e.uniform1f(c.uWide,s/n.height),e.uniform3f(c.uValue,l[0],l[1],l[2]),e.uniform1f(c.uMode,d),e.uniform1f(c.uStrength,h),E(t.write),t.swap()},fe=(t,i)=>{const{velocity:o}=n.targets;return[t*o.read.width/n.width,-i*o.read.height/n.height]},de=t=>Math.max(t.trailWidth*.5,n.height/n.targets.dye.read.height*.9),Ne=(t,i,o)=>{const{emitter:r,pointer:a}=n,{velocity:u,dye:l}=n.targets;if(r.px=r.x,r.py=r.y,_||t.followSpeed>=1)r.x=a.x,r.y=a.y;else{const x=10+t.followSpeed*50,A=Math.max(1,Math.ceil(i/.004)),g=i/A;for(let G=0;G<A;G++)r.vx+=(x*x*(a.x-r.x)-2*x*r.vx)*g,r.vy+=(x*x*(a.y-r.y)-2*x*r.vy)*g,r.x+=r.vx*g,r.y+=r.vy*g}const d=r.x-r.px,h=r.y-r.py;if(Math.hypot(d,h)<.05||!t.enabled)return;const c=de(t);if(!_){const x=fe(d/Math.max(i,.001),h/Math.max(i,.001));O(u,r.px,r.py,r.x,r.y,c*4+18,[x[0],x[1],0],3,rt*.6)}O(l,r.px,r.py,r.x,r.y,c,[5.6,5.6,.7],2,1,c*5+6),n.active=o},ke=(t,i,o,r)=>{const{velocity:a,dye:u}=n.targets,l=de(t),d=6,h=Math.random()*Math.PI*2;for(let s=0;s<d;s++){const c=h+s/d*Math.PI*2+(Math.random()-.5)*.5,x=Math.cos(c),A=Math.sin(c),g=20+Math.random()*14,G=i+x*3,Ee=o+A*3,Te=i+x*g,Se=o+A*g;if(!_){const we=fe(Math.cos(c+.6)*760,Math.sin(c+.6)*760);O(a,G,Ee,Te,Se,18,[we[0],we[1],0],1,.9)}O(u,G,Ee,Te,Se,l*1.1,[2.4,2.4,.3],0,1,l*5+6)}O(u,i,o,i+.01,o,l*2.2,[1.8,1.8,.4],0,1,l*7+10),n.active=r},$e=(t,i)=>{const{velocity:o,dye:r,pressure:a,divergence:u}=n.targets;if(!_){let c=S(R.divergence,o.read.texel);e.uniform1i(c.uVelocity,f(0,o.read)),E(u),c=S(R.scale,a.read.texel),e.uniform1i(c.uSource,f(0,a.read)),e.uniform1f(c.uValue,.8),E(a.write),a.swap(),c=S(R.pressure,a.read.texel),e.uniform1i(c.uDivergence,f(1,u));for(let A=0;A<ot;A++)e.uniform1i(c.uPressure,f(0,a.read)),E(a.write),a.swap();c=S(R.gradient,o.read.texel),e.uniform1i(c.uPressure,f(0,a.read)),e.uniform1i(c.uVelocity,f(1,o.read)),E(o.write),o.swap(),c=S(R.advect,o.read.texel),e.uniform2f(c.uVelocityTexel,o.read.texel[0],o.read.texel[1]),e.uniform1i(c.uVelocity,f(0,o.read)),e.uniform1i(c.uSource,f(0,o.read)),e.uniform1f(c.uDt,i);const x=Math.exp(-i*1.2);e.uniform4f(c.uDecay,x,x,1,1),E(o.write),o.swap()}const l=[Math.exp(-i*4.6/(t.linger*.8)),Math.exp(-i*4.6/(t.linger*.2)),Math.exp(-i*4.6/(t.linger*1.2)),1],{forward:d,back:h}=n.targets;if(_){const c=S(R.advect,r.read.texel);e.uniform2f(c.uVelocityTexel,o.read.texel[0],o.read.texel[1]),e.uniform1i(c.uVelocity,f(0,o.read)),e.uniform1i(c.uSource,f(1,r.read)),e.uniform1f(c.uDt,0),e.uniform4f(c.uDecay,l[0],l[1],l[2],l[3]),E(r.write),r.swap();return}let s=S(R.advect,r.read.texel);e.uniform2f(s.uVelocityTexel,o.read.texel[0],o.read.texel[1]),e.uniform1i(s.uVelocity,f(0,o.read)),e.uniform1i(s.uSource,f(1,r.read)),e.uniform1f(s.uDt,i),e.uniform4f(s.uDecay,1,1,1,1),E(d),e.uniform1i(s.uSource,f(1,d)),e.uniform1f(s.uDt,-i),E(h),s=S(R.maccormack,r.read.texel),e.uniform2f(s.uVelocityTexel,o.read.texel[0],o.read.texel[1]),e.uniform2f(s.uSourceTexel,r.read.texel[0],r.read.texel[1]),e.uniform1i(s.uVelocity,f(0,o.read)),e.uniform1i(s.uSource,f(1,r.read)),e.uniform1i(s.uForward,f(2,d)),e.uniform1i(s.uBack,f(3,h)),e.uniform1f(s.uDt,i),e.uniform4f(s.uDecay,l[0],l[1],l[2],l[3]),E(r.write),r.swap()},ve=(t,i)=>{e.uniform3f(t.uColor,n.color[0],n.color[1],n.color[2]),e.uniform3f(t.uSecondary,n.secondary[0],n.secondary[1],n.secondary[2]),e.uniform1f(t.uIntensity,i.intensity),e.uniform1f(t.uHotspot,i.hotspot)},Xe=t=>{const{dye:i,bloom:o}=n.targets;if(t.glow>0){let a=S(R.prefilter,o[0].texel);e.uniform1i(a.uDye,f(0,i.read)),e.uniform2f(a.uDyeTexel,i.read.texel[0],i.read.texel[1]),ve(a,t),E(o[0]),a=S(R.down,o[0].texel);for(let u=1;u<o.length;u++)e.uniform1i(a.uSource,f(0,o[u-1])),e.uniform2f(a.uSourceTexel,o[u-1].texel[0],o[u-1].texel[1]),E(o[u]);e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE),a=S(R.up,o[0].texel);for(let u=o.length-1;u>0;u--)e.uniform1i(a.uSource,f(0,o[u])),e.uniform2f(a.uSourceTexel,o[u].texel[0],o[u].texel[1]),E(o[u-1]);e.disable(e.BLEND)}const r=S(R.display,[1/y.width,1/y.height]);e.uniform1i(r.uDye,f(0,i.read)),e.uniform1i(r.uBloom,f(1,o[0])),ve(r,t),e.uniform1f(r.uGlow,t.glow>0?t.glow*1.4/Ae:0),e.uniform1f(r.uGrain,t.grain),e.uniform1f(r.uTime,n.time),e.uniform1f(r.uLight,t.theme==="light"?1:0),E(null)},me=()=>{e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,y.width,y.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},xe=t=>{if(I=0,K&&(K=!1,le()),!q||!N||document.hidden)return;const i=V.current,o=B?Math.min(1/30,(t-B)/1e3):1/60;B=t,n.time+=o;const r=Math.min(window.devicePixelRatio||1,Math.max(.5,i.maxDevicePixelRatio||2));for(Math.abs(r-n.ratio)>.01&&le(),ce(),Ie(i),e.bindVertexArray(z),e.disable(e.BLEND),n.ready&&Ne(i,o,t);n.bursts.length;){const[l,d]=n.bursts.shift();ke(i,l,d,t)}$e(i,o),Xe(i);const a=t-n.active>i.linger*1200+900,u=Math.hypot(n.emitter.vx,n.emitter.vy)<1;if(a&&u){Ge(),me(),B=0;return}I=requestAnimationFrame(xe)},F=()=>{!I&&q&&N&&!document.hidden&&(I=requestAnimationFrame(xe))},he=t=>{const i=P.getBoundingClientRect(),o=t.clientX-i.left,r=t.clientY-i.top;if(!(o>=0&&r>=0&&o<=i.width&&r<=i.height)){n.pointer.inside&&(n.pointer.inside=!1,n.ready=!1,F());return}n.ready||(n.emitter.x=o,n.emitter.y=r,n.emitter.px=o,n.emitter.py=r,n.emitter.vx=0,n.emitter.vy=0,n.ready=!0),n.pointer.x=o,n.pointer.y=r,n.pointer.inside=!0,F()},ye=t=>{const i=V.current;if(!i.clickBurst||!i.enabled)return;const o=P.getBoundingClientRect(),r=t.clientX-o.left,a=t.clientY-o.top;r<0||a<0||r>o.width||a>o.height||(n.bursts.push([r,a]),F())},ge=()=>{n.pointer.inside=!1,n.ready=!1,F()},pe=()=>{B=0,F()},be=new ResizeObserver(()=>{se(),F()});be.observe(P);const Re=new IntersectionObserver(t=>{N=t.some(i=>i.isIntersecting),N&&(B=0,F())});return Re.observe(P),window.addEventListener("pointermove",he,{passive:!0}),window.addEventListener("pointerdown",ye,{passive:!0}),document.documentElement.addEventListener("pointerleave",ge),document.addEventListener("visibilitychange",pe),se(),me(),()=>{q=!1,cancelAnimationFrame(I),be.disconnect(),Re.disconnect(),window.removeEventListener("pointermove",he),window.removeEventListener("pointerdown",ye),document.documentElement.removeEventListener("pointerleave",ge),document.removeEventListener("visibilitychange",pe),ue(),Object.values(R).forEach(t=>e.deleteProgram(t.program)),e.deleteShader(W),e.deleteBuffer(ne),e.deleteVertexArray(z)}},[]);const _e=Fe??(ee==="light"?"normal":"screen");return Q.jsxs("div",{ref:oe,className:["relative h-full w-full overflow-hidden",Be].filter(Boolean).join(" "),style:Ce,...Ve,children:[Q.jsx("canvas",{ref:re,className:"pointer-events-none absolute inset-0 block h-full w-full select-none",style:{mixBlendMode:_e},"aria-hidden":"true"}),te&&Q.jsx("div",{className:"relative z-[1] h-full w-full",children:te})]})};export{ut as default};
@@ -0,0 +1,146 @@
1
+ import{r as C,j as pe}from"./index-BiLDfPwS.js";const V=8,B=3,ge=2400,z=3.4,ve=2.8,xe=["#4a3a9c","#8eb2ea","#6e8c3c","#d6f2ef","#f2d48c"],Ke=`#version 300 es
2
+ void main() {
3
+ vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));
4
+ gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
5
+ }`,Ue=`#version 300 es
6
+ precision highp float;
7
+
8
+ uniform vec2 uRes;
9
+ uniform float uTime;
10
+ uniform vec3 uColors[${V}];
11
+ uniform float uColorCount;
12
+ uniform vec4 uBackground;
13
+ uniform vec2 uOrigin;
14
+ uniform float uScale;
15
+ uniform float uAngle;
16
+ uniform float uSpacing;
17
+ uniform float uSpread;
18
+ uniform float uStretch;
19
+ uniform float uSharpness;
20
+ uniform float uHeat;
21
+ uniform float uFill;
22
+ uniform float uHaze;
23
+ uniform float uGrain;
24
+ uniform float uSeed;
25
+ uniform float uShimmer;
26
+ uniform float uFlow;
27
+ uniform vec4 uCursor;
28
+ uniform vec2 uDrag;
29
+ uniform vec2 uWaves[${B}];
30
+ uniform vec2 uIntro;
31
+ uniform float uFade;
32
+ uniform float uOpacity;
33
+ out vec4 outColor;
34
+
35
+ uint hashu(uint x) {
36
+ x ^= x >> 16u; x *= 0x7feb352du;
37
+ x ^= x >> 15u; x *= 0x846ca68bu;
38
+ x ^= x >> 16u; return x;
39
+ }
40
+ float hash12(vec2 p) {
41
+ ivec2 c = ivec2(floor(p));
42
+ uint h = hashu(uint(c.x) * 0x9e3779b9u ^ hashu(uint(c.y) + 0x7f4a7c15u));
43
+ return float(h) / 4294967295.0;
44
+ }
45
+ float speckle(vec2 p) {
46
+ ivec2 c = ivec2(floor(p));
47
+ uint h = hashu(uint(c.x) * 0x9e3779b9u ^ hashu(uint(c.y) + 0x7f4a7c15u + uint(uSeed) * 0x632be5abu));
48
+ return float(h) / 4294967295.0;
49
+ }
50
+
51
+ float noise(vec2 p) {
52
+ vec2 i = floor(p);
53
+ vec2 f = fract(p);
54
+ f = f * f * (3.0 - 2.0 * f);
55
+ float a = hash12(i);
56
+ float b = hash12(i + vec2(1.0, 0.0));
57
+ float c = hash12(i + vec2(0.0, 1.0));
58
+ float d = hash12(i + vec2(1.0, 1.0));
59
+ return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
60
+ }
61
+
62
+ vec4 ramp(float v) {
63
+ float x = clamp(v, 0.0, 1.0) * uColorCount;
64
+ vec3 c = vec3(0.0);
65
+ float keep = 1.0;
66
+ for (int i = 0; i < ${V}; i++) {
67
+ if (float(i) >= uColorCount) break;
68
+ float w = smoothstep(float(i), float(i) + 1.0, x);
69
+ c = mix(c, uColors[i], w);
70
+ keep *= 1.0 - w;
71
+ }
72
+ return vec4(c, 1.0 - keep);
73
+ }
74
+
75
+ float feather(float x, float w) {
76
+ if (w <= 0.0) return 1.0;
77
+ float t = clamp(min(x, 1.0 - x) / w, 0.0, 1.0);
78
+ return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
79
+ }
80
+
81
+ void main() {
82
+ vec2 R = max(uRes, vec2(1.0));
83
+ vec2 uv = gl_FragCoord.xy / R;
84
+ float t = uTime;
85
+
86
+ vec2 P = (uv - uOrigin) * vec2(R.x / R.y, 1.0) * uScale;
87
+ vec2 toCursor = P - uCursor.xy;
88
+ float spot = dot(toCursor, toCursor);
89
+ float near = exp(-spot / 0.035);
90
+ P -= toCursor * uCursor.w * near + uDrag * exp(-spot / 0.07);
91
+ if (uShimmer > 0.0) {
92
+ vec2 drift = vec2(0.0, -uFlow);
93
+ float n1 = noise(P * vec2(6.0, 4.0) + drift) + 0.5 * noise(P * vec2(13.0, 9.0) + drift * 1.7 + 17.0);
94
+ float n2 = noise(P * vec2(5.0, 7.0) + drift * 1.3 + 31.0);
95
+ P += uShimmer * vec2(0.02 * (n1 - 0.75), 0.01 * (n2 - 0.5));
96
+ }
97
+ float ca = cos(uAngle);
98
+ float sa = sin(uAngle);
99
+ P = vec2(ca * P.x - sa * P.y, sa * P.x + ca * P.y);
100
+ vec2 Q = P * vec2(uStretch, 1.0);
101
+ float r = length(Q);
102
+ float th = atan(Q.x, Q.y);
103
+
104
+ float rise = pow(max(r, 1e-4), 0.65) * 6.5;
105
+ float u = rise / uSpacing - t * 0.15;
106
+ float f = fract(u);
107
+
108
+ float sp = f < 0.6 ? 0.5 * f / 0.6 : 0.5 + 0.5 * (f - 0.6) / 0.4;
109
+
110
+ float ang = exp(-pow(abs(th) / (0.68 * uSpread), 2.4));
111
+ float wave = pow(sin(3.14159265 * sp), (1.6 + 2.6 * (1.0 - ang)) * uSharpness);
112
+
113
+ float amp = 0.55 + 0.10 * smoothstep(0.14, 0.28, r)
114
+ + 0.10 * smoothstep(0.28, 0.43, r)
115
+ + 0.13 * smoothstep(0.43, 0.63, r)
116
+ + 0.12 * smoothstep(0.63, 0.85, r);
117
+ float core = smoothstep(0.02, 0.12, r);
118
+ amp *= core;
119
+
120
+ float floorv = uFill * smoothstep(0.45, 0.85, r);
121
+ float v = amp * ang * mix(wave, 1.0, floorv);
122
+ v += uHaze * exp(-pow(th / uSpread, 2.0)) * smoothstep(0.03, 0.3, r);
123
+ v *= uHeat;
124
+
125
+ for (int k = 0; k < ${B}; k++) {
126
+ vec2 pulse = uWaves[k];
127
+ if (pulse.y <= 0.0) continue;
128
+ float band = rise - pulse.x;
129
+ v += pulse.y * exp(-band * band / 0.2) * ang * core * mix(0.35, 1.0, wave);
130
+ }
131
+ v *= 1.0 + uCursor.z * near;
132
+ v += uCursor.z * near * 0.05 * ang;
133
+ v *= 1.0 - smoothstep(uIntro.x - 1.1, uIntro.x, rise);
134
+ v += uIntro.y * exp(-pow((rise - uIntro.x + 0.45) / 0.4, 2.0)) * ang * core * mix(0.3, 1.0, wave) * 0.5;
135
+
136
+ vec4 ink = ramp(v);
137
+ ink *= feather(uv.x, uFade * 0.34) * feather(uv.y, uFade * 0.44);
138
+ float speck = (speckle(gl_FragCoord.xy) - 0.5) * uGrain + (hash12(gl_FragCoord.xy) - 0.5) / 255.0;
139
+ if (uBackground.a > 0.5) {
140
+ vec3 col = ink.rgb + uBackground.rgb * (1.0 - ink.a) + speck;
141
+ outColor = vec4(clamp(col, 0.0, 1.0), 1.0) * uOpacity;
142
+ return;
143
+ }
144
+ vec3 col = ink.rgb + speck * ink.a;
145
+ outColor = vec4(clamp(col, 0.0, ink.a), ink.a) * uOpacity;
146
+ }`,je=["uRes","uTime","uColors","uColorCount","uBackground","uOrigin","uScale","uAngle","uSpacing","uSpread","uStretch","uSharpness","uHeat","uFill","uHaze","uGrain","uSeed","uShimmer","uFlow","uCursor","uDrag","uWaves","uIntro","uFade","uOpacity"],$e=["bottom","top","left","right","center"],h=(n,l,m)=>Math.min(m,Math.max(l,n)),d=(n,l)=>{const m=Number(n);return Number.isFinite(m)?m:l},we=(n,l,m)=>{const u=n.createShader(l);return u?(n.shaderSource(u,m),n.compileShader(u),!n.getShaderParameter(u,n.COMPILE_STATUS)&&!n.isContextLost()&&console.error(n.getShaderInfoLog(u)),u):null},Qe=n=>{const l=we(n,n.VERTEX_SHADER,Ke),m=we(n,n.FRAGMENT_SHADER,Ue),u=l&&m?n.createProgram():null;if(!l||!m||!u)return l&&n.deleteShader(l),m&&n.deleteShader(m),null;if(n.attachShader(u,l),n.attachShader(u,m),n.linkProgram(u),n.deleteShader(l),n.deleteShader(m),!n.getProgramParameter(u,n.LINK_STATUS))return n.isContextLost()||console.error(n.getProgramInfoLog(u)),n.deleteProgram(u),null;const A={};for(const F of je)A[F]=n.getUniformLocation(u,F);return{program:u,uniforms:A}},qe=(n,l)=>n==="top"?{x:.5,y:.92,angle:Math.PI,scale:1}:n==="left"?{x:.08,y:.5,angle:Math.PI/2,scale:1/l}:n==="right"?{x:.92,y:.5,angle:-Math.PI/2,scale:1/l}:n==="center"?{x:.5,y:.5,angle:0,scale:1.84}:{x:.5,y:.08,angle:0,scale:1},Ze=({colors:n=xe,backgroundColor:l="transparent",source:m="bottom",tilt:u=0,spacing:A=1,spread:F=1,stretch:ye=1,sharpness:Se=1,heat:be=1,fill:Ce=.3,haze:ke=.25,shimmer:Me=0,speed:Ee=1,grain:Re=.25,fade:Pe=0,opacity:Ae=1,intro:Fe=!0,mouseInteraction:Le=!0,mouseStrength:Ie=1,clickWave:Oe=!0,paused:De=!1,dpr:_e,className:Te="",...Ne})=>{const j=C.useRef(null),$=C.useRef(null),G=C.useRef(null),[He,ze]=C.useState(0),Q={colors:(Array.isArray(n)&&n.length?n:xe).slice(0,V).map(String),backgroundColor:String(l||"transparent"),source:$e.includes(m)?m:"bottom",tilt:h(d(u,0),-180,180),spacing:h(d(A,1),.2,4),spread:h(d(F,1),.1,6),stretch:h(d(ye,1),.25,4),sharpness:h(d(Se,1),.1,6),heat:h(d(be,1),0,4),fill:h(d(Ce,.3),0,1),haze:h(d(ke,.25),0,1),shimmer:h(d(Me,0),0,2),speed:h(d(Ee,1),-10,10),grain:h(d(Re,.25),0,1),fade:h(d(Pe,0),0,1),opacity:h(d(Ae,1),0,1),intro:Fe,mouseInteraction:Le,mouseStrength:h(d(Ie,1),0,3),clickWave:Oe,paused:De,dpr:_e},x=C.useRef(Q);return x.current=Q,C.useEffect(()=>{G.current?.()}),C.useEffect(()=>{const k=j.current,p=$.current;if(!k||!p)return;const r=p.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"default"});if(!r)return;const L=Qe(r);if(!L)return;const q=r.createVertexArray(),W=document.createElement("canvas");W.width=1,W.height=1;const M=W.getContext("2d",{willReadFrequently:!0}),I=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,X=new Float32Array(V*3),O=new Float32Array(B*2),g=[0,0,0,0],t={time:0,flow:0,clock:0,frame:0,surge:0,intro:x.current.intro&&!I&&!x.current.paused?0:z+1,width:1,height:1,paletteKey:"",backgroundKey:"",colorCount:1,pointer:{x:0,y:0,inside:!1,placed:!1},cursor:{x:.5,y:.5,glow:0,energy:0},trail:{x:.5,y:.5},drag:{x:0,y:0},waves:[]};let v=0,E=0,D=!0,K=!0,_=!1;const Y=o=>{if(!M||!o)return[0,0,0,0];const a=/^[0-9a-f]{3,8}$/i.test(o)?`#${o}`:o;M.clearRect(0,0,1,1),M.fillStyle="rgba(0, 0, 0, 0)",M.fillStyle=a,M.fillRect(0,0,1,1);const[i,s,c,e]=M.getImageData(0,0,1,1).data;return[i/255,s/255,c/255,e/255]},Ve=o=>{const a=o.colors.join("|");if(a!==t.paletteKey&&(t.paletteKey=a,X.fill(0),o.colors.forEach((i,s)=>X.set(Y(i).slice(0,3),s*3)),t.colorCount=o.colors.length),o.backgroundColor!==t.backgroundKey){t.backgroundKey=o.backgroundColor;const[i,s,c,e]=Y(o.backgroundColor);g[0]=i,g[1]=s,g[2]=c,g[3]=e>.5?1:0}},U=()=>{if(_)return;const o=x.current;Ve(o);const a=p.width,i=p.height,s=t.width/t.height,c=qe(o.source,s),e=L.uniforms;r.bindFramebuffer(r.FRAMEBUFFER,null),r.viewport(0,0,a,i),r.disable(r.BLEND),r.useProgram(L.program),r.bindVertexArray(q),r.uniform2f(e.uRes,a,i),r.uniform1f(e.uTime,t.time),r.uniform3fv(e.uColors,X),r.uniform1f(e.uColorCount,t.colorCount),r.uniform4f(e.uBackground,g[0],g[1],g[2],g[3]),r.uniform2f(e.uOrigin,c.x,c.y),r.uniform1f(e.uScale,c.scale),r.uniform1f(e.uAngle,c.angle+o.tilt*Math.PI/180),r.uniform1f(e.uSpacing,o.spacing),r.uniform1f(e.uSpread,o.spread),r.uniform1f(e.uStretch,.68/o.stretch),r.uniform1f(e.uSharpness,o.sharpness),r.uniform1f(e.uHeat,o.heat),r.uniform1f(e.uFill,o.fill),r.uniform1f(e.uHaze,o.haze*.1),r.uniform1f(e.uGrain,o.grain),r.uniform1f(e.uSeed,t.frame),r.uniform1f(e.uShimmer,o.shimmer),r.uniform1f(e.uFlow,t.flow);const{cursor:f}=t,y=f.glow*Math.min(.3,.1*o.mouseStrength),R=f.glow*o.mouseStrength*(.28+.5*f.energy);r.uniform4f(e.uCursor,(f.x-c.x)*s*c.scale,(f.y-c.y)*c.scale,R,y),r.uniform2f(e.uDrag,t.drag.x*s*c.scale,t.drag.y*c.scale),O.fill(0),t.waves.forEach((b,P)=>{const N=t.clock-b.start,H=h(1-N/ve,0,1);O[P*2]=-.4+N*3.8,O[P*2+1]=.7*Math.pow(H,1.6)*b.strength}),r.uniform2fv(e.uWaves,O);const S=h(t.intro/z,0,1),T=1-(1-S)*(1-S);r.uniform2f(e.uIntro,S>=1?1e3:-.6+T*10.6,S>=1?0:1-T),r.uniform1f(e.uFade,o.fade),r.uniform1f(e.uOpacity,o.opacity),r.drawArrays(r.TRIANGLES,0,3),r.bindVertexArray(null)},J=()=>{const o=x.current,a=Math.max(1,k.clientWidth),i=Math.max(1,k.clientHeight),s=Math.min(o.dpr||window.devicePixelRatio||1,2),c=Math.max(a,i)*s,e=c>ge?s*ge/c:s,f=Math.max(1,Math.round(a*e)),y=Math.max(1,Math.round(i*e));(p.width!==f||p.height!==y)&&(p.width=f,p.height=y),t.width=a,t.height=i,U()},Z=o=>{if(v=0,!K||!D||document.hidden||_)return;const a=x.current,i=E?Math.min(.05,(o-E)/1e3):0;E=o;const s=!a.paused&&!I,{pointer:c,cursor:e,trail:f,drag:y}=t;s?(t.clock+=i,t.frame=(t.frame+1)%4096,t.intro+=i,t.surge*=Math.exp(-i/.6),t.time+=i*a.speed*(1+t.surge*2.5),t.flow+=i*(.7+Math.abs(a.speed)*.3),t.waves=t.waves.filter(b=>t.clock-b.start<ve)):t.intro<z&&(t.intro=z+1);const R=a.mouseInteraction&&c.inside&&!I,S=R?1:0;if(i>0){if(R){const Be=c.x/t.width,Ge=1-c.y/t.height,me=1-Math.exp(-i/.06),he=(Be-e.x)*me,de=(Ge-e.y)*me;e.x+=he,e.y+=de;const We=t.width/t.height,Xe=Math.hypot(he*We,de)/i;e.energy+=(Math.min(1,Xe*.8)-e.energy)*(1-Math.exp(-i/.25))}else e.energy*=Math.exp(-i/.4);const b=1-Math.exp(-i/.22);f.x+=(e.x-f.x)*b,f.y+=(e.y-f.y)*b;const P=.035*Math.min(a.mouseStrength,2)*e.glow,N=t.width/t.height,H=(e.x-f.x)*.7,ue=(e.y-f.y)*.7,le=Math.hypot(H*N,ue),fe=le>P?P/le:1;y.x=H*fe,y.y=ue*fe,e.glow+=(S-e.glow)*(1-Math.exp(-i/(R?.3:.55)))}U();const T=Math.hypot(e.x-f.x,e.y-f.y)>5e-4||e.energy>.002||Math.abs(S-e.glow)>.002;s||T?v=requestAnimationFrame(Z):E=0},w=()=>{!v&&K&&D&&!document.hidden&&!_&&(v=requestAnimationFrame(Z))},ee=o=>{const a=k.getBoundingClientRect(),i=o.clientX-a.left,s=o.clientY-a.top;return{x:i,y:s,inside:i>=0&&s>=0&&i<=a.width&&s<=a.height}},te=o=>{const a=ee(o),{pointer:i,cursor:s,trail:c}=t;a.inside&&!i.placed&&s.glow<.05&&(s.x=a.x/Math.max(t.width,1),s.y=1-a.y/Math.max(t.height,1),c.x=s.x,c.y=s.y),i.x=a.x,i.y=a.y,i.inside=a.inside,i.placed=a.inside,w()},oe=o=>{const a=x.current;if(!(!a.mouseInteraction||!a.clickWave||o.button!==0||I||a.paused||o.target instanceof Element&&o.target.closest('a, button, input, textarea, select, label, [role="button"]')||!ee(o).inside)){for(t.surge=Math.min(1.5,t.surge+1),t.waves.push({start:t.clock,strength:Math.min(1.5,.5+.5*a.mouseStrength)});t.waves.length>B;)t.waves.shift();w()}},re=()=>{t.pointer.inside=!1,t.pointer.placed=!1,w()},ne=()=>{E=0,w()},ae=o=>{o.preventDefault(),_=!0,cancelAnimationFrame(v),v=0},ie=()=>ze(o=>o+1),se=new ResizeObserver(J);se.observe(k);const ce=new IntersectionObserver(o=>{D=o.some(a=>a.isIntersecting),D&&(E=0,w())});return ce.observe(k),window.addEventListener("pointermove",te,{passive:!0}),window.addEventListener("pointerdown",oe),document.documentElement.addEventListener("pointerleave",re),document.addEventListener("visibilitychange",ne),p.addEventListener("webglcontextlost",ae),p.addEventListener("webglcontextrestored",ie),J(),w(),G.current=()=>{v||U(),w()},()=>{K=!1,cancelAnimationFrame(v),G.current=null,se.disconnect(),ce.disconnect(),window.removeEventListener("pointermove",te),window.removeEventListener("pointerdown",oe),document.documentElement.removeEventListener("pointerleave",re),document.removeEventListener("visibilitychange",ne),p.removeEventListener("webglcontextlost",ae),p.removeEventListener("webglcontextrestored",ie),r.isContextLost()||(r.deleteVertexArray(q),r.deleteProgram(L.program))}},[He]),pe.jsx("div",{ref:j,className:["relative h-full w-full overflow-hidden",Te].filter(Boolean).join(" "),...Ne,children:pe.jsx("canvas",{ref:$,className:"absolute inset-0 block h-full w-full","aria-hidden":"true"})})};export{Ze as default};
@@ -0,0 +1,152 @@
1
+ import{r as k,j as re}from"./index-BiLDfPwS.js";const Ne=1.8,_e=`#version 300 es
2
+ in vec2 aPosition;
3
+ void main() {
4
+ gl_Position = vec4(aPosition, 0.0, 1.0);
5
+ }`,Ue=`#version 300 es
6
+ precision highp float;
7
+ uniform vec2 uResolution;
8
+ uniform vec2 uCenter;
9
+ uniform float uScale;
10
+ uniform float uRatio;
11
+ uniform float uTime;
12
+ uniform float uDrift;
13
+ uniform vec2 uSteer;
14
+ uniform float uBend;
15
+ uniform float uCount;
16
+ uniform float uSwing;
17
+ uniform float uWave;
18
+ uniform float uWidth;
19
+ uniform float uPulseWidth;
20
+ uniform float uHead;
21
+ uniform float uTail;
22
+ uniform float uChance;
23
+ uniform float uSpacing;
24
+ uniform float uPulseSpeed;
25
+ uniform float uFlow;
26
+ uniform float uHalo;
27
+ uniform float uGlow;
28
+ uniform float uBrightness;
29
+ uniform float uVariance;
30
+ uniform float uBody;
31
+ uniform float uFadeNear;
32
+ uniform float uFadeFar;
33
+ uniform vec3 uCable;
34
+ uniform vec3 uPulse;
35
+ uniform vec3 uTunnel;
36
+ uniform vec3 uSurge;
37
+ uniform float uReveal;
38
+ uniform float uGrain;
39
+ uniform float uSeed;
40
+ uniform float uLight;
41
+ uniform float uOpacity;
42
+ out vec4 outColor;
43
+
44
+ const float TAU = 6.2831853;
45
+
46
+ vec3 inkOf(vec3 color, float depthOfInk) {
47
+ float luma = dot(color, vec3(0.2126, 0.7152, 0.0722));
48
+ float peak = max(color.r, max(color.g, color.b));
49
+ float chroma = (peak - min(color.r, min(color.g, color.b))) / max(peak, 0.001);
50
+ return color * min(1.0, mix(depthOfInk, depthOfInk * 1.7, chroma) / max(luma, 0.001));
51
+ }
52
+
53
+ float hash(float n) {
54
+ return fract(sin(n * 127.1 + uSeed * 311.7) * 43758.5453);
55
+ }
56
+
57
+ vec2 bendAt(float depth) {
58
+ float reach = 1.0 - exp(-max(depth, 0.0) * 0.55);
59
+ vec2 wobble = vec2(sin(uDrift * 0.37 + depth * 0.31), cos(uDrift * 0.29 + depth * 0.23)) * uBend;
60
+ return (wobble + uSteer) * reach;
61
+ }
62
+
63
+ void main() {
64
+ vec2 p = (gl_FragCoord.xy - 0.5 * uResolution - uCenter) / uScale;
65
+ float depth = -log(max(length(p), 1e-5));
66
+ vec2 q = p;
67
+ for (int i = 0; i < 4; i++) {
68
+ q = p - bendAt(depth);
69
+ depth = -log(max(length(q), 1e-5));
70
+ }
71
+ float r = length(q);
72
+ float px = r * uScale;
73
+ float turn = atan(q.y, q.x) / TAU;
74
+ float s = turn - uSwing - uWave * sin(depth * 1.2 + uDrift * 0.5);
75
+ float cell = floor(s * uCount);
76
+ float spacing = TAU * px / uCount;
77
+ float near = smoothstep(0.55, 1.25, r);
78
+ float width = uWidth * (1.0 + near * 1.2);
79
+ float soft = uRatio * (0.55 + near * 0.9);
80
+ float tight = uRatio * uHalo * (1.0 + near);
81
+ float wide = tight * 4.5;
82
+
83
+ float lines = 0.0;
84
+ float body = 0.0;
85
+ vec3 glow = vec3(0.0);
86
+ float strokes = 0.0;
87
+ for (int k = -3; k <= 3; k++) {
88
+ float i = cell + float(k);
89
+ float id = mod(i, uCount);
90
+ float h1 = hash(id);
91
+ float h2 = hash(id + 17.0);
92
+ float h3 = hash(id + 41.0);
93
+ float h4 = hash(id + 73.0);
94
+ float center = (i + 0.5 + (h1 - 0.5) * 0.55) / uCount;
95
+ center += 0.12 * sin(depth * (0.8 + h2 * 0.9) + uDrift * (0.4 + h3 * 0.5) + h4 * TAU) / uCount;
96
+ float d = abs(s - center) * TAU * px;
97
+ float shade = 1.0 + uVariance * (h3 - 0.5) * 0.9;
98
+ float reach = smoothstep(spacing * 2.4, spacing * 1.4, d);
99
+
100
+ lines += smoothstep(width + soft, width - soft, d) * shade;
101
+ body += exp(-d / max(spacing * 0.22, 0.001)) * shade * reach;
102
+
103
+ float x = depth * uSpacing + uTime * uPulseSpeed * (0.55 + h2 * 0.6) * uFlow + h4 * 7.0;
104
+ float lead = (fract(x) - 0.5) / uSpacing * uFlow;
105
+ float lit = step(hash(id * 3.7 + floor(x) * 13.1), uChance);
106
+ float limit = 0.5 / uSpacing;
107
+ float head = exp(-pow(max(-lead, 0.0) / uHead, 2.0)) * smoothstep(-limit, -limit * 0.8, lead);
108
+ float tail = exp(-max(lead, 0.0) / uTail) * smoothstep(limit, limit * 0.55, lead);
109
+ float pulse = (lead < 0.0 ? head : tail) * lit;
110
+ float ring = uSurge.y * exp(-pow((depth - uSurge.x) / uSurge.z, 2.0));
111
+ pulse = max(pulse, ring);
112
+ float hot = pulse * (lead < 0.0 ? 1.0 : exp(-max(lead, 0.0) / (uTail * 0.35)));
113
+
114
+ float core = uPulseWidth * width + 0.35 * uRatio;
115
+ float stroke = smoothstep(core + soft, core - soft, d);
116
+ float bloom = (exp(-d / tight) * 0.7 + exp(-d / wide) * 0.18) * uGlow * reach;
117
+ vec3 tint = mix(uPulse, vec3(1.0), hot * 0.55 * (1.0 - uLight));
118
+ glow += tint * pulse * (stroke * 1.5 + bloom) * shade;
119
+ strokes += pulse * stroke * shade;
120
+ }
121
+
122
+ float lod = smoothstep(4.0, 1.2, spacing);
123
+ float average = min(2.0 * uWidth / max(spacing, 0.001), 1.0);
124
+ lines = mix(lines, average, lod);
125
+ glow = mix(glow, uPulse * average * 0.6 * uChance, lod);
126
+ strokes = mix(strokes, average * 0.6 * uChance, lod);
127
+ body = mix(body, 1.0, lod) * uBody;
128
+
129
+ float rr = r * 0.25;
130
+ float fade = smoothstep(0.0, uFadeNear, rr) * smoothstep(uFadeFar, uFadeFar * 0.55, rr);
131
+ fade *= smoothstep(uReveal - 0.6, uReveal, depth);
132
+
133
+ float grain = 1.0;
134
+ if (uGrain > 0.0) {
135
+ grain += (fract(sin(dot(gl_FragCoord.xy, vec2(12.9898, 78.233)) + uTime * 7.0) * 43758.5453) - 0.5) * uGrain * 4.0;
136
+ }
137
+
138
+ if (uLight > 0.5) {
139
+ float hairline = clamp(lines * 0.26 + body * 0.2, 0.0, 1.0);
140
+ float stroke = clamp(strokes * 1.6, 0.0, 1.0);
141
+ float haze = clamp(length(glow) * 0.12, 0.0, 0.25);
142
+ float ink = clamp(hairline + stroke + haze, 0.0, 1.0) * fade * uOpacity * grain;
143
+ vec3 tone = mix(inkOf(uCable, 0.3), inkOf(uPulse, 0.16), clamp(stroke + haze * 2.0, 0.0, 1.0));
144
+ tone = mix(tone, inkOf(uTunnel, 0.3), clamp(body * uBody, 0.0, 1.0) * 0.5);
145
+ outColor = vec4(tone * ink, ink);
146
+ return;
147
+ }
148
+
149
+ vec3 light = (uCable * lines * 0.12 + uTunnel * body * 0.35 + glow) * uBrightness * fade * grain;
150
+ vec3 mapped = (1.0 - exp(-light * 1.4)) * uOpacity;
151
+ outColor = vec4(mapped, max(mapped.r, max(mapped.g, mapped.b)));
152
+ }`,l=(n,f,c)=>Math.min(c,Math.max(f,n)),ie=(n,f,c)=>{const r=n.createShader(f);return r?(n.shaderSource(r,c),n.compileShader(r),n.getShaderParameter(r,n.COMPILE_STATUS)?r:(n.deleteShader(r),null)):null},Ve=n=>{const f=ie(n,n.VERTEX_SHADER,_e),c=ie(n,n.FRAGMENT_SHADER,Ue),r=n.createProgram();if(!f||!c||!r)return null;if(n.attachShader(r,f),n.attachShader(r,c),n.bindAttribLocation(r,0,"aPosition"),n.linkProgram(r),n.deleteShader(f),n.deleteShader(c),!n.getProgramParameter(r,n.LINK_STATUS))return n.deleteProgram(r),null;const T={},O=n.getProgramParameter(r,n.ACTIVE_UNIFORMS);for(let E=0;E<O;E++){const P=n.getActiveUniform(r,E);P&&(T[P.name]=n.getUniformLocation(r,P.name))}return{program:r,uniforms:T}},qe=({cableColor:n="#ffffff",pulseColor:f="#ffffff",tunnelColor:c="#ffffff",tunnelOpacity:r=0,speed:T=.1,flowDirection:O="inward",pulseSpeed:E=2,pulseLength:P=.28,pulseBlend:ue=.6,pulseWidth:se=1,pulseDensity:le=.5,cableCount:fe=56,thickness:ce=.35,rimWidth:de=.15,waviness:me=.3,sway:he=.5,bend:pe=.4,size:ge=1,centerX:ve=0,centerY:xe=0,glow:we=1,fadeNear:be=.5,fadeFar:ye=2,brightness:Se=1,colorVariance:Me=!0,grain:Re=!1,grainIntensity:Ce=.05,opacity:Ae=1,mouseInteraction:ke=!0,mouseStrength:Ee=.1,clickSurge:Pe=!0,intro:Te=!0,variation:Fe=0,lightMode:Le=!1,dpr:Be,className:Oe="",style:We,...De})=>{const G=k.useRef(null),q=k.useRef(null),W=k.useRef(null),z={cableColor:n,pulseColor:f,tunnelColor:c,tunnelOpacity:l(r,0,1),speed:Math.max(0,T),flow:O==="outward"?1:-1,pulseSpeed:Math.max(0,E),pulseLength:l(P,.02,1),pulseBlend:l(ue,0,1),pulseWidth:l(se,.1,3),pulseDensity:l(le,0,1),cableCount:l(Math.round(fe),4,200),thickness:l(ce,.05,2),rimWidth:l(de,0,1),waviness:Math.max(0,me),sway:Math.max(0,he),bend:Math.max(0,pe),size:Math.max(.05,ge),centerX:ve,centerY:xe,glow:Math.max(0,we),fadeNear:Math.max(.001,be),fadeFar:Math.max(.01,ye),brightness:Math.max(0,Se),colorVariance:Me,grain:Re,grainIntensity:Math.max(0,Ce),opacity:l(Ae,0,1),mouseInteraction:ke,mouseStrength:Math.max(0,Ee),clickSurge:Pe,intro:Te,variation:Fe,lightMode:Le,dpr:Be},m=k.useRef(z);return m.current=z,k.useEffect(()=>{const v=G.current,x=q.current,e=x?.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1});if(!v||!x||!e)return;const F=Ve(e);if(!F)return;const o=F.uniforms,H=e.createBuffer(),D=e.createVertexArray();e.bindVertexArray(D),e.bindBuffer(e.ARRAY_BUFFER,H),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0);const S=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}),j=new Map,I=(t,a)=>{if(!t)return a;const i=String(t),u=j.get(i);if(u)return u;let s=a;if(S){S.clearRect(0,0,1,1),S.fillStyle="#000000",S.fillStyle=i,S.fillRect(0,0,1,1);const[b,g,y]=S.getImageData(0,0,1,1).data;s=[b/255,g/255,y/255]}return j.set(i,s),s},M=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,d={x:0,y:0,inside:!1},h={x:0,y:0},w={age:10};let X=0,N=0,p=m.current.intro&&!M?0:1,R=0,C=0,L=!0;const _=()=>{const t=m.current,a=x.width,i=x.height,u=a/Math.max(1,v.clientWidth),s=Math.min(a,i),b=t.flow,g=3.4,y=w.age*2.6,V=b>0?g-y:-.6+y,ne=w.age<2.4?Math.min(1,w.age/.12)*Math.exp(-w.age*1.1):0,Ie=p*p*(3-2*p);e.viewport(0,0,a,i),e.useProgram(F.program),e.bindVertexArray(D),e.uniform2f(o.uResolution,a,i),e.uniform2f(o.uCenter,t.centerX*s,t.centerY*s),e.uniform1f(o.uScale,s*.5*t.size),e.uniform1f(o.uRatio,u),e.uniform1f(o.uTime,X),e.uniform1f(o.uDrift,N),e.uniform2f(o.uSteer,h.x,h.y),e.uniform1f(o.uBend,t.bend*.45),e.uniform1f(o.uCount,t.cableCount),e.uniform1f(o.uSwing,Math.sin(N*.9)*t.sway*.5/(Math.PI*2)),e.uniform1f(o.uWave,t.waviness*.15),e.uniform1f(o.uWidth,(.25+t.thickness*1.5)*u),e.uniform1f(o.uPulseWidth,.6+t.pulseWidth*.9);const ae=t.pulseLength*1.2;e.uniform1f(o.uHead,ae*(.08+t.pulseBlend*.22)),e.uniform1f(o.uTail,ae*(.5+t.pulseBlend*.7)),e.uniform1f(o.uChance,t.pulseDensity),e.uniform1f(o.uSpacing,.4),e.uniform1f(o.uPulseSpeed,t.pulseSpeed*4),e.uniform1f(o.uFlow,b),e.uniform1f(o.uHalo,1.2+t.rimWidth*8),e.uniform1f(o.uGlow,t.glow),e.uniform1f(o.uBrightness,t.brightness),e.uniform1f(o.uVariance,t.colorVariance?1:0),e.uniform1f(o.uBody,t.tunnelOpacity),e.uniform1f(o.uFadeNear,t.fadeNear),e.uniform1f(o.uFadeFar,t.fadeFar),e.uniform3fv(o.uCable,I(t.cableColor,[1,1,1])),e.uniform3fv(o.uPulse,I(t.pulseColor,[1,1,1])),e.uniform3fv(o.uTunnel,I(t.tunnelColor,[1,1,1])),e.uniform3f(o.uSurge,V,ne,.22),e.uniform1f(o.uReveal,1.7-Ie*3.6),e.uniform1f(o.uGrain,t.grain?t.grainIntensity:0),e.uniform1f(o.uSeed,t.variation),e.uniform1f(o.uLight,t.lightMode?1:0),e.uniform1f(o.uOpacity,t.opacity),e.drawArrays(e.TRIANGLES,0,3)},Y=t=>{if(R=0,!L||document.hidden)return;const a=m.current,i=C?l((t-C)/1e3,5e-4,.05):1/60;C=t;const u=M?0:1;X+=i*a.speed*u,N+=i*(a.speed+.2)*u,w.age+=i,a.intro&&!M&&p<1?p=Math.min(1,p+i/Ne):(!a.intro||M)&&(p=1);const s=a.mouseInteraction&&d.inside&&!M,b=a.mouseStrength*2.5,g=s?[d.x*b,d.y*b]:[0,0],y=1-Math.exp(-i/.6);h.x+=(g[0]-h.x)*y,h.y+=(g[1]-h.y)*y,_();const V=Math.abs(g[0]-h.x)<5e-4&&Math.abs(g[1]-h.y)<5e-4;u>0||!V||p<1||w.age<2.4?R=requestAnimationFrame(Y):C=0},A=()=>{!R&&L&&!document.hidden&&(R=requestAnimationFrame(Y))},U=()=>{const t=m.current,a=Math.max(1,v.clientWidth),i=Math.max(1,v.clientHeight),u=Math.min(t.dpr||window.devicePixelRatio||1,2);x.width=Math.max(1,Math.round(a*u)),x.height=Math.max(1,Math.round(i*u)),_(),A()},K=t=>{const a=v.getBoundingClientRect(),i=t.clientX-a.left,u=t.clientY-a.top;d.inside=i>=0&&u>=0&&i<=a.width&&u<=a.height;const s=Math.min(a.width,a.height)*.5;d.x=(i-a.width/2)/Math.max(1,s),d.y=(a.height/2-u)/Math.max(1,s)},J=t=>{K(t),A()},Q=t=>{K(t),!(!d.inside||!m.current.clickSurge||M)&&(w.age=0,A())},B=t=>{t.pointerType!=="mouse"&&(d.inside=!1)},Z=()=>{d.inside=!1},$=()=>{C=0,A()},ee=new ResizeObserver(U);ee.observe(v);const te=new IntersectionObserver(t=>{L=t.some(a=>a.isIntersecting),L&&(C=0,A())});te.observe(v),window.addEventListener("pointermove",J,{passive:!0}),window.addEventListener("pointerdown",Q,{passive:!0}),window.addEventListener("pointerup",B,{passive:!0}),window.addEventListener("pointercancel",B,{passive:!0}),document.documentElement.addEventListener("pointerleave",Z),document.addEventListener("visibilitychange",$),U();let oe=m.current.dpr;return W.current=()=>{const t=m.current;if(t.dpr!==oe){oe=t.dpr,U();return}R||_(),A()},()=>{cancelAnimationFrame(R),W.current=null,ee.disconnect(),te.disconnect(),window.removeEventListener("pointermove",J),window.removeEventListener("pointerdown",Q),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",B),document.documentElement.removeEventListener("pointerleave",Z),document.removeEventListener("visibilitychange",$),e.deleteProgram(F.program),e.deleteBuffer(H),e.deleteVertexArray(D),x.isConnected||e.getExtension("WEBGL_lose_context")?.loseContext()}},[]),k.useEffect(()=>{W.current?.()}),re.jsx("div",{ref:G,className:["relative h-full w-full overflow-hidden",Oe].filter(Boolean).join(" "),style:We,...De,children:re.jsx("canvas",{ref:q,className:"absolute inset-0 block h-full w-full","aria-hidden":"true"})})};export{qe as default};