@rippleflow/water-distortion 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,27 +1,27 @@
1
- var Ye = Object.defineProperty;
2
- var Ve = (r, e, n) => e in r ? Ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var f = (r, e, n) => Ve(r, typeof e != "symbol" ? e + "" : e, n);
4
- import { jsxs as qe, jsx as de } from "react/jsx-runtime";
5
- import { forwardRef as $e, useRef as y, useImperativeHandle as Qe, useEffect as V, useState as je } from "react";
6
- function h(r, e, n) {
1
+ var Ve = Object.defineProperty;
2
+ var qe = (r, e, n) => e in r ? Ve(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var f = (r, e, n) => qe(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { jsxs as $e, jsx as fe } from "react/jsx-runtime";
5
+ import { forwardRef as Qe, useRef as R, useImperativeHandle as je, useEffect as q, useState as Ze } from "react";
6
+ function d(r, e, n) {
7
7
  return Math.min(n, Math.max(e, r));
8
8
  }
9
- function Ze(r, e) {
9
+ function Je(r, e) {
10
10
  return Math.hypot(e.x - r.x, e.y - r.y);
11
11
  }
12
12
  function O(r, e, n) {
13
13
  return r + (e - r) * n;
14
14
  }
15
- const J = 24, C = 128, oe = 8, se = Math.PI * 2, fe = {
15
+ const ee = 24, V = 32, C = 128, oe = 8, se = Math.PI * 2, me = {
16
16
  causticGain: 0.1,
17
17
  screenCompensation: 1.35,
18
18
  maxAlpha: 0.9
19
- }, Je = {
19
+ }, et = {
20
20
  gradient: 8e-4,
21
21
  curvature: 8e-4,
22
22
  trough: 6e-3,
23
23
  velocity: 8e-4
24
- }, Ae = `
24
+ }, Fe = `
25
25
  attribute vec2 a_position;
26
26
  varying vec2 v_uv;
27
27
 
@@ -29,10 +29,10 @@ void main() {
29
29
  v_uv = a_position * 0.5 + 0.5;
30
30
  gl_Position = vec4(a_position, 0.0, 1.0);
31
31
  }
32
- `, et = `
32
+ `, tt = `
33
33
  precision highp float;
34
34
 
35
- #define MAX_WAKE_SEGMENTS ${J}
35
+ #define MAX_WAKE_SEGMENTS ${ee}
36
36
 
37
37
  varying vec2 v_uv;
38
38
 
@@ -122,7 +122,7 @@ void main() {
122
122
 
123
123
  gl_FragColor = vec4(height, velocity, 0.0, 1.0);
124
124
  }
125
- `, tt = `
125
+ `, rt = `
126
126
  precision highp float;
127
127
 
128
128
  varying vec2 v_uv;
@@ -131,8 +131,8 @@ uniform sampler2D u_state;
131
131
  uniform sampler2D u_background;
132
132
  uniform sampler2D u_causticMap;
133
133
  uniform vec2 u_texel;
134
+ uniform vec2 u_backgroundScale;
134
135
  uniform float u_domMode;
135
- uniform float u_textureEnabled;
136
136
  uniform float u_normalScale;
137
137
  uniform float u_refractionStrength;
138
138
  uniform float u_specularIntensity;
@@ -140,21 +140,9 @@ uniform float u_crestIntensity;
140
140
  uniform float u_causticIntensity;
141
141
  uniform float u_time;
142
142
 
143
- const float DOM_CAUSTIC_GAIN = ${fe.causticGain.toFixed(2)};
144
- const float DOM_SCREEN_COMPENSATION = ${fe.screenCompensation.toFixed(2)};
145
- const float DOM_MAX_ALPHA = ${fe.maxAlpha.toFixed(2)};
146
-
147
- vec3 proceduralBackground(vec2 uv) {
148
- vec3 deep = vec3(0.055, 0.075, 0.070);
149
- vec3 teal = vec3(0.060, 0.320, 0.310);
150
- vec3 coral = vec3(0.680, 0.230, 0.190);
151
- vec3 gold = vec3(0.850, 0.710, 0.360);
152
- float diagonal = smoothstep(0.05, 0.95, uv.x * 0.72 + uv.y * 0.28);
153
- vec3 color = mix(deep, teal, diagonal);
154
- color = mix(color, coral, smoothstep(0.18, 0.76, uv.x - uv.y * 0.18) * 0.36);
155
- color = mix(color, gold, smoothstep(0.58, 1.0, uv.y + uv.x * 0.16) * 0.24);
156
- return color;
157
- }
143
+ const float DOM_CAUSTIC_GAIN = ${me.causticGain.toFixed(2)};
144
+ const float DOM_SCREEN_COMPENSATION = ${me.screenCompensation.toFixed(2)};
145
+ const float DOM_MAX_ALPHA = ${me.maxAlpha.toFixed(2)};
158
146
 
159
147
  vec4 causticLayer(vec2 uv, vec2 bend, mat2 rotation, float scale, vec2 drift) {
160
148
  vec2 p = rotation * (uv * scale + drift * u_time);
@@ -174,15 +162,20 @@ void main() {
174
162
  float dy = up - down;
175
163
  float signedCurvature = left + right + down + up - height * 4.0;
176
164
  vec3 normal = normalize(vec3(-dx * u_normalScale, 1.0, -dy * u_normalScale));
177
- vec2 refractedUv = clamp(
178
- v_uv + normal.xz * u_refractionStrength * 0.025,
165
+ vec2 backgroundUv = (v_uv - vec2(0.5)) * u_backgroundScale + vec2(0.5);
166
+ vec2 refractedUv = (
167
+ v_uv + normal.xz * u_refractionStrength * 0.025 - vec2(0.5)
168
+ ) * u_backgroundScale + vec2(0.5);
169
+ vec2 textureBounds =
170
+ step(vec2(0.0), backgroundUv) * step(backgroundUv, vec2(1.0));
171
+ float textureAlpha = textureBounds.x * textureBounds.y;
172
+ refractedUv = clamp(
173
+ refractedUv,
179
174
  vec2(0.001),
180
175
  vec2(0.999)
181
176
  );
182
177
 
183
- vec3 base = u_textureEnabled > 0.5
184
- ? texture2D(u_background, refractedUv).rgb
185
- : proceduralBackground(refractedUv);
178
+ vec3 base = texture2D(u_background, refractedUv).rgb;
186
179
 
187
180
  float gradient = length(vec2(dx, dy)) * u_normalScale;
188
181
  float crest = smoothstep(0.012, 0.24, gradient);
@@ -268,10 +261,10 @@ void main() {
268
261
  }
269
262
 
270
263
  vec3 color = base + highlight - vec3(0.015, 0.055, 0.070) * visibleTrough * 0.45;
271
- gl_FragColor = vec4(color, 1.0);
264
+ gl_FragColor = vec4(color, textureAlpha);
272
265
  }
273
266
  `;
274
- class rt {
267
+ class nt {
275
268
  constructor(e, n = () => {
276
269
  }) {
277
270
  f(this, "gl");
@@ -293,13 +286,15 @@ class rt {
293
286
  f(this, "textureImage");
294
287
  f(this, "textureReady", !1);
295
288
  f(this, "textureNeedsUpload", !1);
289
+ f(this, "textureWidth", 0);
290
+ f(this, "textureHeight", 0);
296
291
  f(this, "activityPixels");
297
- f(this, "wakeAUniforms", new Float32Array(J * 4));
298
- f(this, "wakeBUniforms", new Float32Array(J * 4));
299
- f(this, "wakeShapeUniforms", new Float32Array(J * 4));
292
+ f(this, "wakeAUniforms", new Float32Array(ee * 4));
293
+ f(this, "wakeBUniforms", new Float32Array(ee * 4));
294
+ f(this, "wakeShapeUniforms", new Float32Array(ee * 4));
300
295
  this.canvas = e, this.requestRender = n;
301
- const { gl: t, isWebGL2: i, canLinearFloat: a } = it(e);
302
- this.gl = t, this.isWebGL2 = i, this.canLinearFloat = a, this.quadBuffer = q(t.createBuffer(), "WebGL buffer"), this.simulationProgram = Le(t, Ae, et), this.materialProgram = Le(t, Ae, tt), this.backgroundTexture = q(t.createTexture(), "WebGL texture"), this.causticTexture = q(t.createTexture(), "WebGL texture"), t.bindBuffer(t.ARRAY_BUFFER, this.quadBuffer), t.bufferData(
296
+ const { gl: t, isWebGL2: i, canLinearFloat: a } = st(e);
297
+ this.gl = t, this.isWebGL2 = i, this.canLinearFloat = a, this.quadBuffer = $(t.createBuffer(), "WebGL buffer"), this.simulationProgram = Ue(t, Fe, tt), this.materialProgram = Ue(t, Fe, rt), this.backgroundTexture = $(t.createTexture(), "WebGL texture"), this.causticTexture = $(t.createTexture(), "WebGL texture"), t.bindBuffer(t.ARRAY_BUFFER, this.quadBuffer), t.bufferData(
303
298
  t.ARRAY_BUFFER,
304
299
  new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]),
305
300
  t.STATIC_DRAW
@@ -307,13 +302,17 @@ class rt {
307
302
  }
308
303
  resize(e, n, t, i) {
309
304
  this.cssWidth = Math.max(1, e), this.cssHeight = Math.max(1, n);
310
- const a = Math.min(2, Math.max(1, t || 1)), l = Math.max(1, Math.round(this.cssWidth * a)), c = Math.max(1, Math.round(this.cssHeight * a));
311
- (this.canvas.width !== l || this.canvas.height !== c) && (this.canvas.width = l, this.canvas.height = c);
312
- const s = Math.max(32, Math.round(i)), d = this.cssWidth / this.cssHeight, E = d >= 1 ? s : Math.max(1, Math.round(s * d)), _ = d >= 1 ? Math.max(1, Math.round(s / d)) : s;
313
- E === this.simWidth && _ === this.simHeight || (this.simWidth = E, this.simHeight = _, this.recreateState());
305
+ const a = Math.min(2, Math.max(1, t || 1)), s = Math.max(1, Math.round(this.cssWidth * a)), u = Math.max(1, Math.round(this.cssHeight * a));
306
+ (this.canvas.width !== s || this.canvas.height !== u) && (this.canvas.width = s, this.canvas.height = u);
307
+ const c = Math.max(
308
+ V,
309
+ Math.round(i)
310
+ ), h = this.cssWidth / this.cssHeight;
311
+ let v = c, x = c;
312
+ h >= 1 ? (x = Math.round(c / h), x < V && (x = V, v = Math.round(V * h))) : (v = Math.round(c * h), v < V && (v = V, x = Math.round(V / h))), !(v === this.simWidth && x === this.simHeight) && (this.simWidth = v, this.simHeight = x, this.recreateState());
314
313
  }
315
314
  setTextureSource(e) {
316
- if (e === this.textureSource || (this.textureSource = e, this.textureImage = void 0, this.textureReady = !1, this.textureNeedsUpload = !1, !e))
315
+ if (e === this.textureSource || (this.textureSource = e, this.textureImage = void 0, this.textureReady = !1, this.textureNeedsUpload = !1, this.textureWidth = 0, this.textureHeight = 0, !e))
317
316
  return;
318
317
  if (typeof e != "string") {
319
318
  this.textureImage = e, this.textureNeedsUpload = !0;
@@ -334,7 +333,7 @@ class rt {
334
333
  }
335
334
  render(e, n = 0) {
336
335
  const t = this.gl;
337
- this.stateTextures && (e.texture ? this.setTextureSource(e.texture) : this.setTextureSource(void 0), this.uploadTextureIfNeeded(e), t.useProgram(this.materialProgram.program), t.bindFramebuffer(t.FRAMEBUFFER, null), t.viewport(0, 0, this.canvas.width, this.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), !(e.mode !== "dom" && e.texture && !this.textureReady) && (t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.stateTextures[this.readIndex]), t.activeTexture(t.TEXTURE1), t.bindTexture(t.TEXTURE_2D, this.backgroundTexture), t.activeTexture(t.TEXTURE2), t.bindTexture(t.TEXTURE_2D, this.causticTexture), this.prepareQuad(this.materialProgram), this.setMaterialUniforms(e, n), t.drawArrays(t.TRIANGLE_STRIP, 0, 4)));
336
+ this.stateTextures && (e.texture ? this.setTextureSource(e.texture) : this.setTextureSource(void 0), this.uploadTextureIfNeeded(e), t.useProgram(this.materialProgram.program), t.bindFramebuffer(t.FRAMEBUFFER, null), t.viewport(0, 0, this.canvas.width, this.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), !(e.mode !== "dom" && !this.textureReady) && (t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.stateTextures[this.readIndex]), t.activeTexture(t.TEXTURE1), t.bindTexture(t.TEXTURE_2D, this.backgroundTexture), t.activeTexture(t.TEXTURE2), t.bindTexture(t.TEXTURE_2D, this.causticTexture), this.prepareQuad(this.materialProgram), this.setMaterialUniforms(e, n), t.drawArrays(t.TRIANGLE_STRIP, 0, 4)));
338
337
  }
339
338
  hasVisibleActivity() {
340
339
  if (!this.framebuffers)
@@ -354,7 +353,7 @@ class rt {
354
353
  } finally {
355
354
  e.bindFramebuffer(e.FRAMEBUFFER, null);
356
355
  }
357
- return ot(
356
+ return ut(
358
357
  this.activityPixels,
359
358
  this.simWidth,
360
359
  this.simHeight
@@ -375,14 +374,14 @@ class rt {
375
374
  (n = this.stateTextures) == null || n.forEach((i) => e.deleteTexture(i)), (t = this.framebuffers) == null || t.forEach((i) => e.deleteFramebuffer(i)), e.deleteTexture(this.backgroundTexture), e.deleteTexture(this.causticTexture), e.deleteBuffer(this.quadBuffer), e.deleteProgram(this.simulationProgram.program), e.deleteProgram(this.materialProgram.program);
376
375
  }
377
376
  recreateState() {
378
- var l, c;
377
+ var s, u;
379
378
  const e = this.gl;
380
- (l = this.stateTextures) == null || l.forEach((s) => e.deleteTexture(s)), (c = this.framebuffers) == null || c.forEach((s) => e.deleteFramebuffer(s));
379
+ (s = this.stateTextures) == null || s.forEach((c) => e.deleteTexture(c)), (u = this.framebuffers) == null || u.forEach((c) => e.deleteFramebuffer(c));
381
380
  const n = this.createStateTexture(), t = this.createStateTexture(), i = this.createFramebuffer(n), a = this.createFramebuffer(t);
382
381
  this.stateTextures = [n, t], this.framebuffers = [i, a], this.readIndex = 0, this.clear();
383
382
  }
384
383
  createStateTexture() {
385
- const e = this.gl, n = q(e.createTexture(), "WebGL texture");
384
+ const e = this.gl, n = $(e.createTexture(), "WebGL texture");
386
385
  if (e.bindTexture(e.TEXTURE_2D, n), e.texParameteri(
387
386
  e.TEXTURE_2D,
388
387
  e.TEXTURE_MIN_FILTER,
@@ -419,7 +418,7 @@ class rt {
419
418
  return n;
420
419
  }
421
420
  createFramebuffer(e) {
422
- const n = this.gl, t = q(n.createFramebuffer(), "WebGL framebuffer");
421
+ const n = this.gl, t = $(n.createFramebuffer(), "WebGL framebuffer");
423
422
  if (n.bindFramebuffer(n.FRAMEBUFFER, t), n.framebufferTexture2D(
424
423
  n.FRAMEBUFFER,
425
424
  n.COLOR_ATTACHMENT0,
@@ -455,11 +454,11 @@ class rt {
455
454
  0,
456
455
  e.RGBA,
457
456
  e.UNSIGNED_BYTE,
458
- nt()
457
+ ot()
459
458
  ), e.generateMipmap(e.TEXTURE_2D);
460
459
  }
461
460
  uploadTextureIfNeeded(e) {
462
- if (e.mode === "dom" || !this.textureImage || !this.textureNeedsUpload && !at(this.textureImage))
461
+ if (e.mode === "dom" || !this.textureImage || !this.textureNeedsUpload && !ct(this.textureImage))
463
462
  return;
464
463
  const n = this.gl;
465
464
  try {
@@ -470,9 +469,11 @@ class rt {
470
469
  n.RGBA,
471
470
  n.UNSIGNED_BYTE,
472
471
  this.textureImage
473
- ), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, 0), this.textureReady = !0, this.textureNeedsUpload = !1;
472
+ ), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, 0), [this.textureWidth, this.textureHeight] = at(
473
+ this.textureImage
474
+ ), this.textureReady = !0, this.textureNeedsUpload = !1;
474
475
  } catch {
475
- this.textureReady = !1, this.textureNeedsUpload = !1;
476
+ this.textureReady = !1, this.textureNeedsUpload = !1, this.textureWidth = 0, this.textureHeight = 0;
476
477
  }
477
478
  }
478
479
  prepareQuad(e) {
@@ -480,57 +481,84 @@ class rt {
480
481
  n.bindBuffer(n.ARRAY_BUFFER, this.quadBuffer), n.enableVertexAttribArray(e.position), n.vertexAttribPointer(e.position, 2, n.FLOAT, !1, 0, 0);
481
482
  }
482
483
  setSimulationUniforms(e, n, t) {
483
- const i = this.gl, a = this.simulationProgram.program, l = Math.min(e.length, J), c = this.wakeAUniforms, s = this.wakeBUniforms, d = this.wakeShapeUniforms, E = Math.max(0, e.length - J);
484
- c.fill(0), s.fill(0), d.fill(0);
485
- for (let _ = 0; _ < l; _ += 1) {
486
- const m = e[E + _], v = _ * 4;
487
- c[v] = m.ax, c[v + 1] = m.ay, c[v + 2] = m.radius, c[v + 3] = m.wakeStrength, s[v] = m.bx, s[v + 1] = m.by, s[v + 2] = m.wakeLength, s[v + 3] = m.velocity, d[v] = m.troughStrength, d[v + 1] = m.ridgeStrength, d[v + 2] = m.ridgeOffset;
484
+ const i = this.gl, a = this.simulationProgram.program, s = Math.min(e.length, ee), u = this.wakeAUniforms, c = this.wakeBUniforms, h = this.wakeShapeUniforms, v = Math.max(0, e.length - ee);
485
+ u.fill(0), c.fill(0), h.fill(0);
486
+ for (let x = 0; x < s; x += 1) {
487
+ const m = e[v + x], p = x * 4;
488
+ u[p] = m.ax, u[p + 1] = m.ay, u[p + 2] = m.radius, u[p + 3] = m.wakeStrength, c[p] = m.bx, c[p + 1] = m.by, c[p + 2] = m.wakeLength, c[p + 3] = m.velocity, h[p] = m.troughStrength, h[p + 1] = m.ridgeStrength, h[p + 2] = m.ridgeOffset;
488
489
  }
489
- i.uniform1i(p(i, a, "u_state"), 0), i.uniform2f(p(i, a, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), i.uniform1f(p(i, a, "u_delta"), t), i.uniform1f(p(i, a, "u_damping"), n.damping), i.uniform1f(p(i, a, "u_stiffness"), n.waveSpeed), i.uniform1f(p(i, a, "u_aspect"), this.cssWidth / this.cssHeight), i.uniform1i(p(i, a, "u_wakeCount"), l), i.uniform4fv(p(i, a, "u_wakeA[0]"), c), i.uniform4fv(p(i, a, "u_wakeB[0]"), s), i.uniform4fv(p(i, a, "u_wakeShape[0]"), d);
490
+ i.uniform1i(_(i, a, "u_state"), 0), i.uniform2f(_(i, a, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), i.uniform1f(_(i, a, "u_delta"), t), i.uniform1f(_(i, a, "u_damping"), n.damping), i.uniform1f(_(i, a, "u_stiffness"), n.waveSpeed), i.uniform1f(_(i, a, "u_aspect"), this.cssWidth / this.cssHeight), i.uniform1i(_(i, a, "u_wakeCount"), s), i.uniform4fv(_(i, a, "u_wakeA[0]"), u), i.uniform4fv(_(i, a, "u_wakeB[0]"), c), i.uniform4fv(_(i, a, "u_wakeShape[0]"), h);
490
491
  }
491
492
  setMaterialUniforms(e, n) {
492
- const t = this.gl, i = this.materialProgram.program, a = e.mode !== "dom";
493
- t.uniform1i(p(t, i, "u_state"), 0), t.uniform1i(p(t, i, "u_background"), 1), t.uniform1i(p(t, i, "u_causticMap"), 2), t.uniform2f(p(t, i, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), t.uniform1f(p(t, i, "u_domMode"), e.mode === "dom" ? 1 : 0), t.uniform1f(
494
- p(t, i, "u_textureEnabled"),
495
- a && this.textureReady ? 1 : 0
496
- ), t.uniform1f(p(t, i, "u_normalScale"), e.normalScale), t.uniform1f(p(t, i, "u_refractionStrength"), e.refractionStrength), t.uniform1f(p(t, i, "u_specularIntensity"), e.specularIntensity), t.uniform1f(p(t, i, "u_crestIntensity"), e.crestIntensity), t.uniform1f(p(t, i, "u_causticIntensity"), e.causticIntensity), t.uniform1f(p(t, i, "u_time"), n % 1e3);
493
+ const t = this.gl, i = this.materialProgram.program, [a, s] = it(
494
+ e.textureFit,
495
+ this.textureWidth,
496
+ this.textureHeight,
497
+ this.cssWidth,
498
+ this.cssHeight
499
+ );
500
+ t.uniform1i(_(t, i, "u_state"), 0), t.uniform1i(_(t, i, "u_background"), 1), t.uniform1i(_(t, i, "u_causticMap"), 2), t.uniform2f(_(t, i, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), t.uniform2f(
501
+ _(t, i, "u_backgroundScale"),
502
+ a,
503
+ s
504
+ ), t.uniform1f(_(t, i, "u_domMode"), e.mode === "dom" ? 1 : 0), t.uniform1f(_(t, i, "u_normalScale"), e.normalScale), t.uniform1f(_(t, i, "u_refractionStrength"), e.refractionStrength), t.uniform1f(_(t, i, "u_specularIntensity"), e.specularIntensity), t.uniform1f(_(t, i, "u_crestIntensity"), e.crestIntensity), t.uniform1f(_(t, i, "u_causticIntensity"), e.causticIntensity), t.uniform1f(_(t, i, "u_time"), n % 1e3);
497
505
  }
498
506
  }
499
- function nt() {
507
+ function it(r, e, n, t, i) {
508
+ if (r === "fill" || !Number.isFinite(e) || !Number.isFinite(n) || !Number.isFinite(t) || !Number.isFinite(i) || e <= 0 || n <= 0 || t <= 0 || i <= 0)
509
+ return [1, 1];
510
+ if (r === "none")
511
+ return [t / e, i / n];
512
+ const a = e / n, s = t / i;
513
+ return r === "cover" ? a > s ? [s / a, 1] : [1, a / s] : a > s ? [1, a / s] : [s / a, 1];
514
+ }
515
+ function at(r) {
516
+ const e = r, n = [
517
+ [e.naturalWidth, e.naturalHeight],
518
+ [e.videoWidth, e.videoHeight],
519
+ [e.displayWidth, e.displayHeight],
520
+ [e.width, e.height]
521
+ ];
522
+ for (const [t, i] of n)
523
+ if (typeof t == "number" && typeof i == "number" && Number.isFinite(t) && Number.isFinite(i) && t > 0 && i > 0)
524
+ return [t, i];
525
+ return [0, 0];
526
+ }
527
+ function ot() {
500
528
  const r = new Uint8Array(C * C * 4);
501
529
  for (let e = 0; e < C; e += 1)
502
530
  for (let n = 0; n < C; n += 1) {
503
- const t = (n + 0.5) / C, i = (e + 0.5) / C, a = Math.round(ce(t, i, 0) * 255), l = Math.round(ce(t, i, 11) * 255), c = Math.round(ce(t, i, 23) * 255), s = Math.round(ce(t, i, 37) * 255), d = (e * C + n) * 4;
504
- r[d] = a, r[d + 1] = l, r[d + 2] = c, r[d + 3] = s;
531
+ const t = (n + 0.5) / C, i = (e + 0.5) / C, a = Math.round(ce(t, i, 0) * 255), s = Math.round(ce(t, i, 11) * 255), u = Math.round(ce(t, i, 23) * 255), c = Math.round(ce(t, i, 37) * 255), h = (e * C + n) * 4;
532
+ r[h] = a, r[h + 1] = s, r[h + 2] = u, r[h + 3] = c;
505
533
  }
506
534
  return r;
507
535
  }
508
536
  function ce(r, e, n) {
509
- const t = Math.sin(se * (e * 2 + n * 0.013)) * 0.12 + Math.sin(se * (r * 3 + e + n * 0.021)) * 0.06, i = Math.cos(se * (r * 2 + n * 0.017)) * 0.12 + Math.sin(se * (e * 3 - r + n * 0.019)) * 0.06, a = r * oe + t, l = e * oe + i, c = Math.floor(a), s = Math.floor(l);
510
- let d = Number.POSITIVE_INFINITY, E = Number.POSITIVE_INFINITY, _ = 0, m = 0;
537
+ const t = Math.sin(se * (e * 2 + n * 0.013)) * 0.12 + Math.sin(se * (r * 3 + e + n * 0.021)) * 0.06, i = Math.cos(se * (r * 2 + n * 0.017)) * 0.12 + Math.sin(se * (e * 3 - r + n * 0.019)) * 0.06, a = r * oe + t, s = e * oe + i, u = Math.floor(a), c = Math.floor(s);
538
+ let h = Number.POSITIVE_INFINITY, v = Number.POSITIVE_INFINITY, x = 0, m = 0;
511
539
  for (let P = -1; P <= 1; P += 1)
512
540
  for (let U = -1; U <= 1; U += 1) {
513
- const k = c + U, B = s + P, M = Ie(k, oe), I = Ie(B, oe), z = k + 0.16 + me(M, I, n) * 0.68, N = B + 0.16 + me(M, I, n + 1) * 0.68, D = Math.hypot(a - z, l - N);
514
- D < d ? (E = d, d = D, _ = M, m = I) : D < E && (E = D);
541
+ const k = u + U, B = c + P, b = Le(k, oe), I = Le(B, oe), z = k + 0.16 + ge(b, I, n) * 0.68, W = B + 0.16 + ge(b, I, n + 1) * 0.68, D = Math.hypot(a - z, s - W);
542
+ D < h ? (v = h, h = D, x = b, m = I) : D < v && (v = D);
515
543
  }
516
- const v = E - d, A = 1 - Fe(0.025, 0.13, v), w = 1 - Fe(0.08, 0.34, v), W = 0.74 + me(_, m, n + 2) * 0.26, H = A * A * 0.58 + w * 0.34;
517
- return We(Math.pow(H * W, 1.12));
544
+ const p = v - h, A = 1 - ke(0.025, 0.13, p), w = 1 - ke(0.08, 0.34, p), N = 0.74 + ge(x, m, n + 2) * 0.26, H = A * A * 0.58 + w * 0.34;
545
+ return Xe(Math.pow(H * N, 1.12));
518
546
  }
519
- function me(r, e, n) {
547
+ function ge(r, e, n) {
520
548
  const t = Math.sin(r * 127.1 + e * 311.7 + n * 74.7) * 43758.5453123;
521
549
  return t - Math.floor(t);
522
550
  }
523
- function Ie(r, e) {
551
+ function Le(r, e) {
524
552
  return (r % e + e) % e;
525
553
  }
526
- function Fe(r, e, n) {
527
- const t = We((n - r) / (e - r));
554
+ function ke(r, e, n) {
555
+ const t = Xe((n - r) / (e - r));
528
556
  return t * t * (3 - t * 2);
529
557
  }
530
- function We(r) {
558
+ function Xe(r) {
531
559
  return Math.min(1, Math.max(0, r));
532
560
  }
533
- function it(r) {
561
+ function st(r) {
534
562
  const e = {
535
563
  alpha: !0,
536
564
  antialias: !1,
@@ -562,51 +590,51 @@ function it(r) {
562
590
  canLinearFloat: !!t.getExtension("OES_texture_float_linear")
563
591
  };
564
592
  }
565
- function Le(r, e, n) {
566
- const t = ke(r, r.VERTEX_SHADER, e), i = ke(r, r.FRAGMENT_SHADER, n), a = q(r.createProgram(), "WebGL program");
593
+ function Ue(r, e, n) {
594
+ const t = De(r, r.VERTEX_SHADER, e), i = De(r, r.FRAGMENT_SHADER, n), a = $(r.createProgram(), "WebGL program");
567
595
  if (r.attachShader(a, t), r.attachShader(a, i), r.linkProgram(a), r.deleteShader(t), r.deleteShader(i), !r.getProgramParameter(a, r.LINK_STATUS)) {
568
- const c = r.getProgramInfoLog(a) || "Unknown shader link error.";
569
- throw r.deleteProgram(a), new Error(c);
596
+ const u = r.getProgramInfoLog(a) || "Unknown shader link error.";
597
+ throw r.deleteProgram(a), new Error(u);
570
598
  }
571
- const l = r.getAttribLocation(a, "a_position");
572
- if (l < 0)
599
+ const s = r.getAttribLocation(a, "a_position");
600
+ if (s < 0)
573
601
  throw new Error("WaterDistortion could not bind its quad attribute.");
574
- return { program: a, position: l };
602
+ return { program: a, position: s };
575
603
  }
576
- function ke(r, e, n) {
577
- const t = q(r.createShader(e), "WebGL shader");
604
+ function De(r, e, n) {
605
+ const t = $(r.createShader(e), "WebGL shader");
578
606
  if (r.shaderSource(t, n), r.compileShader(t), !r.getShaderParameter(t, r.COMPILE_STATUS)) {
579
607
  const i = r.getShaderInfoLog(t) || "Unknown shader compile error.";
580
608
  throw r.deleteShader(t), new Error(i);
581
609
  }
582
610
  return t;
583
611
  }
584
- function p(r, e, n) {
612
+ function _(r, e, n) {
585
613
  const t = r.getUniformLocation(e, n);
586
614
  if (!t)
587
615
  throw new Error(`WaterDistortion could not bind uniform ${n}.`);
588
616
  return t;
589
617
  }
590
- function q(r, e) {
618
+ function $(r, e) {
591
619
  if (!r)
592
620
  throw new Error(`WaterDistortion could not create ${e}.`);
593
621
  return r;
594
622
  }
595
- function at(r) {
623
+ function ct(r) {
596
624
  return typeof HTMLCanvasElement < "u" && r instanceof HTMLCanvasElement || typeof HTMLVideoElement < "u" && r instanceof HTMLVideoElement || typeof OffscreenCanvas < "u" && r instanceof OffscreenCanvas;
597
625
  }
598
- function ot(r, e, n, t = Je) {
626
+ function ut(r, e, n, t = et) {
599
627
  const i = Math.max(0, Math.floor(e)), a = Math.max(0, Math.floor(n));
600
628
  if (i === 0 || a === 0)
601
629
  return !1;
602
- const l = (c, s) => r[(s * i + c) * 4] ?? 0;
603
- for (let c = 0; c < a; c += 1)
604
- for (let s = 0; s < i; s += 1) {
605
- const d = (c * i + s) * 4, E = r[d] ?? 0, _ = r[d + 1] ?? 0;
606
- if (E < -t.trough || Math.abs(_) > t.velocity)
630
+ const s = (u, c) => r[(c * i + u) * 4] ?? 0;
631
+ for (let u = 0; u < a; u += 1)
632
+ for (let c = 0; c < i; c += 1) {
633
+ const h = (u * i + c) * 4, v = r[h] ?? 0, x = r[h + 1] ?? 0;
634
+ if (v < -t.trough || Math.abs(x) > t.velocity)
607
635
  return !0;
608
- const m = s > 0 ? l(s - 1, c) : E, v = s < i - 1 ? l(s + 1, c) : E, A = c > 0 ? l(s, c - 1) : E, w = c < a - 1 ? l(s, c + 1) : E, W = Math.hypot(v - m, w - A), H = Math.abs(m + v + A + w - E * 4);
609
- if (W > t.gradient || H > t.curvature)
636
+ const m = c > 0 ? s(c - 1, u) : v, p = c < i - 1 ? s(c + 1, u) : v, A = u > 0 ? s(c, u - 1) : v, w = u < a - 1 ? s(c, u + 1) : v, N = Math.hypot(p - m, w - A), H = Math.abs(m + p + A + w - v * 4);
637
+ if (N > t.gradient || H > t.curvature)
610
638
  return !0;
611
639
  }
612
640
  return !1;
@@ -624,8 +652,8 @@ const L = {
624
652
  velocityClamp: 1.35,
625
653
  cursorSmoothing: 0.2,
626
654
  segmentSpacing: 18
627
- }, st = 24;
628
- function ge(r) {
655
+ }, lt = 24;
656
+ function ve(r) {
629
657
  return {
630
658
  width: Math.max(1, r.width ?? L.width),
631
659
  height: Math.max(1, r.height ?? L.height),
@@ -655,7 +683,7 @@ function ge(r) {
655
683
  0.05,
656
684
  r.velocityClamp ?? L.velocityClamp
657
685
  ),
658
- cursorSmoothing: h(
686
+ cursorSmoothing: d(
659
687
  r.cursorSmoothing ?? L.cursorSmoothing,
660
688
  0,
661
689
  0.9
@@ -666,24 +694,24 @@ function ge(r) {
666
694
  )
667
695
  };
668
696
  }
669
- function Ue(r, e, n = r.timeStamp) {
697
+ function Pe(r, e, n = r.timeStamp) {
670
698
  const t = typeof r.getCoalescedEvents == "function" ? r.getCoalescedEvents() : [], i = t.length > 0 ? t : [r], a = n - r.timeStamp;
671
- return i.map((l) => ({
672
- x: l.clientX - e.left,
673
- y: l.clientY - e.top,
674
- time: l.timeStamp + a
699
+ return i.map((s) => ({
700
+ x: s.clientX - e.left,
701
+ y: s.clientY - e.top,
702
+ time: s.timeStamp + a
675
703
  }));
676
704
  }
677
- class ct {
705
+ class ht {
678
706
  constructor(e = {}) {
679
707
  f(this, "options");
680
708
  f(this, "previous");
681
709
  f(this, "smoothedVelocity", 0);
682
710
  f(this, "disturbances", []);
683
- this.options = ge(e);
711
+ this.options = ve(e);
684
712
  }
685
713
  configure(e) {
686
- this.options = ge({
714
+ this.options = ve({
687
715
  ...this.options,
688
716
  ...e
689
717
  });
@@ -697,25 +725,25 @@ class ct {
697
725
  if (!t)
698
726
  return this.previous = n, this.disturbances;
699
727
  n.time <= t.time && (n.time = t.time + 0.01);
700
- const i = this.smoothSample(t, n), a = Ze(t, i);
728
+ const i = this.smoothSample(t, n), a = Je(t, i);
701
729
  if (a < 0.35)
702
730
  return this.previous = i, this.disturbances;
703
- const l = a / Math.max(0.01, i.time - t.time), c = h(1 - this.options.cursorSmoothing, 0.12, 1);
731
+ const s = a / Math.max(0.01, i.time - t.time), u = d(1 - this.options.cursorSmoothing, 0.12, 1);
704
732
  this.smoothedVelocity = O(
705
733
  this.smoothedVelocity,
706
- l,
707
- c
734
+ s,
735
+ u
708
736
  ), this.previous = i;
709
- const s = Math.min(
710
- st,
737
+ const c = Math.min(
738
+ lt,
711
739
  Math.max(1, Math.ceil(a / this.options.segmentSpacing))
712
740
  );
713
- for (let d = 0; d < s; d += 1) {
714
- const E = d / s, _ = (d + 1) / s;
741
+ for (let h = 0; h < c; h += 1) {
742
+ const v = h / c, x = (h + 1) / c;
715
743
  this.disturbances.push(
716
- ve(
717
- De(t, i, E),
718
- De(t, i, _),
744
+ xe(
745
+ Be(t, i, v),
746
+ Be(t, i, x),
719
747
  this.smoothedVelocity,
720
748
  this.options
721
749
  )
@@ -725,8 +753,8 @@ class ct {
725
753
  }
726
754
  clampSample(e) {
727
755
  return {
728
- x: h(e.x, 0, this.options.width),
729
- y: h(e.y, 0, this.options.height),
756
+ x: d(e.x, 0, this.options.width),
757
+ y: d(e.y, 0, this.options.height),
730
758
  time: e.time
731
759
  };
732
760
  }
@@ -739,39 +767,40 @@ class ct {
739
767
  };
740
768
  }
741
769
  }
742
- function ve(r, e, n, t) {
743
- const i = ge(t), a = h(
770
+ function xe(r, e, n, t) {
771
+ const i = ve(t), a = d(
744
772
  n * i.velocityScale / i.velocityClamp,
745
773
  0,
746
774
  1
747
- ), l = h(r.y / i.height, 0, 1), c = h(e.y / i.height, 0, 1), s = i.wakeLength * O(0.55, 1.35, a);
775
+ ), s = d(r.y / i.height, 0, 1), u = d(e.y / i.height, 0, 1), c = i.wakeLength * O(0.55, 1.35, a);
748
776
  return {
749
- ax: h(r.x / i.width, 0, 1),
750
- ay: 1 - l,
751
- bx: h(e.x / i.width, 0, 1),
752
- by: 1 - c,
777
+ ax: d(r.x / i.width, 0, 1),
778
+ ay: 1 - s,
779
+ bx: d(e.x / i.width, 0, 1),
780
+ by: 1 - u,
753
781
  radius: i.interactionRadius / i.height,
754
782
  wakeStrength: i.wakeStrength * O(0.18, 1, a),
755
783
  troughStrength: i.troughStrength,
756
784
  ridgeStrength: i.ridgeStrength,
757
785
  ridgeOffset: i.ridgeOffset / i.height,
758
- wakeLength: s / i.height,
786
+ wakeLength: c / i.height,
759
787
  velocity: a
760
788
  };
761
789
  }
762
- function De(r, e, n) {
790
+ function Be(r, e, n) {
763
791
  return {
764
792
  x: O(r.x, e.x, n),
765
793
  y: O(r.y, e.y, n),
766
794
  time: O(r.time, e.time, n)
767
795
  };
768
796
  }
769
- function ut(r) {
770
- const e = h(r, 0.85, 0.998), n = Math.ceil(Math.log(0.012) / Math.log(e));
771
- return h(n * (1e3 / 60), 900, 5200);
797
+ function dt(r) {
798
+ const e = d(r, 0.85, 0.998), n = Math.ceil(Math.log(0.012) / Math.log(e));
799
+ return d(n * (1e3 / 60), 900, 5200);
772
800
  }
773
- const x = {
801
+ const E = {
774
802
  mode: "texture",
803
+ textureFit: "fill",
775
804
  damping: 0.98,
776
805
  waveSpeed: 0.4,
777
806
  normalScale: 20,
@@ -794,136 +823,137 @@ const x = {
794
823
  interactionMode: "move",
795
824
  runInBackground: !1,
796
825
  pauseKey: void 0
797
- }, G = 1e3 / 60, lt = 4, Pe = 360, Be = 24, ht = 200;
798
- function dt(r) {
826
+ }, G = 1e3 / 60, ft = 4, Ce = 360, Ne = 24, mt = 200;
827
+ function gt(r) {
799
828
  return r instanceof Element && r.closest(
800
829
  "a, button, input, select, textarea, [contenteditable]:not([contenteditable=false])"
801
830
  ) !== null;
802
831
  }
803
- function ft(r) {
832
+ function vt(r) {
804
833
  const e = r.strength === void 0 ? void 0 : r.strength / 48;
805
834
  return {
806
- mode: r.mode ?? x.mode,
835
+ mode: r.mode ?? E.mode,
807
836
  texture: r.texture,
808
- damping: h(
809
- r.damping ?? r.dissipation ?? x.damping,
837
+ textureFit: r.textureFit ?? E.textureFit,
838
+ damping: d(
839
+ r.damping ?? r.dissipation ?? E.damping,
810
840
  0.85,
811
841
  0.998
812
842
  ),
813
- waveSpeed: h(r.waveSpeed ?? x.waveSpeed, 0.05, 1),
814
- normalScale: h(
815
- r.normalScale ?? x.normalScale,
843
+ waveSpeed: d(r.waveSpeed ?? E.waveSpeed, 0.05, 1),
844
+ normalScale: d(
845
+ r.normalScale ?? E.normalScale,
816
846
  1,
817
847
  80
818
848
  ),
819
- refractionStrength: h(
820
- r.refractionStrength ?? x.refractionStrength,
849
+ refractionStrength: d(
850
+ r.refractionStrength ?? E.refractionStrength,
821
851
  0,
822
852
  2.5
823
853
  ),
824
- specularIntensity: h(
825
- r.specularIntensity ?? x.specularIntensity,
854
+ specularIntensity: d(
855
+ r.specularIntensity ?? E.specularIntensity,
826
856
  0,
827
857
  3
828
858
  ),
829
- crestIntensity: h(
830
- r.crestIntensity ?? x.crestIntensity,
859
+ crestIntensity: d(
860
+ r.crestIntensity ?? E.crestIntensity,
831
861
  0,
832
862
  3
833
863
  ),
834
- causticIntensity: h(
835
- r.causticIntensity ?? x.causticIntensity,
864
+ causticIntensity: d(
865
+ r.causticIntensity ?? E.causticIntensity,
836
866
  0,
837
867
  3
838
868
  ),
839
- simulationResolution: h(
869
+ simulationResolution: d(
840
870
  Math.round(
841
- r.simulationResolution ?? x.simulationResolution
871
+ r.simulationResolution ?? E.simulationResolution
842
872
  ),
843
873
  64,
844
874
  384
845
875
  ),
846
- wakeStrength: h(
847
- r.wakeStrength ?? r.rippleStrength ?? e ?? x.wakeStrength,
876
+ wakeStrength: d(
877
+ r.wakeStrength ?? r.rippleStrength ?? e ?? E.wakeStrength,
848
878
  0,
849
879
  3
850
880
  ),
851
- interactionRadius: h(
852
- r.interactionRadius ?? x.interactionRadius,
881
+ interactionRadius: d(
882
+ r.interactionRadius ?? E.interactionRadius,
853
883
  2,
854
884
  80
855
885
  ),
856
- troughStrength: h(
857
- r.troughStrength ?? x.troughStrength,
886
+ troughStrength: d(
887
+ r.troughStrength ?? E.troughStrength,
858
888
  0,
859
889
  3
860
890
  ),
861
- ridgeStrength: h(
862
- r.ridgeStrength ?? x.ridgeStrength,
891
+ ridgeStrength: d(
892
+ r.ridgeStrength ?? E.ridgeStrength,
863
893
  0,
864
894
  3
865
895
  ),
866
- ridgeOffset: h(
867
- r.ridgeOffset ?? x.ridgeOffset,
896
+ ridgeOffset: d(
897
+ r.ridgeOffset ?? E.ridgeOffset,
868
898
  0,
869
899
  80
870
900
  ),
871
- wakeLength: h(
872
- r.wakeLength ?? x.wakeLength,
901
+ wakeLength: d(
902
+ r.wakeLength ?? E.wakeLength,
873
903
  1,
874
904
  240
875
905
  ),
876
- velocityScale: h(
877
- r.velocityScale ?? x.velocityScale,
906
+ velocityScale: d(
907
+ r.velocityScale ?? E.velocityScale,
878
908
  0.01,
879
909
  4
880
910
  ),
881
- velocityClamp: h(
882
- r.velocityClamp ?? x.velocityClamp,
911
+ velocityClamp: d(
912
+ r.velocityClamp ?? E.velocityClamp,
883
913
  0.05,
884
914
  8
885
915
  ),
886
- cursorSmoothing: h(
887
- r.cursorSmoothing ?? x.cursorSmoothing,
916
+ cursorSmoothing: d(
917
+ r.cursorSmoothing ?? E.cursorSmoothing,
888
918
  0,
889
919
  0.9
890
920
  ),
891
- segmentSpacing: h(
892
- r.segmentSpacing ?? x.segmentSpacing,
921
+ segmentSpacing: d(
922
+ r.segmentSpacing ?? E.segmentSpacing,
893
923
  1,
894
924
  96
895
925
  ),
896
- idleTimeout: Math.max(120, r.idleTimeout ?? x.idleTimeout),
897
- interactionMode: r.interactionMode ?? x.interactionMode,
898
- runInBackground: r.runInBackground ?? x.runInBackground,
899
- pauseKey: r.pauseKey || x.pauseKey
926
+ idleTimeout: Math.max(120, r.idleTimeout ?? E.idleTimeout),
927
+ interactionMode: r.interactionMode ?? E.interactionMode,
928
+ runInBackground: r.runInBackground ?? E.runInBackground,
929
+ pauseKey: r.pauseKey || E.pauseKey
900
930
  };
901
931
  }
902
- function Ce(r, e, n) {
903
- const t = h(r.x, 0, 1) * n.width, i = h(r.y, 0, 1) * n.height, a = Math.max(0.5, e.interactionRadius * 0.08), l = e.velocityClamp / e.velocityScale, c = {
932
+ function We(r, e, n) {
933
+ const t = d(r.x, 0, 1) * n.width, i = d(r.y, 0, 1) * n.height, a = Math.max(0.5, e.interactionRadius * 0.08), s = e.velocityClamp / e.velocityScale, u = {
904
934
  ...e,
905
935
  width: n.width,
906
936
  height: n.height,
907
937
  wakeLength: e.interactionRadius * 1.5
908
938
  };
909
939
  return [
910
- ve(
940
+ xe(
911
941
  { x: t - a, y: i },
912
942
  { x: t + a, y: i },
913
- l,
914
- c
943
+ s,
944
+ u
915
945
  ),
916
- ve(
946
+ xe(
917
947
  { x: t, y: i - a },
918
948
  { x: t, y: i + a },
919
- l,
920
- c
949
+ s,
950
+ u
921
951
  )
922
952
  ];
923
953
  }
924
- function mt(r) {
925
- const [e, n] = je(!1);
926
- return V(() => {
954
+ function xt(r) {
955
+ const [e, n] = Ze(!1);
956
+ return q(() => {
927
957
  if (!r || typeof window > "u" || !window.matchMedia) {
928
958
  n(!1);
929
959
  return;
@@ -938,71 +968,72 @@ function mt(r) {
938
968
  };
939
969
  }, [r]), e;
940
970
  }
941
- const gt = $e(function(e, n) {
971
+ const pt = Qe(function(e, n) {
942
972
  const {
943
973
  underlay: t,
944
974
  children: i,
945
975
  foreground: a,
946
- className: l,
947
- style: c,
948
- reducedMotion: s = "respect"
949
- } = e, d = y(null), E = y(null), _ = y(null), m = y(new ct()), v = y(null), A = y(null), w = y(() => {
950
- }), W = y(() => {
951
- }), H = y(() => {
952
- }), P = y([]), U = y(!0), k = y(!0), B = y(!1), M = y(!1), I = y(null), z = y(0), N = y(0), D = y(0), R = ft(e), g = y(R), $ = y({ width: 1, height: 1 }), Ne = mt(
953
- s === "respect"
954
- ), ue = s === "disable" || s === "respect" && Ne, Xe = a ?? i;
955
- g.current = R, Qe(
976
+ className: s,
977
+ style: u,
978
+ reducedMotion: c = "respect"
979
+ } = e, h = R(null), v = R(null), x = R(null), m = R(new ht()), p = R(null), A = R(null), w = R(() => {
980
+ }), N = R(() => {
981
+ }), H = R(() => {
982
+ }), P = R([]), U = R(!0), k = R(!0), B = R(!1), b = R(!1), I = R(null), z = R(0), W = R(0), D = R(0), T = vt(e), g = R(T), Q = R({ width: 1, height: 1 }), Ge = xt(
983
+ c === "respect"
984
+ ), ue = c === "disable" || c === "respect" && Ge, Oe = a ?? i;
985
+ g.current = T, je(
956
986
  n,
957
987
  () => ({
958
988
  triggerRipple(S) {
959
- B.current || M.current || H.current(
960
- Ce(
989
+ B.current || b.current || H.current(
990
+ We(
961
991
  S,
962
992
  g.current,
963
- $.current
993
+ Q.current
964
994
  )
965
995
  );
966
996
  }
967
997
  }),
968
998
  []
969
- ), V(() => {
999
+ ), q(() => {
970
1000
  var S;
971
- B.current = ue, ue && (m.current.reset(), I.current = null, P.current = [], z.current = 0, N.current = 0, D.current = 0, (S = _.current) == null || S.clear()), w.current();
972
- }, [ue]), V(() => {
973
- const S = _.current;
1001
+ B.current = ue, ue && (m.current.reset(), I.current = null, P.current = [], z.current = 0, W.current = 0, D.current = 0, (S = x.current) == null || S.clear()), w.current();
1002
+ }, [ue]), q(() => {
1003
+ const S = x.current;
974
1004
  if (!S)
975
1005
  return;
976
- const { width: K, height: b } = $.current;
1006
+ const { width: K, height: M } = Q.current;
977
1007
  S.resize(
978
1008
  K,
979
- b,
1009
+ M,
980
1010
  window.devicePixelRatio,
981
- R.simulationResolution
982
- ), S.setTextureSource(R.texture), w.current();
1011
+ T.simulationResolution
1012
+ ), S.setTextureSource(T.texture), w.current();
983
1013
  }, [
984
- R.mode,
985
- R.texture,
986
- R.damping,
987
- R.waveSpeed,
988
- R.normalScale,
989
- R.refractionStrength,
990
- R.specularIntensity,
991
- R.crestIntensity,
992
- R.causticIntensity,
993
- R.simulationResolution
994
- ]), V(() => {
995
- const S = d.current, K = E.current;
1014
+ T.mode,
1015
+ T.texture,
1016
+ T.textureFit,
1017
+ T.damping,
1018
+ T.waveSpeed,
1019
+ T.normalScale,
1020
+ T.refractionStrength,
1021
+ T.specularIntensity,
1022
+ T.crestIntensity,
1023
+ T.causticIntensity,
1024
+ T.simulationResolution
1025
+ ]), q(() => {
1026
+ const S = h.current, K = v.current;
996
1027
  if (!S || !K)
997
1028
  return;
998
1029
  k.current = typeof document.hasFocus == "function" ? document.hasFocus() : !0;
999
- let b = null, ie, ee = G, xe = !1, te;
1030
+ let M = null, ae, te = G, pe = !1, re;
1000
1031
  const Y = () => {
1001
- v.current !== null && (window.cancelAnimationFrame(v.current), v.current = null), A.current !== null && (window.clearTimeout(A.current), A.current = null);
1002
- }, Oe = (o, u) => {
1032
+ p.current !== null && (window.cancelAnimationFrame(p.current), p.current = null), A.current !== null && (window.clearTimeout(A.current), A.current = null);
1033
+ }, ze = (o, l) => {
1003
1034
  m.current.configure({
1004
1035
  width: o,
1005
- height: u,
1036
+ height: l,
1006
1037
  interactionRadius: g.current.interactionRadius,
1007
1038
  wakeStrength: g.current.wakeStrength,
1008
1039
  troughStrength: g.current.troughStrength,
@@ -1014,56 +1045,56 @@ const gt = $e(function(e, n) {
1014
1045
  cursorSmoothing: g.current.cursorSmoothing,
1015
1046
  segmentSpacing: g.current.segmentSpacing
1016
1047
  });
1017
- }, He = (o, u) => {
1018
- const F = Math.max(1, o), T = Math.max(1, u);
1019
- $.current = { width: F, height: T }, Oe(F, T), b == null || b.resize(
1048
+ }, Ke = (o, l) => {
1049
+ const F = Math.max(1, o), y = Math.max(1, l);
1050
+ Q.current = { width: F, height: y }, ze(F, y), M == null || M.resize(
1020
1051
  F,
1021
- T,
1052
+ y,
1022
1053
  window.devicePixelRatio,
1023
1054
  g.current.simulationResolution
1024
1055
  );
1025
- }, pe = () => {
1026
- b == null || b.render(g.current, performance.now() * 1e-3);
1056
+ }, Ee = () => {
1057
+ M == null || M.render(g.current, performance.now() * 1e-3);
1027
1058
  }, X = () => {
1028
- ie = void 0, ee = G;
1029
- }, re = () => {
1030
- Y(), m.current.reset(), I.current = null, X(), te === void 0 && (te = performance.now());
1031
- }, Q = () => {
1059
+ ae = void 0, te = G;
1060
+ }, ne = () => {
1061
+ Y(), m.current.reset(), I.current = null, X(), re === void 0 && (re = performance.now());
1062
+ }, j = () => {
1032
1063
  const o = g.current;
1033
- let u = !1;
1034
- if (!(!B.current && !M.current && U.current && (o.runInBackground || !document.hidden && k.current))) {
1064
+ let l = !1;
1065
+ if (!(!B.current && !b.current && U.current && (o.runInBackground || !document.hidden && k.current))) {
1035
1066
  X();
1036
1067
  return;
1037
1068
  }
1038
- if (te !== void 0) {
1039
- const T = performance.now() - te;
1040
- z.current += T, N.current += T, D.current += T, te = void 0, u = !0;
1069
+ if (re !== void 0) {
1070
+ const y = performance.now() - re;
1071
+ z.current += y, W.current += y, D.current += y, re = void 0, l = !0;
1041
1072
  }
1042
- (!o.runInBackground || u) && X(), pe(), w.current();
1043
- }, Ee = (o) => {
1044
- v.current = null;
1045
- const u = g.current;
1046
- if (!b || M.current || !U.current || !u.runInBackground && (document.hidden || !k.current)) {
1073
+ (!o.runInBackground || l) && X(), Ee(), w.current();
1074
+ }, _e = (o) => {
1075
+ p.current = null;
1076
+ const l = g.current;
1077
+ if (!M || b.current || !U.current || !l.runInBackground && (document.hidden || !k.current)) {
1047
1078
  X();
1048
1079
  return;
1049
1080
  }
1050
1081
  if (B.current) {
1051
- P.current = [], b.render(u, o * 1e-3), X();
1082
+ P.current = [], M.render(l, o * 1e-3), X();
1052
1083
  return;
1053
1084
  }
1054
- const F = u.runInBackground ? Pe : lt, T = ie === void 0 ? G : h(
1055
- o - ie,
1085
+ const F = l.runInBackground ? Ce : ft, y = ae === void 0 ? G : d(
1086
+ o - ae,
1056
1087
  0,
1057
- u.runInBackground ? G * Pe : 64
1088
+ l.runInBackground ? G * Ce : 64
1058
1089
  );
1059
- ie = o, ee = Math.min(
1060
- ee + T,
1090
+ ae = o, te = Math.min(
1091
+ te + y,
1061
1092
  G * F
1062
1093
  );
1063
- let Z = P.current.splice(0), be = 0;
1064
- for (; ee >= G && be < F; )
1065
- b.step(Z, u, 1), Z = [], ee -= G, be += 1;
1066
- if (b.render(u, o * 1e-3), P.current.length > 0) {
1094
+ let J = P.current.splice(0), Ie = 0;
1095
+ for (; te >= G && Ie < F; )
1096
+ M.step(J, l, 1), J = [], te -= G, Ie += 1;
1097
+ if (M.render(l, o * 1e-3), P.current.length > 0) {
1067
1098
  w.current();
1068
1099
  return;
1069
1100
  }
@@ -1071,8 +1102,8 @@ const gt = $e(function(e, n) {
1071
1102
  w.current();
1072
1103
  return;
1073
1104
  }
1074
- if (xe) {
1075
- o < N.current ? w.current() : X();
1105
+ if (pe) {
1106
+ o < W.current ? w.current() : X();
1076
1107
  return;
1077
1108
  }
1078
1109
  if (o < D.current) {
@@ -1080,122 +1111,122 @@ const gt = $e(function(e, n) {
1080
1111
  return;
1081
1112
  }
1082
1113
  try {
1083
- b.hasVisibleActivity() ? (D.current = o + ht, w.current()) : X();
1114
+ M.hasVisibleActivity() ? (D.current = o + mt, w.current()) : X();
1084
1115
  } catch {
1085
- xe = !0, o < N.current ? w.current() : X();
1116
+ pe = !0, o < W.current ? w.current() : X();
1086
1117
  }
1087
1118
  }, le = () => {
1088
- M.current || v.current !== null || A.current !== null || (g.current.runInBackground && document.hidden ? A.current = window.setTimeout(() => {
1089
- A.current = null, Ee(performance.now());
1090
- }, G) : v.current = window.requestAnimationFrame(Ee));
1119
+ b.current || p.current !== null || A.current !== null || (g.current.runInBackground && document.hidden ? A.current = window.setTimeout(() => {
1120
+ A.current = null, _e(performance.now());
1121
+ }, G) : p.current = window.requestAnimationFrame(_e));
1091
1122
  };
1092
1123
  w.current = le;
1093
1124
  try {
1094
- b = new rt(K, () => {
1125
+ M = new nt(K, () => {
1095
1126
  w.current();
1096
- }), _.current = b, b.setTextureSource(g.current.texture);
1127
+ }), x.current = M, M.setTextureSource(g.current.texture);
1097
1128
  } catch {
1098
- return K.style.display = "none", _.current = null, w.current = () => {
1129
+ return K.style.display = "none", x.current = null, w.current = () => {
1099
1130
  }, () => {
1100
1131
  };
1101
1132
  }
1102
- const ae = () => {
1133
+ const he = () => {
1103
1134
  const o = K.getBoundingClientRect();
1104
- return He(o.width, o.height), o;
1105
- }, ze = () => {
1106
- ae(), pe();
1107
- }, he = (o) => {
1108
- if (M.current || o.length === 0)
1135
+ return Ke(o.width, o.height), o;
1136
+ }, Se = () => {
1137
+ he(), Ee();
1138
+ }, de = (o) => {
1139
+ if (b.current || o.length === 0)
1109
1140
  return;
1110
- const u = P.current;
1111
- for (const Z of o)
1112
- u.push(Z);
1113
- u.length > Be && u.splice(0, u.length - Be);
1114
- const T = performance.now() + g.current.idleTimeout;
1115
- z.current = Math.max(z.current, T), N.current = Math.max(
1116
- N.current,
1117
- T + ut(g.current.damping)
1141
+ const l = P.current;
1142
+ for (const J of o)
1143
+ l.push(J);
1144
+ l.length > Ne && l.splice(0, l.length - Ne);
1145
+ const y = performance.now() + g.current.idleTimeout;
1146
+ z.current = Math.max(z.current, y), W.current = Math.max(
1147
+ W.current,
1148
+ y + dt(g.current.damping)
1118
1149
  ), D.current = 0, le();
1119
1150
  };
1120
- H.current = he;
1121
- const _e = (o) => {
1122
- const u = g.current;
1123
- if (B.current || M.current || !U.current || u.interactionMode === "event" || !u.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
1151
+ H.current = de;
1152
+ const Te = (o) => {
1153
+ const l = g.current;
1154
+ if (B.current || b.current || !U.current || l.interactionMode === "event" || !l.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
1124
1155
  return;
1125
1156
  m.current.reset();
1126
- const F = ae(), [T] = Ue(o, F, performance.now());
1127
- T && ((u.interactionMode === "click" || u.interactionMode === "drag") && he(
1128
- Ce(
1157
+ const F = he(), [y] = Pe(o, F, performance.now());
1158
+ y && ((l.interactionMode === "click" || l.interactionMode === "drag") && de(
1159
+ We(
1129
1160
  {
1130
- x: T.x / $.current.width,
1131
- y: T.y / $.current.height
1161
+ x: y.x / Q.current.width,
1162
+ y: y.y / Q.current.height
1132
1163
  },
1133
- u,
1134
- $.current
1164
+ l,
1165
+ Q.current
1135
1166
  )
1136
- ), u.interactionMode === "drag" ? (I.current = o.pointerId, m.current.addSample(T)) : u.interactionMode === "move" && m.current.addSample(T));
1137
- }, Se = (o) => {
1138
- const u = g.current;
1139
- if (B.current || M.current || !U.current || u.interactionMode !== "move" && (u.interactionMode !== "drag" || I.current !== o.pointerId) || !u.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
1167
+ ), l.interactionMode === "drag" ? (I.current = o.pointerId, m.current.addSample(y)) : l.interactionMode === "move" && m.current.addSample(y));
1168
+ }, ye = (o) => {
1169
+ const l = g.current;
1170
+ if (B.current || b.current || !U.current || l.interactionMode !== "move" && (l.interactionMode !== "drag" || I.current !== o.pointerId) || !l.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
1140
1171
  return;
1141
- const F = ae(), T = Ue(o, F, performance.now());
1142
- for (const Z of T)
1143
- he(m.current.addSample(Z));
1144
- }, j = (o) => {
1172
+ const F = he(), y = Pe(o, F, performance.now());
1173
+ for (const J of y)
1174
+ de(m.current.addSample(J));
1175
+ }, Z = (o) => {
1145
1176
  I.current !== null && I.current !== o.pointerId || (I.current = null, m.current.reset());
1146
- }, Te = (o) => {
1147
- const u = g.current.pauseKey;
1148
- !u || o.code !== u || o.repeat || o.altKey || o.ctrlKey || o.metaKey || dt(o.target) || (o.preventDefault(), M.current = !M.current, M.current ? re() : (Y(), Q()));
1149
- }, ye = () => {
1150
- Y(), document.hidden && !g.current.runInBackground ? re() : Q();
1151
- }, Re = () => {
1152
- k.current = !1, g.current.runInBackground ? (Y(), Q()) : re();
1177
+ }, Re = (o) => {
1178
+ const l = g.current.pauseKey;
1179
+ !l || o.code !== l || o.repeat || o.altKey || o.ctrlKey || o.metaKey || gt(o.target) || (o.preventDefault(), b.current = !b.current, b.current ? ne() : (Y(), j()));
1153
1180
  }, we = () => {
1154
- k.current = !0, Y(), Q();
1155
- }, Ke = () => {
1156
- Y(), !g.current.runInBackground && (document.hidden || !k.current) ? re() : Q();
1181
+ Y(), document.hidden && !g.current.runInBackground ? ne() : j();
1182
+ }, be = () => {
1183
+ k.current = !1, g.current.runInBackground ? (Y(), j()) : ne();
1184
+ }, Me = () => {
1185
+ k.current = !0, Y(), j();
1186
+ }, Ye = () => {
1187
+ Y(), !g.current.runInBackground && (document.hidden || !k.current) ? ne() : j();
1157
1188
  };
1158
- W.current = Ke, ze();
1159
- const Me = new ResizeObserver(() => {
1160
- ae(), le();
1189
+ N.current = Ye, Se();
1190
+ const Ae = new ResizeObserver(() => {
1191
+ Se(), le();
1161
1192
  });
1162
- Me.observe(K);
1163
- let ne;
1164
- return "IntersectionObserver" in window && (ne = new IntersectionObserver((o) => {
1165
- const u = o[0];
1166
- U.current = u ? u.isIntersecting : !0, U.current ? Q() : re();
1167
- }), ne.observe(S)), S.addEventListener("pointerdown", _e, {
1193
+ Ae.observe(K);
1194
+ let ie;
1195
+ return "IntersectionObserver" in window && (ie = new IntersectionObserver((o) => {
1196
+ const l = o[0];
1197
+ U.current = l ? l.isIntersecting : !0, U.current ? j() : ne();
1198
+ }), ie.observe(S)), S.addEventListener("pointerdown", Te, {
1168
1199
  passive: !0
1169
- }), S.addEventListener("pointermove", Se, {
1200
+ }), S.addEventListener("pointermove", ye, {
1170
1201
  passive: !0
1171
- }), S.addEventListener("pointerup", j, {
1202
+ }), S.addEventListener("pointerup", Z, {
1172
1203
  passive: !0
1173
- }), S.addEventListener("pointerleave", j, {
1204
+ }), S.addEventListener("pointerleave", Z, {
1174
1205
  passive: !0
1175
- }), S.addEventListener("pointercancel", j, {
1206
+ }), S.addEventListener("pointercancel", Z, {
1176
1207
  passive: !0
1177
- }), window.addEventListener("blur", Re), window.addEventListener("focus", we), document.addEventListener("keydown", Te), document.addEventListener("visibilitychange", ye), () => {
1208
+ }), window.addEventListener("blur", be), window.addEventListener("focus", Me), document.addEventListener("keydown", Re), document.addEventListener("visibilitychange", we), () => {
1178
1209
  var o;
1179
- Y(), Me.disconnect(), ne == null || ne.disconnect(), S.removeEventListener("pointerdown", _e), S.removeEventListener("pointermove", Se), S.removeEventListener("pointerup", j), S.removeEventListener("pointerleave", j), S.removeEventListener("pointercancel", j), window.removeEventListener("blur", Re), window.removeEventListener("focus", we), document.removeEventListener("keydown", Te), document.removeEventListener("visibilitychange", ye), (o = _.current) == null || o.dispose(), _.current = null, w.current = () => {
1180
- }, W.current = () => {
1210
+ Y(), Ae.disconnect(), ie == null || ie.disconnect(), S.removeEventListener("pointerdown", Te), S.removeEventListener("pointermove", ye), S.removeEventListener("pointerup", Z), S.removeEventListener("pointerleave", Z), S.removeEventListener("pointercancel", Z), window.removeEventListener("blur", be), window.removeEventListener("focus", Me), document.removeEventListener("keydown", Re), document.removeEventListener("visibilitychange", we), (o = x.current) == null || o.dispose(), x.current = null, w.current = () => {
1211
+ }, N.current = () => {
1181
1212
  }, H.current = () => {
1182
1213
  };
1183
1214
  };
1184
- }, []), V(() => {
1215
+ }, []), q(() => {
1185
1216
  m.current.reset(), I.current = null;
1186
- }, [R.interactionMode]), V(() => {
1187
- W.current();
1188
- }, [R.runInBackground]), V(() => {
1189
- !R.pauseKey && M.current && (M.current = !1, W.current());
1190
- }, [R.pauseKey]);
1191
- const Ge = {
1192
- ...c,
1217
+ }, [T.interactionMode]), q(() => {
1218
+ N.current();
1219
+ }, [T.runInBackground]), q(() => {
1220
+ !T.pauseKey && b.current && (b.current = !1, N.current());
1221
+ }, [T.pauseKey]);
1222
+ const He = {
1223
+ ...u,
1193
1224
  position: "relative",
1194
1225
  overflow: "hidden",
1195
1226
  isolation: "isolate"
1196
1227
  };
1197
- return /* @__PURE__ */ qe("div", { ref: d, className: l, style: Ge, children: [
1198
- t ? /* @__PURE__ */ de(
1228
+ return /* @__PURE__ */ $e("div", { ref: h, className: s, style: He, children: [
1229
+ t ? /* @__PURE__ */ fe(
1199
1230
  "div",
1200
1231
  {
1201
1232
  style: {
@@ -1208,10 +1239,10 @@ const gt = $e(function(e, n) {
1208
1239
  children: t
1209
1240
  }
1210
1241
  ) : null,
1211
- /* @__PURE__ */ de(
1242
+ /* @__PURE__ */ fe(
1212
1243
  "canvas",
1213
1244
  {
1214
- ref: E,
1245
+ ref: v,
1215
1246
  "aria-hidden": "true",
1216
1247
  style: {
1217
1248
  position: "absolute",
@@ -1220,24 +1251,24 @@ const gt = $e(function(e, n) {
1220
1251
  width: "100%",
1221
1252
  height: "100%",
1222
1253
  pointerEvents: "none",
1223
- mixBlendMode: R.mode === "dom" ? "screen" : "normal"
1254
+ mixBlendMode: T.mode === "dom" ? "screen" : "normal"
1224
1255
  }
1225
1256
  }
1226
1257
  ),
1227
- /* @__PURE__ */ de(
1258
+ /* @__PURE__ */ fe(
1228
1259
  "div",
1229
1260
  {
1230
1261
  style: {
1231
1262
  position: "relative",
1232
1263
  zIndex: 2
1233
1264
  },
1234
- children: Xe
1265
+ children: Oe
1235
1266
  }
1236
1267
  )
1237
1268
  ] });
1238
- }), Et = gt;
1269
+ }), Tt = pt;
1239
1270
  export {
1240
- gt as WaterDistortion,
1241
- Et as WaterLayer
1271
+ pt as WaterDistortion,
1272
+ Tt as WaterLayer
1242
1273
  };
1243
1274
  //# sourceMappingURL=water-distortion.js.map