kuinetic 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -10
- package/dist/esm/advanced/index.mjs +4727 -0
- package/dist/esm/chunk-AEQGC2KM.mjs +189 -0
- package/dist/esm/chunk-MQSNMYRP.mjs +9332 -0
- package/dist/esm/chunk-RVTYN6NZ.mjs +3446 -0
- package/dist/esm/chunk-U43BX5O2.mjs +2984 -0
- package/dist/esm/core/index.mjs +16 -9
- package/dist/esm/effects/index.mjs +19 -4
- package/dist/esm/index.mjs +17 -10
- package/dist/kuinetic.advanced.js +5070 -0
- package/dist/kuinetic.advanced.min.js +749 -0
- package/dist/kuinetic.all.js +15218 -5595
- package/dist/kuinetic.all.min.js +2 -0
- package/dist/kuinetic.css +2900 -360
- package/dist/kuinetic.js +15217 -5593
- package/dist/kuinetic.min.css +1 -0
- package/dist/kuinetic.min.js +7 -0
- package/dist/types/3d/angles.d.ts +30 -0
- package/dist/types/3d/flattening.d.ts +49 -0
- package/dist/types/3d/index.d.ts +36 -0
- package/dist/types/3d/model-3d.d.ts +115 -0
- package/dist/types/3d/register.d.ts +26 -0
- package/dist/types/3d/webgl.d.ts +24 -0
- package/dist/types/advanced/audio.d.ts +322 -0
- package/dist/types/advanced/base.d.ts +233 -0
- package/dist/types/advanced/camera-3d.d.ts +236 -0
- package/dist/types/advanced/fluid-cursor.d.ts +149 -0
- package/dist/types/advanced/gl-utils.d.ts +52 -0
- package/dist/types/advanced/glsl.d.ts +60 -0
- package/dist/types/advanced/index.d.ts +23 -0
- package/dist/types/advanced/particles.d.ts +108 -0
- package/dist/types/advanced/scenes.d.ts +207 -0
- package/dist/types/advanced/shaders.d.ts +972 -0
- package/dist/types/browser/boot.d.ts +72 -0
- package/dist/types/core/activation.d.ts +227 -2
- package/dist/types/core/animator.d.ts +446 -11
- package/dist/types/core/attrs.d.ts +9 -0
- package/dist/types/core/breakpoints.d.ts +260 -0
- package/dist/types/core/bundles.d.ts +71 -0
- package/dist/types/core/callback.d.ts +64 -0
- package/dist/types/core/capabilities.d.ts +47 -0
- package/dist/types/core/channels.d.ts +120 -2
- package/dist/types/core/cloak-selectors.d.ts +47 -0
- package/dist/types/core/compile.d.ts +207 -2
- package/dist/types/core/control.d.ts +218 -0
- package/dist/types/core/declarations.d.ts +128 -0
- package/dist/types/core/derived/aggregate.d.ts +43 -0
- package/dist/types/core/derived/book.d.ts +30 -0
- package/dist/types/core/derived/diagnostics.d.ts +51 -0
- package/dist/types/core/derived/group-gate.d.ts +62 -0
- package/dist/types/core/derived/install.d.ts +110 -0
- package/dist/types/core/derived/late-matches.d.ts +19 -0
- package/dist/types/core/derived/types.d.ts +108 -0
- package/dist/types/core/easing.d.ts +57 -0
- package/dist/types/core/element-config.d.ts +47 -6
- package/dist/types/core/element-size.d.ts +23 -0
- package/dist/types/core/event-sources.d.ts +39 -0
- package/dist/types/core/flip.d.ts +34 -1
- package/dist/types/core/gesture.d.ts +12 -0
- package/dist/types/core/host-facts.d.ts +155 -0
- package/dist/types/core/index.d.ts +7 -3
- package/dist/types/core/owned-styles.d.ts +129 -2
- package/dist/types/core/params.d.ts +48 -0
- package/dist/types/core/parse.d.ts +28 -1
- package/dist/types/core/register-into.d.ts +29 -0
- package/dist/types/core/registry.d.ts +10 -3
- package/dist/types/core/repeat.d.ts +91 -0
- package/dist/types/core/sequence.d.ts +126 -0
- package/dist/types/core/stagger-config.d.ts +199 -0
- package/dist/types/core/stagger-keys.d.ts +63 -0
- package/dist/types/core/stagger.d.ts +187 -6
- package/dist/types/core/style-plan.d.ts +21 -16
- package/dist/types/core/target.d.ts +128 -0
- package/dist/types/core/threshold-reachability.d.ts +45 -0
- package/dist/types/core/time-scale.d.ts +9 -0
- package/dist/types/core/toggle-actions.d.ts +141 -0
- package/dist/types/core/travel.d.ts +59 -0
- package/dist/types/core/types.d.ts +705 -13
- package/dist/types/core/unquoted-selectors.d.ts +53 -0
- package/dist/types/effects/carousel/drag.d.ts +80 -0
- package/dist/types/effects/carousel/index.d.ts +149 -0
- package/dist/types/effects/catalog/background-media.d.ts +152 -0
- package/dist/types/effects/catalog/discrete.d.ts +13 -0
- package/dist/types/effects/catalog/interaction-proximity.d.ts +24 -0
- package/dist/types/effects/catalog/interaction-reveal.d.ts +248 -0
- package/dist/types/effects/catalog/interaction-shared.d.ts +42 -0
- package/dist/types/effects/catalog/interaction-states.d.ts +68 -0
- package/dist/types/effects/catalog/materials.d.ts +67 -0
- package/dist/types/effects/catalog/media-shared.d.ts +3 -2
- package/dist/types/effects/catalog/numbers-shared.d.ts +8 -5
- package/dist/types/effects/catalog/shared.d.ts +2 -2
- package/dist/types/effects/catalog/text-shared.d.ts +92 -10
- package/dist/types/effects/catalog/transforms.d.ts +13 -0
- package/dist/types/effects/catalog/view-transitions.d.ts +13 -0
- package/dist/types/effects/forms/primitives.d.ts +15 -4
- package/dist/types/effects/gestures/index.d.ts +53 -0
- package/dist/types/effects/index.d.ts +5 -0
- package/dist/types/effects/layout/presets.d.ts +35 -0
- package/dist/types/effects/motion-path/index.d.ts +35 -0
- package/dist/types/effects/scroll-mechanics/params.d.ts +23 -0
- package/dist/types/effects/scroll-mechanics/presets.d.ts +51 -0
- package/dist/types/effects/scroll-mechanics/section-index.d.ts +47 -0
- package/dist/types/effects/shared.d.ts +162 -2
- package/dist/types/effects/step-index.d.ts +121 -0
- package/dist/types/effects/step-marking.d.ts +41 -33
- package/dist/types/effects/svg/icon-parts.d.ts +23 -0
- package/dist/types/effects/three-d/flip-parts.d.ts +46 -0
- package/dist/types/effects/tween/index.d.ts +57 -0
- package/dist/types/effects/tween/properties.d.ts +107 -0
- package/dist/types/effects/tween/waypoints.d.ts +106 -0
- package/dist/types/showcase/compare.d.ts +4 -0
- package/dist/types/showcase/device-frame.d.ts +3 -0
- package/dist/types/showcase/hotspots.d.ts +3 -0
- package/dist/types/showcase/index.d.ts +30 -0
- package/dist/types/showcase/lightbox.d.ts +3 -0
- package/dist/types/showcase/media-source.d.ts +13 -0
- package/dist/types/showcase/modal-shell.d.ts +22 -0
- package/dist/types/showcase/scroll-story.d.ts +4 -0
- package/dist/types/showcase/shared.d.ts +47 -0
- package/dist/types/showcase/slideshow.d.ts +3 -0
- package/dist/types/showcase/slow-mo.d.ts +5 -0
- package/package.json +14 -7
- package/dist/esm/chunk-5DON3UFQ.mjs +0 -4380
- package/dist/esm/chunk-JT4PZL3A.mjs +0 -773
- package/dist/esm/chunk-QUVFODSQ.mjs +0 -1278
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
"use strict";var kuineticAdvanced=(()=>{var K=Object.defineProperty;var Ft=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Wt=Object.prototype.hasOwnProperty;var Ot=(e,t)=>{for(var n in t)K(e,n,{get:t[n],enumerable:!0})},Dt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Gt(t))!Wt.call(e,i)&&i!==n&&K(e,i,{get:()=>t[i],enumerable:!(r=Ft(t,i))||r.enumerable});return e};var Ut=e=>Dt(K({},"__esModule",{value:!0}),e);var Jr={};Ot(Jr,{AUDIO_PARAMETERS:()=>te,AUDIO_PRESETS:()=>re,AUDIO_PRIMITIVES:()=>ne,AudioSourceController:()=>T,CAMERA_PARAMETERS:()=>Le,CAMERA_PRESETS:()=>Re,CAMERA_PRIMITIVES:()=>Ee,FLUID_PARAMETERS:()=>Ge,FLUID_PRESETS:()=>Oe,FLUID_PRIMITIVES:()=>We,PARTICLE_PARAMETERS:()=>Ce,PARTICLE_PRESETS:()=>Te,PARTICLE_PRIMITIVES:()=>Ae,SCENE_PARAMETERS:()=>be,SCENE_PRESETS:()=>xe,SCENE_PRIMITIVES:()=>ye,SHADERS_PRESETS:()=>pe,SHADERS_PRIMITIVE:()=>fe,SHADER_PARAMETERS:()=>he,prepareAudioSource:()=>ee,prepareCameraScene:()=>_e,prepareFluidCursor:()=>Fe,prepareParticles:()=>Se,prepareScene:()=>ge,prepareShaders:()=>me,registerAdvanced:()=>Qr,registerAudio:()=>O,registerCamera:()=>$,registerFluidCursor:()=>Y,registerParticles:()=>X,registerScenes:()=>V,registerShaders:()=>z});var R=`uniform float u_audio;
|
|
2
|
+
float audioGain() { return 1.0 + clamp(u_audio, 0.0, 1.0); }
|
|
3
|
+
`,k=`uniform vec4 u_maskBox;
|
|
4
|
+
uniform vec4 u_maskRx;
|
|
5
|
+
uniform vec4 u_maskRy;
|
|
6
|
+
uniform float u_maskAlpha;
|
|
7
|
+
float shapeMask() {
|
|
8
|
+
if (u_maskBox.z <= 0.0 || u_maskBox.w <= 0.0) return u_maskAlpha;
|
|
9
|
+
vec2 p = gl_FragCoord.xy - u_maskBox.xy;
|
|
10
|
+
vec2 h = u_maskBox.zw;
|
|
11
|
+
bool left = p.x < 0.0;
|
|
12
|
+
float rx = p.y >= 0.0 ? (left ? u_maskRx.x : u_maskRx.y) : (left ? u_maskRx.w : u_maskRx.z);
|
|
13
|
+
float ry = p.y >= 0.0 ? (left ? u_maskRy.x : u_maskRy.y) : (left ? u_maskRy.w : u_maskRy.z);
|
|
14
|
+
rx = min(rx, h.x);
|
|
15
|
+
ry = min(ry, h.y);
|
|
16
|
+
if (rx <= 0.0 || ry <= 0.0) return u_maskAlpha;
|
|
17
|
+
vec2 q = abs(p) - (h - vec2(rx, ry));
|
|
18
|
+
if (q.x <= 0.0 || q.y <= 0.0) return u_maskAlpha;
|
|
19
|
+
float d = (length(q / vec2(rx, ry)) - 1.0) * min(rx, ry);
|
|
20
|
+
return u_maskAlpha * clamp(0.5 - d, 0.0, 1.0);
|
|
21
|
+
}
|
|
22
|
+
`,C=`const int KUI_MAX_OCTAVES = 6;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Integer avalanche over one lattice coordinate.
|
|
26
|
+
*
|
|
27
|
+
* Deliberately not the \`fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453)\` idiom. That relies
|
|
28
|
+
* on the low bits of a large sine, which \`highp\` does not reliably have: on several mobile GPUs
|
|
29
|
+
* neighbouring cells stay correlated and the field bands visibly. GLSL ES 3.00 has real unsigned
|
|
30
|
+
* integer arithmetic, so a proper mix is both better distributed and cheaper.
|
|
31
|
+
*/
|
|
32
|
+
uint kuiHash(uvec3 v) {
|
|
33
|
+
uint h = v.x * 0x8da6b343u ^ v.y * 0xd8163841u ^ v.z * 0xcb1ab31fu;
|
|
34
|
+
h ^= h >> 15u; h *= 0x2c1b3c6du;
|
|
35
|
+
h ^= h >> 12u; h *= 0x297a2d39u;
|
|
36
|
+
h ^= h >> 15u;
|
|
37
|
+
return h;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A unit gradient vector for one lattice corner.
|
|
42
|
+
*
|
|
43
|
+
* The three components read *non-overlapping* 10-bit fields. Overlapping slices of one hash are
|
|
44
|
+
* correlated with each other, which shows up as gradients clustering around a diagonal and the
|
|
45
|
+
* noise developing a directional grain. The \`1e-5\` keeps \`normalize\` defined for the one input
|
|
46
|
+
* that hashes to exactly zero.
|
|
47
|
+
*/
|
|
48
|
+
vec3 kuiGradient(uvec3 cell) {
|
|
49
|
+
uint h = kuiHash(cell);
|
|
50
|
+
vec3 g = vec3(
|
|
51
|
+
float((h ) & 1023u),
|
|
52
|
+
float((h >> 10u ) & 1023u),
|
|
53
|
+
float((h >> 20u ) & 1023u)
|
|
54
|
+
) * (2.0 / 1023.0) - 1.0;
|
|
55
|
+
return normalize(g + vec3(1e-5));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* One octave of gradient noise, approximately -1..1.
|
|
60
|
+
*
|
|
61
|
+
* The lattice index is biased into unsigned space before hashing: seeds, scroll and a centred UV
|
|
62
|
+
* field all reach negative coordinates, and \`uvec3\` of a negative \`ivec3\` wraps \u2014 which is
|
|
63
|
+
* harmless for a hash, but only once every negative input maps somewhere distinct rather than
|
|
64
|
+
* folding onto its positive twin.
|
|
65
|
+
*/
|
|
66
|
+
float kuiNoise(vec3 p) {
|
|
67
|
+
vec3 i = floor(p);
|
|
68
|
+
vec3 f = p - i;
|
|
69
|
+
vec3 w = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);
|
|
70
|
+
uvec3 c = uvec3(ivec3(i) + 0x10000);
|
|
71
|
+
float n000 = dot(kuiGradient(c + uvec3(0u, 0u, 0u)), f - vec3(0.0, 0.0, 0.0));
|
|
72
|
+
float n100 = dot(kuiGradient(c + uvec3(1u, 0u, 0u)), f - vec3(1.0, 0.0, 0.0));
|
|
73
|
+
float n010 = dot(kuiGradient(c + uvec3(0u, 1u, 0u)), f - vec3(0.0, 1.0, 0.0));
|
|
74
|
+
float n110 = dot(kuiGradient(c + uvec3(1u, 1u, 0u)), f - vec3(1.0, 1.0, 0.0));
|
|
75
|
+
float n001 = dot(kuiGradient(c + uvec3(0u, 0u, 1u)), f - vec3(0.0, 0.0, 1.0));
|
|
76
|
+
float n101 = dot(kuiGradient(c + uvec3(1u, 0u, 1u)), f - vec3(1.0, 0.0, 1.0));
|
|
77
|
+
float n011 = dot(kuiGradient(c + uvec3(0u, 1u, 1u)), f - vec3(0.0, 1.0, 1.0));
|
|
78
|
+
float n111 = dot(kuiGradient(c + uvec3(1u, 1u, 1u)), f - vec3(1.0, 1.0, 1.0));
|
|
79
|
+
float nx00 = mix(n000, n100, w.x);
|
|
80
|
+
float nx10 = mix(n010, n110, w.x);
|
|
81
|
+
float nx01 = mix(n001, n101, w.x);
|
|
82
|
+
float nx11 = mix(n011, n111, w.x);
|
|
83
|
+
// 2/sqrt(3) \u2014 a 3D gradient-noise octave peaks near sqrt(3)/2, so this brings it to about -1..1.
|
|
84
|
+
return mix(mix(nx00, nx10, w.y), mix(nx01, nx11, w.y), w.z) * 1.1547;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Octaves summed and **normalised by the amplitude sum**, approximately -1..1 at every octave count.
|
|
89
|
+
*
|
|
90
|
+
* The division is the whole point of the function. Without it, raising the octave count raises the
|
|
91
|
+
* total amplitude, so the one authored knob that means "how much fine structure" would silently be
|
|
92
|
+
* a contrast control as well \u2014 two behaviours behind one parameter, which is the class of bug this
|
|
93
|
+
* repository keeps rediscovering. Gain and lacunarity stay fixed at 0.5 and 2.0: they are the two
|
|
94
|
+
* numbers that make layered noise look wrong in a hundred ways and right in one.
|
|
95
|
+
*
|
|
96
|
+
* The loop bound is a constant with an early break because a loop bound that is itself a uniform
|
|
97
|
+
* forces some drivers to unroll against the worst case anyway, and this way the cost of a low
|
|
98
|
+
* \`detail\` is genuinely low.
|
|
99
|
+
*/
|
|
100
|
+
float kuiFbm(vec3 p, int octaves) {
|
|
101
|
+
float amp = 1.0;
|
|
102
|
+
float freq = 1.0;
|
|
103
|
+
float sum = 0.0;
|
|
104
|
+
float norm = 0.0;
|
|
105
|
+
for (int i = 0; i < KUI_MAX_OCTAVES; i++) {
|
|
106
|
+
if (i >= octaves) break;
|
|
107
|
+
sum += amp * kuiNoise(p * freq);
|
|
108
|
+
norm += amp;
|
|
109
|
+
amp *= 0.5;
|
|
110
|
+
freq *= 2.0;
|
|
111
|
+
}
|
|
112
|
+
return sum / max(norm, 1e-5);
|
|
113
|
+
}
|
|
114
|
+
`,P=`uniform float u_noise;
|
|
115
|
+
uniform float u_seed;
|
|
116
|
+
uniform float u_scale;
|
|
117
|
+
uniform float u_warp;
|
|
118
|
+
uniform int u_detail;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* A sine's RMS is 0.707. Amplitude-normalised fbm's is about 0.23 \u2014 it reaches its \`1.0\` peak
|
|
122
|
+
* rarely, which is what makes it look like noise rather than a wave. Handing the programs the raw
|
|
123
|
+
* field would therefore read as the *effect being turned down*, not as it being re-textured, and
|
|
124
|
+
* the first thing anyone trying \`noise: 1\` would do is reach for \`strength\`. This brings the two
|
|
125
|
+
* to the same typical magnitude so the amount is a change of texture and nothing else.
|
|
126
|
+
*/
|
|
127
|
+
const float KUI_FBM_SINE_RMS = 3.0;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* One scalar of animated noise, scaled to stand in for a unit sine at a stated rate.
|
|
131
|
+
*
|
|
132
|
+
* \`cycles\` and \`rate\` are the spatial and temporal frequency of the term being replaced, in
|
|
133
|
+
* cycles rather than radians \u2014 each call site divides its own trig coefficients by 2*pi and passes
|
|
134
|
+
* the result, so \`noise: 1\` lands on the same feature size and the same speed as the wave it took
|
|
135
|
+
* over from. That is the entire mechanism keeping this from being a new look.
|
|
136
|
+
*
|
|
137
|
+
* \`phase\` decorrelates sibling calls: two components of one flow vector must not be the same
|
|
138
|
+
* field, and offsetting the seed is cheaper than hashing a second one.
|
|
139
|
+
*
|
|
140
|
+
* \`u_warp\` costs two further fbm evaluations and is skipped entirely when it is zero.
|
|
141
|
+
*/
|
|
142
|
+
float kuiFilterField(vec2 uv, float t, float cycles, float rate, float phase) {
|
|
143
|
+
vec3 s = vec3(u_seed * 137.31, u_seed * 71.17, u_seed * 29.73) + phase;
|
|
144
|
+
vec3 q = vec3((uv - 0.5) * cycles * max(u_scale, 0.05), t * rate) + s;
|
|
145
|
+
if (u_warp > 0.0) {
|
|
146
|
+
float wx = kuiFbm(q * 0.5 + vec3(5.2, 1.3, 7.1), u_detail);
|
|
147
|
+
float wy = kuiFbm(q * 0.5 + vec3(19.7, 11.1, 3.7), u_detail);
|
|
148
|
+
q.xy += vec2(wx, wy) * u_warp;
|
|
149
|
+
}
|
|
150
|
+
return kuiFbm(q, u_detail) * KUI_FBM_SINE_RMS;
|
|
151
|
+
}
|
|
152
|
+
`,De=`#version 300 es
|
|
153
|
+
in vec2 a_position;
|
|
154
|
+
uniform vec2 u_uvOrigin;
|
|
155
|
+
uniform vec2 u_uvScale;
|
|
156
|
+
out vec2 v_uv;
|
|
157
|
+
void main() {
|
|
158
|
+
vec2 uv = (a_position + 1.0) * 0.5;
|
|
159
|
+
uv.y = 1.0 - uv.y;
|
|
160
|
+
v_uv = u_uvOrigin + uv * u_uvScale;
|
|
161
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
162
|
+
}
|
|
163
|
+
`,Ue=`#version 300 es
|
|
164
|
+
precision highp float;
|
|
165
|
+
in vec2 v_uv;
|
|
166
|
+
out vec4 fragColor;
|
|
167
|
+
uniform sampler2D u_image;
|
|
168
|
+
uniform float u_time;
|
|
169
|
+
uniform float u_strength;
|
|
170
|
+
uniform float u_frequency;
|
|
171
|
+
uniform float u_chromatic;
|
|
172
|
+
uniform vec2 u_mouse;
|
|
173
|
+
uniform vec4 u_tint;
|
|
174
|
+
uniform int u_blend;
|
|
175
|
+
uniform float u_duotone;
|
|
176
|
+
uniform vec4 u_color1;
|
|
177
|
+
uniform vec4 u_color2;
|
|
178
|
+
uniform float u_progress;
|
|
179
|
+
${R}${k}
|
|
180
|
+
vec4 applyBlend(vec4 base, vec4 tint, int mode) {
|
|
181
|
+
// \`base\` is premultiplied \u2014 \`createGLTexture\` uploads with \`UNPACK_PREMULTIPLY_ALPHA_WEBGL\` to
|
|
182
|
+
// match a \`premultipliedAlpha: true\` context \u2014 while \`tint\` is straight rgba out of
|
|
183
|
+
// \`parseColor\`. All four blends are defined on *straight* colour, so every mode takes the same
|
|
184
|
+
// path: un-premultiply, blend, and re-premultiply by this pixel's own coverage.
|
|
185
|
+
//
|
|
186
|
+
// Screen and add were the obvious cases. Run over all four premultiplied components,
|
|
187
|
+
// \`screen((0,0,0,0), (1,0,0,1))\` is \`(1,0,0,1)\`, an opaque red pixel where the source had no
|
|
188
|
+
// coverage at all \u2014 \`blend: screen tint: red\` filled a transparent PNG's surround with a solid
|
|
189
|
+
// red rectangle. Normal and multiply *looked* safe as a plain \`base * tint\`, because a transparent
|
|
190
|
+
// base does multiply to transparent whatever the tint is. It is the tint's alpha they got wrong:
|
|
191
|
+
// \`(1,1,1,1) * (1,0,0,0)\` is \`(1,0,0,0)\`, red at zero coverage, and a premultiplied canvas
|
|
192
|
+
// composites \`rgb > a\` *additively* \u2014 \`tint: rgba(255,0,0,0)\`, a fully transparent tint, turned
|
|
193
|
+
// an opaque image red, and any translucent tint bled the same way in proportion.
|
|
194
|
+
//
|
|
195
|
+
// The \`min\` on \`s\` is for \`main()\`'s chromatic sampling, which reads the three colour channels
|
|
196
|
+
// at three offsets and \`a\` at a fourth: at a transparent PNG's edge that can pair \`rgb\` from
|
|
197
|
+
// opaque neighbours with \`a\` from a transparent centre, an input that already breaks the
|
|
198
|
+
// invariant. Clamping the un-premultiplied colour to 1 is what keeps the output inside it.
|
|
199
|
+
//
|
|
200
|
+
// Alpha is \`base.a * tint.a\` \u2014 the source's coverage, faded by a translucent tint. Whatever the
|
|
201
|
+
// mode, the result satisfies \`rgb <= a\`, which is the whole contract of a premultiplied pixel.
|
|
202
|
+
float a = base.a * tint.a;
|
|
203
|
+
vec3 s = base.a > 0.0 ? min(base.rgb / base.a, vec3(1.0)) : vec3(0.0);
|
|
204
|
+
vec3 c = mode == 1 ? 1.0 - (1.0 - s) * (1.0 - tint.rgb)
|
|
205
|
+
: mode == 3 ? min(s + tint.rgb, vec3(1.0))
|
|
206
|
+
: s * tint.rgb;
|
|
207
|
+
return vec4(c * a, a);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
void main() {
|
|
211
|
+
vec2 m = u_mouse;
|
|
212
|
+
float d = distance(v_uv, m);
|
|
213
|
+
float ripple = sin(d * u_frequency - u_time * 3.0) * exp(-d * 4.0);
|
|
214
|
+
float pFactor = u_progress >= 0.0 ? u_progress : 1.0;
|
|
215
|
+
// Audio widens the ripple's throw (up to 2x), leaving its shape and speed alone.
|
|
216
|
+
vec2 disp = normalize(v_uv - m + 0.0001) * ripple * u_strength * 0.05 * pFactor * audioGain();
|
|
217
|
+
|
|
218
|
+
float cr = texture(u_image, v_uv + disp * (1.0 + u_chromatic)).r;
|
|
219
|
+
float cg = texture(u_image, v_uv + disp).g;
|
|
220
|
+
float cb = texture(u_image, v_uv + disp * (1.0 - u_chromatic)).b;
|
|
221
|
+
float ca = texture(u_image, v_uv + disp).a;
|
|
222
|
+
vec4 color = vec4(cr, cg, cb, ca);
|
|
223
|
+
|
|
224
|
+
if (u_duotone > 0.5) {
|
|
225
|
+
float lum = dot(color.rgb, vec3(0.299, 0.587, 0.114));
|
|
226
|
+
// \`* color.a\` because the ramp's two colours are straight rgba and everything downstream of
|
|
227
|
+
// here is premultiplied. Assigning one of them to a transparent pixel's \`rgb\` left \`rgb > 0\`
|
|
228
|
+
// with \`a == 0\`, which a \`premultipliedAlpha: true\` canvas composites *additively* \u2014 a
|
|
229
|
+
// transparent PNG's surround glowing in \`color1\` over whatever the page put behind it.
|
|
230
|
+
//
|
|
231
|
+
// \`lum\` is still read off the premultiplied colour, which is deliberate and unchanged: it
|
|
232
|
+
// makes a half-covered pixel map nearer \`color1\`, matching how the alpha stencil in
|
|
233
|
+
// \`GENERATIVE_FS\` reads the same kind of edge.
|
|
234
|
+
color.rgb = mix(u_color1.rgb, u_color2.rgb, lum) * color.a;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
fragColor = applyBlend(color, u_tint, u_blend) * shapeMask();
|
|
238
|
+
}
|
|
239
|
+
`,Be=`#version 300 es
|
|
240
|
+
precision highp float;
|
|
241
|
+
in vec2 v_uv;
|
|
242
|
+
out vec4 fragColor;
|
|
243
|
+
uniform sampler2D u_image;
|
|
244
|
+
uniform float u_time;
|
|
245
|
+
uniform float u_strength;
|
|
246
|
+
uniform vec2 u_mouse;
|
|
247
|
+
uniform vec4 u_tint;
|
|
248
|
+
uniform float u_progress;
|
|
249
|
+
${R}${k}${C}${P}
|
|
250
|
+
void main() {
|
|
251
|
+
vec2 uv = v_uv;
|
|
252
|
+
vec2 m = u_mouse;
|
|
253
|
+
float d = distance(uv, m);
|
|
254
|
+
// Audio scales both halves of the flow \u2014 the ambient drift and the pointer's push \u2014 so a beat
|
|
255
|
+
// reads as the whole surface moving faster, not just around the cursor.
|
|
256
|
+
float gain = audioGain();
|
|
257
|
+
float force = exp(-d * 6.0) * u_strength * gain;
|
|
258
|
+
// The ambient drift. Two perpendicular waves at 10 rad across the box and 1 rad/s, which is
|
|
259
|
+
// 10/2pi = 1.5915 cycles and 1/2pi = 0.1592 cycles a second \u2014 the numbers kuiFilterField needs
|
|
260
|
+
// to put its field at the same size and speed. The drift is the whole of the ambient motion
|
|
261
|
+
// here, so this is the mode where the noise core reads most strongly: a regular cross-hatched
|
|
262
|
+
// sway becomes an irregular current.
|
|
263
|
+
vec2 wave = vec2(sin(u_time + uv.y * 10.0), cos(u_time + uv.x * 10.0));
|
|
264
|
+
if (u_noise > 0.0) {
|
|
265
|
+
wave = mix(wave, vec2(
|
|
266
|
+
kuiFilterField(uv, u_time, 1.5915, 0.1592, 0.0),
|
|
267
|
+
kuiFilterField(uv, u_time, 1.5915, 0.1592, 31.4)
|
|
268
|
+
), u_noise);
|
|
269
|
+
}
|
|
270
|
+
vec2 flow = wave * 0.02 * gain;
|
|
271
|
+
float pFactor = u_progress >= 0.0 ? u_progress : 1.0;
|
|
272
|
+
vec2 offset = (flow + (uv - m) * force * 0.1) * pFactor;
|
|
273
|
+
fragColor = texture(u_image, uv + offset) * u_tint * shapeMask();
|
|
274
|
+
}
|
|
275
|
+
`,He=`#version 300 es
|
|
276
|
+
precision highp float;
|
|
277
|
+
in vec2 v_uv;
|
|
278
|
+
out vec4 fragColor;
|
|
279
|
+
uniform sampler2D u_image;
|
|
280
|
+
uniform float u_time;
|
|
281
|
+
uniform float u_strength;
|
|
282
|
+
uniform vec4 u_tint;
|
|
283
|
+
uniform float u_progress;
|
|
284
|
+
${R}${k}${C}${P}
|
|
285
|
+
void main() {
|
|
286
|
+
vec2 uv = v_uv;
|
|
287
|
+
// 12 rad and 2 rad/s is 1.9099 cycles at 0.3183 a second; 10 rad and 1.5 rad/s is 1.5915 at
|
|
288
|
+
// 0.2387. The two waves keep their own rates under noise rather than being merged into one
|
|
289
|
+
// field, because the difference between them is what stops the surface reading as a single
|
|
290
|
+
// sheet sliding.
|
|
291
|
+
float w1 = sin(uv.y * 12.0 + u_time * 2.0);
|
|
292
|
+
float w2 = cos(uv.x * 10.0 - u_time * 1.5);
|
|
293
|
+
if (u_noise > 0.0) {
|
|
294
|
+
w1 = mix(w1, kuiFilterField(uv, u_time, 1.9099, 0.3183, 0.0), u_noise);
|
|
295
|
+
w2 = mix(w2, kuiFilterField(uv, u_time, 1.5915, 0.2387, 47.3), u_noise);
|
|
296
|
+
}
|
|
297
|
+
w1 *= 0.015;
|
|
298
|
+
w2 *= 0.015;
|
|
299
|
+
float pFactor = u_progress >= 0.0 ? u_progress : 1.0;
|
|
300
|
+
// Audio deepens the wave (up to 2x) without changing its wavelength or speed.
|
|
301
|
+
vec2 offset = vec2(w1, w2) * u_strength * pFactor * audioGain();
|
|
302
|
+
fragColor = texture(u_image, uv + offset) * u_tint * shapeMask();
|
|
303
|
+
}
|
|
304
|
+
`,Ne=`#version 300 es
|
|
305
|
+
precision highp float;
|
|
306
|
+
in vec2 v_uv;
|
|
307
|
+
out vec4 fragColor;
|
|
308
|
+
uniform sampler2D u_image;
|
|
309
|
+
uniform float u_time;
|
|
310
|
+
uniform float u_strength;
|
|
311
|
+
uniform vec4 u_tint;
|
|
312
|
+
uniform float u_progress;
|
|
313
|
+
${R}${k}${C}${P}
|
|
314
|
+
// No u_mouse here, deliberately. This program declared one from the day it was written and never
|
|
315
|
+
// read it, so particles has never responded to the pointer \u2014 the declaration was a promise the
|
|
316
|
+
// body did not keep, and the compiler dropped it anyway (an unused uniform gets no location, so
|
|
317
|
+
// uploadCoordUniforms was already skipping it and removing it changes no pixel). It is deleted
|
|
318
|
+
// rather than wired because wiring it would restyle a mode that is already in use without anyone
|
|
319
|
+
// asking, which is the same argument FILTER_NOISE_GLSL's doc makes for noise: being opt-in. The
|
|
320
|
+
// pointer gesture that *was* asked for lives on the generative program below, under hover:.
|
|
321
|
+
void main() {
|
|
322
|
+
vec2 uv = v_uv;
|
|
323
|
+
vec2 grid = fract(uv * 40.0) - 0.5;
|
|
324
|
+
float dist = length(grid);
|
|
325
|
+
// 100 rad across the box and 5 rad/s is 15.915 cycles at 0.7958 a second. That is by far the
|
|
326
|
+
// highest frequency of the four, and deliberately so: the trig term here is a diagonal travelling
|
|
327
|
+
// stripe, which is the most visible of the four repeats. Under noise the stripe becomes a
|
|
328
|
+
// scintillation, which is the largest change of the set and is the reason the parameter exists
|
|
329
|
+
// rather than the swap being unconditional.
|
|
330
|
+
//
|
|
331
|
+
// The clamp is not damage control. Mapped through KUI_FBM_SINE_RMS the field reaches 0 and 1
|
|
332
|
+
// often, which is what a sine does too \u2014 sin()*0.5+0.5 is arcsine-distributed and spends most of
|
|
333
|
+
// its time at the extremes. Clamping reproduces that; a soft field would give a duller sparkle
|
|
334
|
+
// than the one being replaced.
|
|
335
|
+
//
|
|
336
|
+
// Cost: this is one fbm per pixel, three with warp on, over the whole quad. At detail 6 the
|
|
337
|
+
// finest octave here sits near 509 cycles across the box, which is sub-pixel on a small element
|
|
338
|
+
// and will alias \u2014 high detail belongs on the low-frequency modes.
|
|
339
|
+
float sparkle = sin(u_time * 5.0 + dot(uv, vec2(100.0))) * 0.5 + 0.5;
|
|
340
|
+
if (u_noise > 0.0) {
|
|
341
|
+
float n = clamp(kuiFilterField(uv, u_time, 15.915, 0.7958, 0.0) * 0.5 + 0.5, 0.0, 1.0);
|
|
342
|
+
sparkle = mix(sparkle, n, u_noise);
|
|
343
|
+
}
|
|
344
|
+
vec4 tex = texture(u_image, uv);
|
|
345
|
+
float pFactor = u_progress >= 0.0 ? u_progress : 1.0;
|
|
346
|
+
float dotMask = smoothstep(0.4, 0.2, dist) * u_strength * pFactor;
|
|
347
|
+
// Audio brightens the sparkle (0.3 -> at most 0.6) rather than growing the dots: the mask is
|
|
348
|
+
// already multiplied by an unbounded u_strength and feeds a mix(), so widening it would
|
|
349
|
+
// extrapolate past the texture over a larger and larger area.
|
|
350
|
+
fragColor = mix(tex, tex * u_tint + sparkle * 0.3 * audioGain(), dotMask) * shapeMask();
|
|
351
|
+
}
|
|
352
|
+
`,qe=`#version 300 es
|
|
353
|
+
precision highp float;
|
|
354
|
+
in vec2 v_uv;
|
|
355
|
+
out vec4 fragColor;
|
|
356
|
+
uniform sampler2D u_image;
|
|
357
|
+
uniform sampler2D u_image_to;
|
|
358
|
+
uniform float u_time;
|
|
359
|
+
uniform float u_strength;
|
|
360
|
+
uniform float u_progress;
|
|
361
|
+
${R}${k}${C}${P}
|
|
362
|
+
void main() {
|
|
363
|
+
vec2 uv = v_uv;
|
|
364
|
+
float progress = u_progress >= 0.0 ? clamp(u_progress, 0.0, 1.0) : clamp(u_strength, 0.0, 1.0);
|
|
365
|
+
// Audio wobbles the crossfade harder. Deliberately not applied to u_progress: the morph's
|
|
366
|
+
// position between the two images belongs to the author (or to scroll), and letting a beat
|
|
367
|
+
// drive it would make the transition jump backwards on every quiet frame.
|
|
368
|
+
//
|
|
369
|
+
// 20 rad and 1 rad/s is 3.1831 cycles at 0.1592 a second. The 0.7071 is the one place the shared
|
|
370
|
+
// RMS gain is wrong by construction: the term being replaced is a *product* of two unit sines,
|
|
371
|
+
// whose RMS is 0.5 rather than a single sine's 0.7071, so matching it means taking the field
|
|
372
|
+
// down by that ratio. Without it the displacement under noise would be about 40% deeper than
|
|
373
|
+
// the one it stands in for \u2014 a visibly stronger morph, not the same one better textured.
|
|
374
|
+
float noise = sin(uv.x * 20.0 + u_time) * cos(uv.y * 20.0 + u_time);
|
|
375
|
+
if (u_noise > 0.0) {
|
|
376
|
+
noise = mix(noise, kuiFilterField(uv, u_time, 3.1831, 0.1592, 0.0) * 0.7071, u_noise);
|
|
377
|
+
}
|
|
378
|
+
noise = noise * 0.05 * audioGain();
|
|
379
|
+
vec4 c1 = texture(u_image, uv + vec2(noise * (1.0 - progress)));
|
|
380
|
+
vec4 c2 = texture(u_image_to, uv - vec2(noise * progress));
|
|
381
|
+
fragColor = mix(c1, c2, smoothstep(0.2, 0.8, progress)) * shapeMask();
|
|
382
|
+
}
|
|
383
|
+
`,ze=`#version 300 es
|
|
384
|
+
precision highp float;
|
|
385
|
+
in vec2 v_uv;
|
|
386
|
+
out vec4 fragColor;
|
|
387
|
+
uniform float u_time;
|
|
388
|
+
uniform float u_strength;
|
|
389
|
+
uniform float u_frequency;
|
|
390
|
+
uniform float u_chromatic;
|
|
391
|
+
uniform float u_iridescence;
|
|
392
|
+
uniform float u_progress;
|
|
393
|
+
uniform float u_seed;
|
|
394
|
+
uniform float u_scale;
|
|
395
|
+
uniform float u_warp;
|
|
396
|
+
uniform float u_grain;
|
|
397
|
+
uniform float u_hue;
|
|
398
|
+
uniform int u_detail;
|
|
399
|
+
uniform int u_bands;
|
|
400
|
+
uniform int u_colorCount;
|
|
401
|
+
uniform vec4 u_colors[5];
|
|
402
|
+
uniform vec4 u_tint;
|
|
403
|
+
uniform sampler2D u_image;
|
|
404
|
+
uniform int u_maskMode;
|
|
405
|
+
uniform vec2 u_mouse;
|
|
406
|
+
uniform int u_hover;
|
|
407
|
+
uniform vec4 u_backdrop;
|
|
408
|
+
uniform float u_angle;
|
|
409
|
+
uniform int u_motion;
|
|
410
|
+
${R}${k}${C}
|
|
411
|
+
|
|
412
|
+
/** \`hover:\` as bits, so \`both\` is \`stir | light\` rather than a third code path. */
|
|
413
|
+
const int KUI_HOVER_STIR = 1;
|
|
414
|
+
const int KUI_HOVER_LIGHT = 2;
|
|
415
|
+
|
|
416
|
+
/** \`motion:\` \u2014 \`0\` is \`evolve\`, which is this program's original behaviour and its default. */
|
|
417
|
+
const int KUI_MOTION_DRIFT = 1;
|
|
418
|
+
const int KUI_MOTION_SWIRL = 2;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Rotate a point of the field's domain.
|
|
422
|
+
*
|
|
423
|
+
* \`v_uv\` is y-down, so this matrix \u2014 the ordinary counter-clockwise one \u2014 turns the *picture*
|
|
424
|
+
* clockwise, which is \`transform: rotate()\`'s direction and therefore the one an author already
|
|
425
|
+
* has an intuition for. Every call site passes \`-angle\`: rotating the sample point one way is
|
|
426
|
+
* what rotates what you see the other.
|
|
427
|
+
*/
|
|
428
|
+
vec2 kuiRotate(vec2 v, float a) {
|
|
429
|
+
float c = cos(a);
|
|
430
|
+
float s = sin(a);
|
|
431
|
+
return vec2(v.x * c - v.y * s, v.x * s + v.y * c);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* The pair of factors that carry a centred UV offset into a space that is isotropic **on screen**,
|
|
436
|
+
* and back out again by dividing.
|
|
437
|
+
*
|
|
438
|
+
* \`v_uv\` is normalised per axis, so one unit of \`v_uv.x\` is the box's whole width and one unit of
|
|
439
|
+
* \`v_uv.y\` is its whole height \u2014 two different numbers of screen pixels as soon as the box is not
|
|
440
|
+
* square. Anything round or rigid has to leave that space first. Scaling by \`(k, 1/k)\` for
|
|
441
|
+
* \`k = sqrt(halfWidth / halfHeight)\` puts both axes in units of \`sqrt(width * height)\`: a circle
|
|
442
|
+
* stays a circle, a rotation stays a rotation, and the unit tracks the box's overall size rather
|
|
443
|
+
* than one of its two dimensions. On a square box the pair is exactly \`(1, 1)\` and every user of
|
|
444
|
+
* it degenerates to the plain UV arithmetic it had before.
|
|
445
|
+
*
|
|
446
|
+
* It is a *ratio* of the two half-extents, so it is DPR-invariant \u2014 device pixel ratio scales
|
|
447
|
+
* \`u_maskBox.z\` and \`u_maskBox.w\` together and cancels.
|
|
448
|
+
*
|
|
449
|
+
* A zero half-extent is \`shapeMask()\`'s "no box measured" signal and is read the same way here:
|
|
450
|
+
* fall back to \`(1, 1)\` rather than divide by it.
|
|
451
|
+
*/
|
|
452
|
+
vec2 kuiAspectAxes() {
|
|
453
|
+
if (u_maskBox.z > 0.0 && u_maskBox.w > 0.0) {
|
|
454
|
+
float k = sqrt(u_maskBox.z / u_maskBox.w);
|
|
455
|
+
return vec2(k, 1.0 / k);
|
|
456
|
+
}
|
|
457
|
+
return vec2(1.0);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Turn a centred UV offset by \`a\`, rigidly **on screen** rather than in the field's own stretched
|
|
462
|
+
* space.
|
|
463
|
+
*
|
|
464
|
+
* \`A^-1 \xB7 R(a) \xB7 A\`, with \`A = diag(kuiAspectAxes())\`: leave the per-axis-normalised space, turn
|
|
465
|
+
* there, come back. Rotating without the conjugation turns *and shears* \u2014 on a 160x100 box an
|
|
466
|
+
* authored \`angle: 45deg\` actually travels at 32 degrees, an error that grows with how far from
|
|
467
|
+
* square the box is. \`angle\` is documented as \`transform: rotate()\`'s convention, and this is what
|
|
468
|
+
* makes that true of a wide box and not only of a square one.
|
|
469
|
+
*
|
|
470
|
+
* **Not bit-identical at \`a == 0\`**, and that matters: \`A^-1 \xB7 I \xB7 A\` is \`diag(k * (1/k), (1/k) * k)\`,
|
|
471
|
+
* which in IEEE 754 is about an ulp away from the identity per axis rather than exactly it. Every
|
|
472
|
+
* caller must therefore keep its existing exact-zero guard \u2014 the defaults are unchanged because
|
|
473
|
+
* nothing here executes at them, not because this collapses.
|
|
474
|
+
*
|
|
475
|
+
* \`scale\` is a scalar and commutes with all three matrices, so a zoomed offset can be passed
|
|
476
|
+
* straight in: \`A^-1 R A (zoom * d)\` is \`zoom * (A^-1 R A d)\`.
|
|
477
|
+
*/
|
|
478
|
+
vec2 kuiRotateScreen(vec2 v, float a) {
|
|
479
|
+
vec2 s = kuiAspectAxes();
|
|
480
|
+
return kuiRotate(v * s, a) / s;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* How strongly the pointer reaches this fragment: 1 under it, falling to nothing at the edge of a
|
|
485
|
+
* **round** pool.
|
|
486
|
+
*
|
|
487
|
+
* Round is the whole difficulty. \`v_uv\` and \`u_mouse\` are both normalised per axis, so the
|
|
488
|
+
* obvious \`distance(v_uv, u_mouse)\` draws an *ellipse* as soon as the box is not square \u2014 and the
|
|
489
|
+
* boxes this mode is documented for are full-bleed bands, card faces and footer strips, i.e.
|
|
490
|
+
* precisely the wide ones. \`kuiAspectAxes()\` is the correction, and measuring the offset there
|
|
491
|
+
* makes the pool a circle on screen whose size tracks the box's overall scale rather than one of
|
|
492
|
+
* its two dimensions. On a square box the pair is exactly \`(1, 1)\` and this degenerates to the
|
|
493
|
+
* plain UV distance \`displace\` already uses.
|
|
494
|
+
*
|
|
495
|
+
* Gaussian rather than \`smoothstep\`, because a pool of light has no edge to see.
|
|
496
|
+
*/
|
|
497
|
+
float kuiHoverFalloff() {
|
|
498
|
+
vec2 d = (v_uv - u_mouse) * kuiAspectAxes();
|
|
499
|
+
return exp(-dot(d, d) * 6.0);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* One point of the element's UV square, in the field's own frame.
|
|
504
|
+
*
|
|
505
|
+
* A rigid motion \u2014 one rotation and one translation \u2014 so that carrying the pointer through the
|
|
506
|
+
* same call puts it at the same place relative to the field that it occupies on screen. That is
|
|
507
|
+
* what lets \`stir\` swirl the field about a centre the cursor is actually sitting on, at any
|
|
508
|
+
* \`angle\`, mid-\`drift\`, mid-\`swirl\`.
|
|
509
|
+
*
|
|
510
|
+
* The turn is \`kuiRotateScreen\`, so it is rigid **on screen** on a box of any shape: \`angle: 45deg\`
|
|
511
|
+
* points at 45 degrees on a 160x100 band, and \`motion: drift\` travels along exactly the axis the
|
|
512
|
+
* author named instead of a sheared one.
|
|
513
|
+
*
|
|
514
|
+
* Inert at the defaults by construction: \`orient\` of zero skips the rotation entirely and
|
|
515
|
+
* \`travel\` of zero subtracts an exact zero, so \`motion: evolve\` at \`angle: 0deg\` computes the
|
|
516
|
+
* same \`(v_uv - 0.5) * scale\` this program has always computed, bit for bit. **The guard is the
|
|
517
|
+
* whole of that promise** \u2014 \`kuiRotateScreen\` does not collapse to the identity at zero, it only
|
|
518
|
+
* gets within an ulp, so deleting the guard because "a rotation is cheap" would silently move the
|
|
519
|
+
* last bit of every generative pixel already on the web.
|
|
520
|
+
*/
|
|
521
|
+
vec2 kuiFieldPoint(vec2 uv, float zoom, float orient, float travel) {
|
|
522
|
+
vec2 v = (uv - 0.5) * zoom;
|
|
523
|
+
if (orient != 0.0) v = kuiRotateScreen(v, -orient);
|
|
524
|
+
v.x -= travel;
|
|
525
|
+
return v;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* \`hover: stir\` \u2014 one vortex of the sample point about the pointer.
|
|
530
|
+
*
|
|
531
|
+
* A turn that dies away from the cursor, plus a push of the *sample point* outward, which is the
|
|
532
|
+
* field spiralling inward and is the whole difference between a rotating disc and a stir.
|
|
533
|
+
* \`rel / (length(rel) + eps)\` rather than \`normalize\`, so the push fades to nothing at the centre
|
|
534
|
+
* instead of kicking the one pixel under the cursor in whatever direction the epsilon points.
|
|
535
|
+
*
|
|
536
|
+
* Both halves run inside \`kuiAspectAxes()\`, for the same reason \`kuiHoverFalloff\` does: the
|
|
537
|
+
* falloff that drives this is already a circle on screen, so a vortex measured in raw UV would be
|
|
538
|
+
* a round pool turning an elliptical gesture \u2014 two different ideas of "the same distance from the
|
|
539
|
+
* cursor" in one effect.
|
|
540
|
+
*/
|
|
541
|
+
vec2 kuiStirPoint(vec2 pt, vec2 centre, float zoom, float fall) {
|
|
542
|
+
vec2 s = kuiAspectAxes();
|
|
543
|
+
vec2 rel = (pt - centre) * s;
|
|
544
|
+
vec2 turned = kuiRotate(rel, 1.6 * fall) + rel / (length(rel) + 1e-4) * (0.10 * zoom * fall);
|
|
545
|
+
return centre + turned / s;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* The host image read as a stencil: 1 where the mark is, 0 where the page should show through.
|
|
550
|
+
*
|
|
551
|
+
* Three ways to ask, because a logo file answers the question differently depending on what it is:
|
|
552
|
+
*
|
|
553
|
+
* - \`0\` \u2014 no stencil. \`mode: gradient\`; \`u_image\` is not sampled at all.
|
|
554
|
+
* - \`1\` (\`mask: alpha\`) \u2014 the image's own alpha. An SVG or PNG mark on a transparent ground,
|
|
555
|
+
* which is what a logo asset usually is. The texture is uploaded premultiplied, so \`a\` is the
|
|
556
|
+
* coverage and multiplying all four channels by it stays premultiplied-correct.
|
|
557
|
+
* - \`2\`/\`3\` (\`mask: luma\` / \`luma-invert\`) \u2014 luminance, for a format with no alpha to read. A
|
|
558
|
+
* JPEG has none, so a black-on-white mark under \`alpha\` would give an all-opaque stencil and
|
|
559
|
+
* fill the whole rectangle with field. \`luma\` takes the *bright* pixels as the mark (white on
|
|
560
|
+
* black); \`luma-invert\` takes the dark ones (black on white, which is the common logo file).
|
|
561
|
+
* Both directions exist because guessing one silently produces a perfect negative of the mark \u2014
|
|
562
|
+
* an image that looks deliberate and is exactly wrong.
|
|
563
|
+
*
|
|
564
|
+
* Luminance is taken from the premultiplied colour, so a transparent pixel is black. Under
|
|
565
|
+
* \`luma\` that reads as "not the mark", which is the sensible answer for a file that has alpha and
|
|
566
|
+
* was asked for a luma stencil anyway. Under \`luma-invert\` the same pixel reads as *solid* mark \u2014
|
|
567
|
+
* correct for the opaque JPEG the keyword exists for, and wrong for anything with a transparent
|
|
568
|
+
* surround, which should be using \`alpha\`.
|
|
569
|
+
*/
|
|
570
|
+
float glyphMask() {
|
|
571
|
+
if (u_maskMode == 0) return 1.0;
|
|
572
|
+
vec4 src = texture(u_image, v_uv);
|
|
573
|
+
if (u_maskMode == 1) return src.a;
|
|
574
|
+
float lum = dot(src.rgb, vec3(0.299, 0.587, 0.114));
|
|
575
|
+
return u_maskMode == 2 ? lum : 1.0 - lum;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* The palette ramp, interpolated in linear-light rather than straight sRGB.
|
|
580
|
+
*
|
|
581
|
+
* \`mix()\` between two sRGB triples passes through a desaturated middle \u2014 the classic muddy
|
|
582
|
+
* midpoint of a naive gradient, worst exactly where two saturated brand colours meet. Squaring
|
|
583
|
+
* into approximately linear light, mixing there, and taking the square root back is a two-operation
|
|
584
|
+
* approximation of a gamma-2.0 space that removes almost all of it.
|
|
585
|
+
*
|
|
586
|
+
* \`smoothstep\` on the segment fraction, not a straight lerp, so the ramp has no visible crease at
|
|
587
|
+
* each stop \u2014 a crease that banding (\`u_bands\`) would otherwise land on and amplify.
|
|
588
|
+
*/
|
|
589
|
+
vec3 kuiPalette(float t) {
|
|
590
|
+
int n = max(u_colorCount, 2);
|
|
591
|
+
float x = clamp(t, 0.0, 1.0) * float(n - 1);
|
|
592
|
+
int i = int(floor(x));
|
|
593
|
+
int j = min(i + 1, n - 1);
|
|
594
|
+
float f = smoothstep(0.0, 1.0, x - float(i));
|
|
595
|
+
vec3 a = u_colors[i].rgb;
|
|
596
|
+
vec3 b = u_colors[j].rgb;
|
|
597
|
+
return sqrt(mix(a * a, b * b, f));
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/** Rotate a colour about the grey axis \u2014 Rodrigues' formula, which needs no colour-space change. */
|
|
601
|
+
vec3 kuiHueRotate(vec3 c, float angle) {
|
|
602
|
+
const vec3 axis = vec3(0.57735026);
|
|
603
|
+
float s = sin(angle);
|
|
604
|
+
float k = cos(angle);
|
|
605
|
+
return c * k + cross(axis, c) * s + axis * dot(axis, c) * (1.0 - k);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** Per-pixel film grain. Quantised in time so it flickers at ~60 steps a second rather than per frame. */
|
|
609
|
+
float kuiGrain(vec2 fragCoord, float t) {
|
|
610
|
+
uint h = kuiHash(uvec3(uvec2(fragCoord), uint(int(t * 60.0) + 0x10000)));
|
|
611
|
+
return float(h & 0xffffu) / 65535.0 - 0.5;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
void main() {
|
|
615
|
+
// Centred and aspect-free: the field is authored in the element's own UV space, so the same
|
|
616
|
+
// parameters give the same picture whatever size the box is.
|
|
617
|
+
float zoom = max(u_scale, 0.05);
|
|
618
|
+
vec3 seed = vec3(u_seed * 137.31, u_seed * 71.17, u_seed * 29.73);
|
|
619
|
+
float t = u_time;
|
|
620
|
+
float pFactor = u_progress >= 0.0 ? u_progress : 1.0;
|
|
621
|
+
|
|
622
|
+
// Orientation and travel, as one rigid motion of the domain. \`angle\` names the field's axis;
|
|
623
|
+
// \`motion: swirl\` turns that axis over time; \`motion: drift\` slides along it. Both are *added
|
|
624
|
+
// to* the third-axis evolution below rather than replacing it, so a drifting field is still
|
|
625
|
+
// changing as it goes rather than being one frozen picture towed across the box.
|
|
626
|
+
float spin = u_motion == KUI_MOTION_SWIRL ? t * 0.2 : 0.0;
|
|
627
|
+
float orient = u_angle + spin;
|
|
628
|
+
// Multiplied by the zoom, so \`drift\` crosses the box at the same visual rate whatever \`scale\`
|
|
629
|
+
// is. Without it, zooming in would slow the travel down \u2014 one knob quietly moving two things,
|
|
630
|
+
// which is the bug kuiFbm's \`/norm\` divisor exists to avoid on the octave count.
|
|
631
|
+
float travel = u_motion == KUI_MOTION_DRIFT ? t * 0.12 * zoom : 0.0;
|
|
632
|
+
|
|
633
|
+
vec2 p = kuiFieldPoint(v_uv, zoom, orient, travel);
|
|
634
|
+
// One evaluation, shared by both gestures, and skipped entirely when there is no pointer
|
|
635
|
+
// response authored.
|
|
636
|
+
float hoverFall = u_hover != 0 ? kuiHoverFalloff() : 0.0;
|
|
637
|
+
|
|
638
|
+
// Domain warp: a second field displaces the sample point of the first. This is the whole
|
|
639
|
+
// difference between concentric fbm contours and something that reads as liquid.
|
|
640
|
+
//
|
|
641
|
+
// **This displacement is deliberately NOT aspect-corrected, and it is the one thing here that
|
|
642
|
+
// is not.** \`vec2(wx, wy)\` is isotropic in the field's own normalised space, which means it is
|
|
643
|
+
// anisotropic on screen \u2014 the same flaw \`kuiRotateScreen\` exists to fix for \`angle\`, \`motion\`
|
|
644
|
+
// and the \`stir\` vortex. It is left alone because \`warp\` is *shipped and in use*: multiplying
|
|
645
|
+
// it through \`kuiAspectAxes()\` would restyle every live page that authored one, which is a
|
|
646
|
+
// price a correctness argument does not get to charge. The rule the rest of this program follows
|
|
647
|
+
// and this line does not: **orientation and the pointer vortex are screen-true; the domain warp
|
|
648
|
+
// is field-true.** If you are here to "finish the job", that is a behaviour change to real
|
|
649
|
+
// sites and it needs the owner, not a tidy-up commit.
|
|
650
|
+
vec2 q = p;
|
|
651
|
+
if (u_warp > 0.0) {
|
|
652
|
+
float wf = u_frequency * 0.1;
|
|
653
|
+
float wx = kuiFbm(vec3(p * wf, t * 0.35) + seed, u_detail);
|
|
654
|
+
float wy = kuiFbm(vec3(p * wf + 5.2, t * 0.35 + 1.3) + seed, u_detail);
|
|
655
|
+
q += vec2(wx, wy) * u_warp;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// \`hover: stir\` \u2014 the cursor dragged through the colour, like stirring thick paint.
|
|
659
|
+
//
|
|
660
|
+
// Applied here, last, to the finished sample point: the gesture is dragging paint that is
|
|
661
|
+
// already there, not re-warping the field before it exists. It also means \`stir\` works at the
|
|
662
|
+
// library defaults, where \`warp\` is 0 and there is no domain warp to ride on.
|
|
663
|
+
//
|
|
664
|
+
// A vortex, which is one gesture and not two \u2014 see \`kuiStirPoint\`, which also explains why both
|
|
665
|
+
// halves of it are measured in the same screen-isotropic space as the falloff that drives them.
|
|
666
|
+
//
|
|
667
|
+
// On \`mode: logo\` this cannot touch the mark's edges: \`glyphMask()\` samples \`u_image\` at the
|
|
668
|
+
// undistorted \`v_uv\` and multiplies the finished colour, so stirring \`q\` swirls the fill and
|
|
669
|
+
// leaves the stencil exactly where it was.
|
|
670
|
+
if ((u_hover & KUI_HOVER_STIR) != 0) {
|
|
671
|
+
vec2 pm = kuiFieldPoint(u_mouse, zoom, orient, travel);
|
|
672
|
+
q = kuiStirPoint(q, pm, zoom, hoverFall);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// Audio and progress scale the field's *amplitude*, leaving its shape and rate alone \u2014 so a
|
|
676
|
+
// beat swells the contrast and a scroll at 0 leaves a flat single colour rather than a jump cut.
|
|
677
|
+
float field = kuiFbm(vec3(q, t * 0.25) + seed, u_detail);
|
|
678
|
+
field *= u_strength * pFactor * audioGain();
|
|
679
|
+
float v = clamp(field * 0.5 + 0.5, 0.0, 1.0);
|
|
680
|
+
|
|
681
|
+
// Iridescence wraps the ramp back on itself, so one palette reads as many sheens across the box.
|
|
682
|
+
float wrapped = u_iridescence > 0.0 ? fract(v * u_iridescence) : v;
|
|
683
|
+
|
|
684
|
+
// Posterise. Divided by bands-1 so the top step reaches the end of the ramp; a plain /bands
|
|
685
|
+
// would stop one step short and quietly desaturate the brightest colour.
|
|
686
|
+
if (u_bands > 0) {
|
|
687
|
+
float steps = float(u_bands);
|
|
688
|
+
wrapped = floor(wrapped * steps) / max(steps - 1.0, 1.0);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// Fringing offsets the *ramp position* per channel rather than re-sampling the field three
|
|
692
|
+
// times: three palette lookups are nearly free, three more fbm evaluations would triple the
|
|
693
|
+
// program's cost for a decorative edge.
|
|
694
|
+
vec3 color;
|
|
695
|
+
if (u_chromatic > 0.0) {
|
|
696
|
+
float d = u_chromatic * 0.04;
|
|
697
|
+
color = vec3(
|
|
698
|
+
kuiPalette(wrapped + d).r,
|
|
699
|
+
kuiPalette(wrapped).g,
|
|
700
|
+
kuiPalette(wrapped - d).b
|
|
701
|
+
);
|
|
702
|
+
} else {
|
|
703
|
+
color = kuiPalette(wrapped);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
if (u_hue != 0.0) color = kuiHueRotate(color, u_hue);
|
|
707
|
+
|
|
708
|
+
// \`hover: light\` \u2014 a torch held over the surface.
|
|
709
|
+
//
|
|
710
|
+
// A multiply rather than a blend toward white. Multiplying preserves the hue and *raises* the
|
|
711
|
+
// saturation, so what appears under the pointer is the author's own colour becoming vivid;
|
|
712
|
+
// mixing toward white would wash the palette out at exactly the point the eye is on. The gain is
|
|
713
|
+
// 1.0 in the far field, which is what makes this a highlight rather than a restyling \u2014 a palette
|
|
714
|
+
// already at the top of the range has nowhere to go, and that is the honest behaviour of a torch.
|
|
715
|
+
if ((u_hover & KUI_HOVER_LIGHT) != 0) color *= 1.0 + 0.7 * hoverFall;
|
|
716
|
+
|
|
717
|
+
if (u_grain > 0.0) color += kuiGrain(gl_FragCoord.xy, t) * u_grain * 0.25;
|
|
718
|
+
|
|
719
|
+
// Opaque before masking, and premultiplied trivially because alpha is 1 \u2014 the element's own
|
|
720
|
+
// shape and its ancestors' opacity arrive through shapeMask(), the mark's shape through
|
|
721
|
+
// glyphMask(), and both multiply all four channels, which is the right operation on
|
|
722
|
+
// premultiplied colour and is what leaves the page visible around a logo.
|
|
723
|
+
float sm = shapeMask();
|
|
724
|
+
float gm = glyphMask();
|
|
725
|
+
vec4 px = vec4(clamp(color, 0.0, 1.0), 1.0) * u_tint * sm * gm;
|
|
726
|
+
|
|
727
|
+
// \`backdrop\` \u2014 the colour the field is composited *over*, inside the element's own shape.
|
|
728
|
+
//
|
|
729
|
+
// Premultiplied "over", because everything in this program already is. \`u_tint.a * gm\` is the
|
|
730
|
+
// field's coverage before the shape mask, so the backdrop is pulled through the same \`sm\` as the
|
|
731
|
+
// field rather than being masked twice \u2014 which would otherwise thin the backdrop along an
|
|
732
|
+
// antialiased rounded corner.
|
|
733
|
+
//
|
|
734
|
+
// What it is *for*: \`mode: logo\`'s plate. Outside the mark the coverage is zero and the backdrop
|
|
735
|
+
// is all there is, so a mark gets a solid ground instead of the page showing through. A bare
|
|
736
|
+
// \`gradient\` is opaque, so there this is a no-op by construction \u2014 visible only through a \`tint\`
|
|
737
|
+
// whose alpha is below 1. That is a property of an opaque field, not an oversight.
|
|
738
|
+
if (u_backdrop.a > 0.0) {
|
|
739
|
+
px += vec4(u_backdrop.rgb * u_backdrop.a, u_backdrop.a) * sm * (1.0 - u_tint.a * gm);
|
|
740
|
+
}
|
|
741
|
+
fragColor = px;
|
|
742
|
+
}
|
|
743
|
+
`;function Bt(e){let t=e.style,n=new Map,r=e.hasAttribute("style");function i(o){if(n.has(o))return;let s=t.getPropertyValue(o);n.set(o,s===""?void 0:{value:s,priority:t.getPropertyPriority(o)})}return{set(o,s){i(o),t.setProperty(o,s)},claim:i,restore(){for(let[o,s]of n)s===void 0?t.removeProperty(o):t.setProperty(o,s.value,s.priority);n.clear(),!r&&t.length===0&&!e.getAttribute("style")&&e.removeAttribute("style")},owned:()=>[...n.keys()],peek(o){if(!n.has(o))return;let s=n.get(o);return s===void 0?"":s.value}}}var je=Symbol.for("kuinetic.owned-styles.1");function Ve(e){let n=e[je];return n||(n=new Map,Object.defineProperty(e,je,{value:n,configurable:!0,writable:!0})),n}function Ht(e,t,n){let r=Ve(e),i=r.get(t);return i||(i={ledger:n(e),owners:new Set},r.set(t,i)),i}function Nt(e,t){let n={},r=new Map;return{join(i){let o=r.get(i);return o||(o=Ht(i,e,t),o.owners.add(n),r.set(i,o)),o.ledger},held:i=>r.get(i)?.ledger??null,leave(i){let o=r.get(i);o&&(r.delete(i),o.owners.delete(n),!(o.owners.size>0)&&(Ve(i).delete(e),o.ledger.restore()))},elements:()=>[...r.keys()]}}function $e(){let e=Nt("style",Bt),t=new WeakMap;function n(r){return{set:(i,o)=>{e.join(r).set(i,o)},claim:i=>{e.join(r).claim(i)},restore:()=>{e.leave(r)},owned:()=>e.held(r)?.owned()??[],peek:i=>e.held(r)?.peek(i)}}return{style(r){let i=t.get(r);return i||(i=n(r),t.set(r,i)),e.join(r),i},release:r=>{e.leave(r)},elements:()=>e.elements()}}function d(e,t,n){return Math.min(Math.max(e,t),n)}function g(e,t){return!t||typeof t.hasAttribute!="function"||!t.style?null:e.style(t)}function L(e){let t=$e();return{style:n=>t.style(n),restore(){let n=[],r=i=>{try{t.release(i)}catch(o){n.push(o)}};for(let i of t.elements())i!==e&&r(i);if(r(e),n.length>0)throw new AggregateError(n,`kuinetic: ${n.length} element(s) could not be given back`)},elements:()=>t.elements()}}var Xe=new Map;function qt(e){let t=Xe.get(e);return t||(t=new RegExp(String.raw`(?:^|,)\s*${e}(?=[\s,]|$)`),Xe.set(e,t)),t}function Qe(e,t){if(typeof e.getAttribute!="function")return!1;let n=e.getAttribute("data-kui");return!!n&&qt(t).test(n)}function zt(e,t,n){let r=t?.parentElement;for(;r&&r!==e;){if(Qe(r,n))return!1;r=r.parentElement}return!0}function I(e,t,n){if(typeof e.querySelectorAll!="function")return[];let r=[];for(let i of e.querySelectorAll(`[data-kui*="${n}"]`))Qe(i,n)&&zt(e,i,t)&&r.push(i);return r}function A(e,t,n){return e+(t-e)*n}function jt(e,t){return e&&typeof e.requestAnimationFrame=="function"?e.requestAnimationFrame(t):null}function Vt(e,t){return e&&typeof e.cancelAnimationFrame=="function"&&t!=null&&e.cancelAnimationFrame(t),null}function $t(e,t){return typeof globalThis.setTimeout!="function"?null:globalThis.setTimeout(e,t)}function Xt(e){typeof globalThis.clearTimeout=="function"&&e!=null&&globalThis.clearTimeout(e)}function Yt(e,t){return e?.win!==void 0?e.win:t.window!==void 0?t.window:typeof window<"u"?window:null}function Kt(e,t){return e?.doc!==void 0?e.doc:t.document!==void 0?t.document:typeof document<"u"?document:null}var Ye=new WeakMap,Zt=()=>null;function Qt(e,t,n){if(e?.createCanvas)return e.createCanvas;if(t.createCanvas)return t.createCanvas;if(!n)return Zt;let r=Ye.get(n);if(r)return r;let i=()=>typeof n.createElement=="function"?n.createElement("canvas"):null;return Ye.set(n,i),i}function Jt(e,t,n){return e?.raf?e.raf:t.raf?t.raf:r=>jt(n,r)}function en(e,t,n){return e?.caf?e.caf:t.caf?t.caf:r=>Vt(n,r)}function tn(e,t){return e?.setTimer&&e.clearTimer?[e.setTimer,e.clearTimer]:t.setTimer&&t.clearTimer?[t.setTimer,t.clearTimer]:[$t,Xt]}function h(e=null,t={}){let n=e,r=Yt(n,t),i=Kt(n,t),[o,s]=tn(n,t);return{window:r,document:i,createCanvas:Qt(n,t,i),raf:Jt(n,t,r),caf:en(n,t,r),setTimer:o,clearTimer:s}}function x(e){if(!e)return!1;let t=e.reducedMotion;return!!(t===!0||typeof t=="object"&&t&&t.enabled===!0)}function w(e={}){let t=!1,n=!1,r,i=new Promise(o=>{r=o});return{continuous:!!e.continuous,activate(){t||typeof e.activate=="function"&&e.activate()},cancel(){t||(typeof e.cancel=="function"&&e.cancel(),!n&&r&&(n=!0,r()))},finish(){t||(typeof e.finish=="function"&&e.finish(),!n&&r&&(n=!0,r()))},finished:e.continuous?Promise.resolve():i,destroy(){if(!t){t=!0;try{typeof e.destroy=="function"&&e.destroy()}finally{!n&&r&&(n=!0,r())}}}}}function f(e){let t=!1;return{continuous:!1,activate(){},cancel(){},finish(){},finished:Promise.resolve(),destroy(){t||(t=!0,typeof e=="function"&&e())}}}function Ke(e){return Array.isArray(e)?e:[e]}function Ze(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.registerPrimitives=="function"&&typeof t.registerPresets=="function"}function nn(e){if(!e||typeof e!="object")return;if(Ze(e))return e;let t=e;if(Ze(t.registry))return t.registry}function _(e,t,n,r="module"){let i=nn(e);if(!i)throw new Error(`kuinetic: register${r} requires a Registry or Animator instance`);return i.registerPrimitives(Ke(t)),i.registerPresets(Ke(n)),e}function Je(e,t,n){let r=e.createShader(t);return r?(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(e.deleteShader(r),null)):null}function et(e,t,n){let r=Je(e,e.VERTEX_SHADER,t),i=Je(e,e.FRAGMENT_SHADER,n);if(!r||!i)return r&&e.deleteShader(r),i&&e.deleteShader(i),null;let o=e.createProgram();return o?(e.attachShader(o,r),e.attachShader(o,i),e.linkProgram(o),e.deleteShader(r),e.deleteShader(i),typeof e.getProgramParameter=="function"&&!e.getProgramParameter(o,e.LINK_STATUS)?(e.deleteProgram(o),null):o):(e.deleteShader(r),e.deleteShader(i),null)}function tt(e,t){return t?{program:t,a_position:e.getAttribLocation(t,"a_position"),u_image:e.getUniformLocation(t,"u_image"),u_image_to:e.getUniformLocation(t,"u_image_to"),u_uvOrigin:e.getUniformLocation(t,"u_uvOrigin"),u_uvScale:e.getUniformLocation(t,"u_uvScale"),u_maskBox:e.getUniformLocation(t,"u_maskBox"),u_maskRx:e.getUniformLocation(t,"u_maskRx"),u_maskRy:e.getUniformLocation(t,"u_maskRy"),u_maskAlpha:e.getUniformLocation(t,"u_maskAlpha"),u_time:e.getUniformLocation(t,"u_time"),u_strength:e.getUniformLocation(t,"u_strength"),u_frequency:e.getUniformLocation(t,"u_frequency"),u_chromatic:e.getUniformLocation(t,"u_chromatic"),u_iridescence:e.getUniformLocation(t,"u_iridescence"),u_mouse:e.getUniformLocation(t,"u_mouse"),u_tint:e.getUniformLocation(t,"u_tint"),u_color1:e.getUniformLocation(t,"u_color1"),u_color2:e.getUniformLocation(t,"u_color2"),u_duotone:e.getUniformLocation(t,"u_duotone"),u_blend:e.getUniformLocation(t,"u_blend"),u_progress:e.getUniformLocation(t,"u_progress"),u_seed:e.getUniformLocation(t,"u_seed"),u_scale:e.getUniformLocation(t,"u_scale"),u_warp:e.getUniformLocation(t,"u_warp"),u_grain:e.getUniformLocation(t,"u_grain"),u_hue:e.getUniformLocation(t,"u_hue"),u_detail:e.getUniformLocation(t,"u_detail"),u_bands:e.getUniformLocation(t,"u_bands"),u_colorCount:e.getUniformLocation(t,"u_colorCount"),u_colors:e.getUniformLocation(t,"u_colors"),u_maskMode:e.getUniformLocation(t,"u_maskMode"),u_hover:e.getUniformLocation(t,"u_hover"),u_backdrop:e.getUniformLocation(t,"u_backdrop"),u_angle:e.getUniformLocation(t,"u_angle"),u_motion:e.getUniformLocation(t,"u_motion")}:null}function Z(e,t,n){if(e){t&&e.deleteBuffer&&e.deleteBuffer(t);for(let r of Object.values(n)){let i=r&&typeof r=="object"&&"program"in r?r.program:r;i&&e.deleteProgram&&e.deleteProgram(i)}}}function rn(e){let t=e,n=Number(t.naturalWidth??t.videoWidth??t.width??0),r=Number(t.naturalHeight??t.videoHeight??t.height??0);return[Number.isFinite(n)?n:0,Number.isFinite(r)?r:0]}function on(e,t){if(typeof e.getParameter!="function")return!1;let n=Number(e.getParameter(e.MAX_TEXTURE_SIZE));if(!Number.isFinite(n)||n<=0)return!1;let[r,i]=rn(t);return r>n||i>n}function sn(e){if(typeof e.getError=="function"){for(let t=0;t<8;t+=1)if(Number(e.getError())===0)return}}function an(e){if(typeof e.getError!="function")return!1;let t=e.getError();return typeof t=="number"&&t!==0}function nt(e,t){if(on(e,t))return null;let n=e.createTexture();if(!n)return null;sn(e);try{return e.bindTexture(e.TEXTURE_2D,n),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.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),typeof e.pixelStorei=="function"&&e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),an(e)?(e.deleteTexture&&e.deleteTexture(n),null):n}catch{return e.deleteTexture&&e.deleteTexture(n),null}}var un=["--kui-audio-bass","--kui-audio-mid","--kui-audio-treble","--kui-audio-level","--kui-audio"],J={bass:"--kui-audio-bass",mid:"--kui-audio-mid",treble:"--kui-audio-treble",level:"--kui-audio-level"},F=Object.keys(J);function rt(e){if(!e)return null;let t=parseFloat(e);return Number.isFinite(t)?d(t,0,1):null}function G(e){if(!e)return null;let t=e.trim();return Object.hasOwn(J,t)?t:null}function W(e,t){let n=J[t],r=rt(e.style?.getPropertyValue?.(n));if(r!==null)return r;let i=e.ownerDocument?.defaultView;return rt(i?.getComputedStyle?.(e).getPropertyValue(n))??0}function ln(e,t){let n=e.length;if(n===0)return{bass:0,mid:0,treble:0,level:0};let i=(t>0?t/2:22050)/n,o=(u,l)=>{let c=Math.max(0,Math.floor(u/i)),m=Math.min(n,Math.max(c+1,Math.ceil(l/i))),p=0,v=0;for(let E=c;E<m;E++)p+=e[E],v++;return v>0?p/(v*255):0},s=0;for(let u=0;u<n;u++)s+=e[u];let a=s/(n*255);return{bass:d(o(20,250),0,1),mid:d(o(250,4e3),0,1),treble:d(o(4e3,16e3),0,1),level:d(a,0,1)}}var cn="audio, video";function dn(e,t){let r=t?.HTMLMediaElement??(typeof HTMLMediaElement<"u"?HTMLMediaElement:null);return r?e instanceof r:!1}function mn(e,t,n,r){if(dn(e,n))return e;let i=e.querySelector?.(t??cn);return i||t&&r?.querySelector?.(t)||null}function it(e){if(!(!e||typeof e.disconnect!="function"))try{e.disconnect()}catch{return}}function hn(e,t){if(!(!e||typeof e.disconnect!="function"||!t))try{e.disconnect(t)}catch{return}}var ot=[32,64,128,256,512,1024,2048];function ut(e){let t=ot[0];for(let n of ot)Math.abs(n-e)<Math.abs(t-e)&&(t=n);return t}var st=["pointerdown","keydown","touchend"],Q=new WeakMap;function fn(e){if(typeof e.createGain!="function")return null;try{let t=e.createGain();return t.gain&&(t.gain.value=0),t.connect(e.destination),t}catch{return null}}function pn(e){let t=Q.get(e);if(t)return t.consumers++,t;let n=e.AudioContext||e.webkitAudioContext;if(!n)return null;try{let r=new n,i={ctx:r,sources:new WeakMap,sink:fn(r),consumers:1,ownsMediaOutput:!1};return Q.set(e,i),i}catch{return null}}function at(e,t){if(t.consumers--,t.consumers>0||t.ownsMediaOutput)return;Q.delete(e);let n=t.ctx.close?.();n&&n.catch(()=>{})}function vn(e,t){let n=e.sources.get(t);if(n)return n;if(typeof e.ctx.createMediaElementSource!="function")return null;try{let r=e.ctx.createMediaElementSource(t);return r.connect(e.ctx.destination),e.sources.set(t,r),e.ownsMediaOutput=!0,r}catch{return null}}var T=class{element;options;env;window;document;raf;caf;audioCtx=null;analyser=null;sourceNode=null;stream=null;freqData=null;rafId=null;isActive=!1;graph=null;sourceIsShared=!1;ledgers;micRequestToken=0;releaseGestureResume=null;constructor(t,n={},r={}){this.element=t,this.options=n,this.env=r;let i=h(null,r);this.window=i.window,this.document=i.document,this.raf=i.raf,this.caf=i.caf,this.ledgers=L(t)}connectMicSource(t,n,r){let i=r?.navigator;if(!i?.mediaDevices?.getUserMedia)return;let o=++this.micRequestToken;i.mediaDevices.getUserMedia({audio:!0}).then(s=>{if(o!==this.micRequestToken||this.analyser!==n){for(let a of s.getTracks())a.stop();return}this.stream=s,this.sourceNode=t.ctx.createMediaStreamSource(s),this.sourceIsShared=!1,this.sourceNode.connect(n),this.resumeContext()&&this.startLoopIfReady()}).catch(()=>{})}connectMediaSource(t,n,r){let i=this.document;try{let o=mn(this.element,this.options.target||null,r,i);if(!o)return;let s=vn(t,o);if(!s)return;s.connect(n),this.sourceNode=s,this.sourceIsShared=!0}catch{return}}buildAnalyser(t){try{let n=t.ctx.createAnalyser();return n.fftSize=ut(this.options.fftSize||256),n.smoothingTimeConstant=this.options.smoothing??.8,t.sink&&n.connect(t.sink),n}catch{return null}}initAudio(){if(this.analyser)return!0;let t=this.window;if(!t)return!1;let n=pn(t);if(!n)return!1;let r=this.buildAnalyser(n);return r?(this.graph=n,this.audioCtx=n.ctx,this.analyser=r,this.freqData=new Uint8Array(new ArrayBuffer(r.frequencyBinCount)),this.options.source==="mic"?this.connectMicSource(n,r,t):this.connectMediaSource(n,r,t),!0):(at(t,n),!1)}start(){if(!this.isActive){if(this.isActive=!0,!this.initAudio()||!this.resumeContext()||!this.sourceNode){this.updateFrame();return}this.startLoop()}}resumeContext(){let t=this.audioCtx;return!t||t.state!=="suspended"?!0:(t.resume().then(()=>this.startLoopIfReady()).catch(()=>{}),this.armGestureResume(),!1)}startLoopIfReady(){this.isActive&&this.sourceNode&&this.startLoop()}armGestureResume(){let t=this.window;if(this.releaseGestureResume||!t?.addEventListener||!t.removeEventListener)return;let n=()=>{this.releaseGestureResume?.(),this.audioCtx?.resume().then(()=>this.startLoopIfReady()).catch(()=>{})};this.releaseGestureResume=()=>{this.releaseGestureResume=null;for(let r of st)t.removeEventListener?.(r,n)};for(let r of st)t.addEventListener(r,n,{passive:!0})}startLoop(){if(this.rafId)return;let t=()=>{this.updateFrame(),this.isActive?this.rafId=this.raf(t):this.rafId=null};this.rafId=this.raf(t)}updateFrame(){let t=g(this.ledgers,this.element);if(!t)return;let n={bass:0,mid:0,treble:0,level:0};this.analyser&&this.freqData&&this.audioCtx&&(this.analyser.getByteFrequencyData(this.freqData),n=ln(this.freqData,this.audioCtx.sampleRate));let r=n.level.toFixed(3);this.writeChannel(t,"--kui-audio-bass",n.bass.toFixed(3)),this.writeChannel(t,"--kui-audio-mid",n.mid.toFixed(3)),this.writeChannel(t,"--kui-audio-treble",n.treble.toFixed(3)),this.writeChannel(t,"--kui-audio-level",r),this.writeChannel(t,"--kui-audio",r)}writeChannel(t,n,r){t.claim(n),this.element.style.getPropertyValue(n)!==r&&t.set(n,r)}stop(){this.isActive=!1,this.micRequestToken++,this.rafId&&(this.caf(this.rafId),this.rafId=null),this.releaseGestureResume?.(),this.disconnectAudioNodes()}disconnectAudioNodes(){if(this.stream){for(let n of this.stream.getTracks())n.stop();this.stream=null}let t=this.analyser;this.sourceIsShared?hn(this.sourceNode,t):it(this.sourceNode),this.sourceNode=null,this.sourceIsShared=!1,it(t),this.analyser=null,this.freqData=null,this.audioCtx=null,this.graph&&(at(this.window,this.graph),this.graph=null)}destroy(){try{this.stop()}finally{this.ledgers.restore()}}};function ee(e,t,n){if(x(n))return f();let r=h(n),o=(t.text?t.text("source","media"):"media")==="mic"?"mic":"media",s=t.text?t.text("target",""):"",a=d(t.num?t.num("smoothing",.8):.8,0,.99),u=ut(d(t.num?t.num("fft",256):256,32,2048)),l=new T(e,{source:o,target:s,smoothing:a,fftSize:u},r);return w({continuous:!0,activate(){l.start()},cancel(){l.stop()},finish(){l.stop()},destroy(){l.destroy()}})}var te={source:{type:"keyword",default:"media",keywords:["media","mic"],cssProperty:"--kui-audio-source"},target:{type:"text",default:"",cssProperty:"--kui-target"},smoothing:{type:"number",default:"0.8",minimum:0,maximum:.99,cssProperty:"--kui-audio-smoothing"},fft:{type:"number",default:"256",minimum:32,maximum:2048,cssProperty:"--kui-audio-fft"}},ne=[{id:"audio-source",renderer:"javascript",channels:[...un],parameters:te,supportedTimelines:["time"],supportedActivations:["load","enter","click","manual"],defaultActivation:"load",perfClass:"continuous",reducedMotion:"disable",prepare:ee}],re=[{name:"audio-source",primitive:"audio-source"},{name:"audio-reactive",primitive:"audio-source"},{name:"audio-mic",primitive:"audio-source",params:{source:"mic"}}];function O(e){return _(e,ne[0],re,"AudioSource")}function gn(e){if(!/^[0-9a-fA-F]{3,8}$/.test(e))return null;if(e.length===3||e.length===4){let t=e.length===4?parseInt(e[3]+e[3],16)/255:1;return[parseInt(e[0]+e[0],16)/255,parseInt(e[1]+e[1],16)/255,parseInt(e[2]+e[2],16)/255,t]}if(e.length===6||e.length===8){let t=e.length===8?parseInt(e.slice(6,8),16)/255:1;return[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255,t]}return null}var bn=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)$/i;function yn(e){let t=bn.exec(e);if(!t||!t[1]||!t[2]||!t[3])return null;let n=Math.min(255,Math.max(0,parseInt(t[1],10)))/255,r=Math.min(255,Math.max(0,parseInt(t[2],10)))/255,i=Math.min(255,Math.max(0,parseInt(t[3],10)))/255,o=t[4]!==void 0?Math.min(1,Math.max(0,parseFloat(t[4]))):1;return[n,r,i,o]}var lt={transparent:[0,0,0,0],black:[0,0,0,1],white:[1,1,1,1],red:[1,0,0,1],green:[0,.5,0,1],blue:[0,0,1,1],yellow:[1,1,0,1],cyan:[0,1,1,1],magenta:[1,0,1,1],gray:[.5,.5,.5,1],grey:[.5,.5,.5,1],orange:[1,.647,0,1],purple:[.5,0,.5,1]},ct=new WeakMap;function xn(e){let t=ct.get(e);if(t!==void 0)return t;let n=null;try{let r=e();r&&(r.width=1,r.height=1,n=r.getContext?.("2d",{willReadFrequently:!0})??null)}catch{n=null}return n&&ct.set(e,n),n}function wn(e,t){try{let n=xn(t);if(!n)return null;n.clearRect(0,0,1,1),n.fillStyle="#000000",n.fillStyle=e,n.fillRect(0,0,1,1);let r=n.getImageData(0,0,1,1).data;return[r[0]/255,r[1]/255,r[2]/255,r[3]/255]}catch{return null}}function M(e,t=h(null).createCanvas){if(!e)return[1,1,1,1];let n=e.trim();if(n.startsWith("#")){let s=gn(n.slice(1));if(s)return s}let r=yn(n);if(r)return r;let i=n.toLowerCase();if(i in lt)return lt[i];let o=wn(n,t);return o||[1,1,1,1]}var dt={deg:Math.PI/180,grad:Math.PI/200,rad:1,turn:Math.PI*2};function mt(e){if(!e)return 0;let t=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(deg|grad|rad|turn)?$/i.exec(e.trim());if(!t)return 0;let n=parseFloat(t[1]);return Number.isFinite(n)?n*(dt[(t[2]??"deg").toLowerCase()]??dt.deg):0}var ie=5,_n=[[.09,.11,.25,1],[.45,.29,.78,1]];function Ln(e,t){let n=e.filter(o=>o.trim()!=="").slice(0,ie),r=n.length>=2?n.map(o=>M(o,t)):[..._n],i=new Float32Array(ie*4);for(let o=0;o<ie;o+=1){let s=r[Math.min(o,r.length-1)];i.set(s,o*4)}return{palette:i,colorCount:r.length}}function En(e,t,n){return t.u_audio===void 0&&(t.u_audio=e.getUniformLocation(n,"u_audio")),t.u_noise===void 0&&(t.u_noise=e.getUniformLocation(n,"u_noise")),t}function le(e,t){if(!t)return null;if("program"in t&&t.program)return En(e,t,t.program);let n=t,r=i=>e.getUniformLocation(n,i);return{u_time:r("u_time"),u_strength:r("u_strength"),u_frequency:r("u_frequency"),u_chromatic:r("u_chromatic"),u_iridescence:r("u_iridescence"),u_mouse:r("u_mouse"),u_uvOrigin:r("u_uvOrigin"),u_uvScale:r("u_uvScale"),u_tint:r("u_tint"),u_blend:r("u_blend"),u_duotone:r("u_duotone"),u_color1:r("u_color1"),u_color2:r("u_color2"),u_image:r("u_image"),u_image_to:r("u_image_to"),u_progress:r("u_progress"),u_audio:r("u_audio"),u_noise:r("u_noise"),u_maskBox:r("u_maskBox"),u_maskRx:r("u_maskRx"),u_maskRy:r("u_maskRy"),u_maskAlpha:r("u_maskAlpha"),u_seed:r("u_seed"),u_scale:r("u_scale"),u_warp:r("u_warp"),u_grain:r("u_grain"),u_hue:r("u_hue"),u_detail:r("u_detail"),u_bands:r("u_bands"),u_colorCount:r("u_colorCount"),u_colors:r("u_colors"),u_maskMode:r("u_maskMode"),u_hover:r("u_hover"),u_backdrop:r("u_backdrop"),u_angle:r("u_angle"),u_motion:r("u_motion")}}var oe=[0,0,0,0],Rn=[0,0,0,0];function kn(e,t,n){t.u_maskBox&&e.uniform4fv(t.u_maskBox,n.maskBox??oe),t.u_maskRx&&e.uniform4fv(t.u_maskRx,n.maskRx??oe),t.u_maskRy&&e.uniform4fv(t.u_maskRy,n.maskRy??oe),b(e,t.u_maskAlpha,n.maskAlpha??1)}function b(e,t,n){t&&n!==void 0&&e.uniform1f(t,n)}function S(e,t,n){t&&n!==void 0&&e.uniform1i(t,Math.round(n))}function Sn(e,t,n){b(e,t.u_seed,n.seed??0),b(e,t.u_scale,n.scale??1),b(e,t.u_warp,n.warp??0),b(e,t.u_noise,n.noise??0)}function Cn(e,t,n){b(e,t.u_grain,n.grain??0),b(e,t.u_hue,n.hue??0),S(e,t.u_detail,n.detail??3),S(e,t.u_bands,n.bands??0)}function An(e,t,n){S(e,t.u_maskMode,n.maskMode??0),S(e,t.u_hover,n.hover??0),b(e,t.u_angle,n.angle??0),S(e,t.u_motion,n.motion??0)}function Tn(e,t,n){Sn(e,t,n),Cn(e,t,n),An(e,t,n),t.u_backdrop&&e.uniform4fv(t.u_backdrop,n.backdropRgba??Rn)}function Mn(e,t,n){t.u_mouse&&n.localMouse&&e.uniform2f(t.u_mouse,n.localMouse.x,n.localMouse.y),t.u_uvOrigin&&n.uvOrigin&&e.uniform2f(t.u_uvOrigin,n.uvOrigin[0],n.uvOrigin[1]),t.u_uvScale&&n.uvScale&&e.uniform2f(t.u_uvScale,n.uvScale[0],n.uvScale[1])}function Pn(e,t,n){let r=le(e,t);if(!r)return;let i=n.time!==void 0?n.time*(n.speed??1):void 0;b(e,r.u_time,i),b(e,r.u_strength,n.strength),b(e,r.u_frequency,n.frequency),b(e,r.u_chromatic,n.chromatic),b(e,r.u_iridescence,n.iridescence),b(e,r.u_progress,n.progress??-1),b(e,r.u_audio,n.audio??0),Mn(e,r,n),kn(e,r,n),Tn(e,r,n)}function In(e,t,n){n.isDuotone&&(t.u_color1&&n.c1Rgba&&e.uniform4fv(t.u_color1,n.c1Rgba),t.u_color2&&n.c2Rgba&&e.uniform4fv(t.u_color2,n.c2Rgba))}function Fn(e,t,n){let r=le(e,t);r&&(r.u_tint&&n.tintRgba&&e.uniform4fv(r.u_tint,n.tintRgba),r.u_blend&&n.blendMode!==void 0&&e.uniform1i(r.u_blend,n.blendMode),r.u_duotone&&e.uniform1f(r.u_duotone,n.isDuotone?1:0),In(e,r,n),r.u_colors&&n.palette&&e.uniform4fv(r.u_colors,n.palette),S(e,r.u_colorCount,n.colorCount))}function Gn(e,t){return e.width<=0||e.height<=0?!1:e.bottom>=0&&e.top<=t}function q(e){return{height:e?.innerHeight??800,dpr:Math.min(e?.devicePixelRatio??1,2)}}function y(e,t=0){let n=parseFloat(e??"");return Number.isFinite(n)?n:t}function xt(e,t){let n=t?.getComputedStyle;if(typeof n!="function")return null;try{return n.call(t,e)}catch{return null}}function ce(e){return{left:e.left,top:e.top,right:e.left+e.width,bottom:e.top+e.height}}function se(e,t){return{left:Math.max(e.left,t.left),top:Math.max(e.top,t.top),right:Math.min(e.right,t.right),bottom:Math.min(e.bottom,t.bottom)}}function wt(e,t){return{left:e.left+t.left,top:e.top+t.top,right:e.right-t.right,bottom:e.bottom-t.bottom}}function _t(e){return{left:y(e.borderLeftWidth),top:y(e.borderTopWidth),right:y(e.borderRightWidth),bottom:y(e.borderBottomWidth)}}function Wn(e,t){let n=ce(e);if(!t)return n;let r=_t(t);return wt(n,{left:r.left+y(t.paddingLeft),top:r.top+y(t.paddingTop),right:r.right+y(t.paddingRight),bottom:r.bottom+y(t.paddingBottom)})}function On(e,t,n,r){let[i,o]=r;if(e==="cover"){let s=Math.max(t/i,n/o);return[i*s,o*s]}if(e==="none")return[i,o];if(e==="contain"||e==="scale-down"){let s=Math.min(t/i,n/o,e==="scale-down"?1:1/0);return[i*s,o*s]}return[t,n]}var Dn={left:0,top:0,center:.5,right:1,bottom:1};function ht(e,t){let n=Dn[e];return n!==void 0?t*n:e.endsWith("%")?t*(y(e)/100):y(e,t*.5)}function Un(e,t,n){if(!t||!n)return e;let r=e.right-e.left,i=e.bottom-e.top;if(r<=0||i<=0)return e;let[o,s]=On(n.objectFit||"fill",r,i,t),a=(n.objectPosition||"50% 50%").trim().split(/\s+/),u=e.left+ht(a[0]??"50%",r-o),l=e.top+ht(a[1]??"50%",i-s);return{left:u,top:l,right:u+o,bottom:l+s}}function ft(e,t){return e?e.endsWith("%")?Math.max(0,t*(y(e)/100)):Math.max(0,y(e)):0}function D(e,t,n){let r=(e??"").trim().split(/\s+/);return[ft(r[0],t),ft(r[1]??r[0],n)]}function Bn(e,t){if(!e)return[0,0,0,0,0,0,0,0];let n=t.width,r=t.height,i=D(e.borderTopLeftRadius,n,r),o=D(e.borderTopRightRadius,n,r),s=D(e.borderBottomRightRadius,n,r),a=D(e.borderBottomLeftRadius,n,r);return[i[0],i[1],o[0],o[1],s[0],s[1],a[0],a[1]]}function Hn(e){let{naturalWidth:t,naturalHeight:n}=e;return typeof t!="number"||typeof n!="number"||t<=0||n<=0?null:[t,n]}function Nn(e){for(let t of[e.overflowX,e.overflowY])if(t&&t!=="visible")return!0;return!1}var qn=12;function zn(e){return e.position&&e.position!=="static"?!0:[e.transform,e.filter,e.perspective].some(t=>t&&t!=="none")}function jn(e,t){return e==="fixed"?!1:e==="absolute"?zn(t):!0}function Vn(e,t,n){let r=xt(t,n);if(!r)return;let i=y(r.opacity,1);if(i<1&&(e.alpha*=Math.max(0,i)),jn(e.subject,r)){let o=Nn(r)?t.getBoundingClientRect?.():null;o&&(e.clip=se(e.clip,wt(ce(o),_t(r)))),e.subject=r.position||"static"}}function $n(e,t,n,r){let i={clip:n,alpha:1,subject:r},o=e.parentElement??null;for(let s=0;o&&s<qn;s++)Vn(i,o,t),o=o.parentElement??null;return i}function Lt(e,t,n=!1,r){let i=e.getBoundingClientRect(),{height:o}=q(t);if(!Gn(i,o))return null;let s=t??null,a=xt(e,s),u=ce(i),l=n?u:Wn(i,a),c=$n(e,s,l,a?.position||"static"),m=Math.max(0,Math.min(1,r??y(a?.opacity,1)));return{border:u,paint:n?u:Un(l,Hn(e),a),clip:c.clip,radii:Bn(a,i),alpha:c.alpha*m,hostAlpha:m}}function Xn(e,t,n){let r=e.border,i=e.radii;return{maskBox:[(r.left+r.right)*.5*n,t-(r.top+r.bottom)*.5*n,(r.right-r.left)*.5*n,(r.bottom-r.top)*.5*n],maskRx:[i[0]*n,i[2]*n,i[4]*n,i[6]*n],maskRy:[i[1]*n,i[3]*n,i[5]*n,i[7]*n]}}function Yn(e,t,n){let r=e.paint.right-e.paint.left,i=e.paint.bottom-e.paint.top;if(r<=0||i<=0)return null;let o={left:0,top:0,right:t.width/n,bottom:t.height/n},s=se(se(e.paint,e.clip),o),a=s.right-s.left,u=s.bottom-s.top;if(a<=0||u<=0)return null;let l=Math.round(s.left*n),c=Math.round(t.height-s.bottom*n),m=Math.min(t.width-l,Math.round(a*n)),p=Math.min(t.height-c,Math.round(u*n));if(m<=0||p<=0)return null;let v=e.border;return{sx:l,sy:c,sw:m,sh:p,rect:{left:v.left,top:v.top,width:v.right-v.left,height:v.bottom-v.top},uvOrigin:[(s.left-e.paint.left)/r,(s.top-e.paint.top)/i],uvScale:[a/r,u/i],alpha:e.alpha,...Xn(e,t.height,n)}}function Kn(e,t,n,r){let i=Yn(n,t,r);return i?(e.enable(e.SCISSOR_TEST),e.viewport(i.sx,i.sy,i.sw,i.sh),e.scissor(i.sx,i.sy,i.sw,i.sh),i):null}function Zn(e,t,n,r){if(!n)return;let i=le(e,t);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,n),i?.u_image&&e.uniform1i(i.u_image,0),i?.u_image_to&&(e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,r||n),e.uniform1i(i.u_image_to,1))}function Qn(e){return e?"program"in e&&e.program?e.program:e:null}function Jn(e,t){if(e.hasPointer===!1)return{x:.5,y:.5};let n=e.mouse.x-t.left,r=e.mouse.y-t.top;return{x:d(n/t.width,0,1),y:d(r/t.height,0,1)}}function er(e,t,n){e.bindBuffer(e.ARRAY_BUFFER,t);let r=n;r?.a_position!==void 0&&r.a_position!==-1&&(e.enableVertexAttribArray(r.a_position),e.vertexAttribPointer(r.a_position,2,e.FLOAT,!1,0,0))}function tr(e){let{gl:t,canvas:n,quadBuffer:r}=e;return t&&n&&r?{gl:t,canvas:n}:null}function Et(e,t,n={}){let r=tr(e);if(!r)return!1;let{gl:i,canvas:o}=r,s=n.mode??"displace",a=e.programs[s];if(a===void 0)return!1;let u=Qn(a);if(!u)return!1;let l=n.geometry!==void 0?n.geometry:Lt(t,e.window,de.has(s));if(!l)return!1;let c=Kn(i,o,l,q(e.window).dpr);if(!c)return!1;let m=Jn(e,c.rect);return i.useProgram(u),Zn(i,a,n.texture,n.toTexture),Pn(i,a,{...n,localMouse:m,uvOrigin:c.uvOrigin,uvScale:c.uvScale,maskBox:c.maskBox,maskRx:c.maskRx,maskRy:c.maskRy,maskAlpha:c.alpha}),Fn(i,a,n),er(i,e.quadBuffer,a),i.drawArrays(i.TRIANGLES,0,6),!0}var de=new Set(["gradient"]),Rt=["displace","fluid","liquid","particles","morph","gradient","logo"],nr=[[["displace"],Ue],[["fluid"],Be],[["liquid"],He],[["particles"],Ne],[["morph"],qe],[["gradient","logo"],ze]],pt={alpha:1,luma:2,"luma-invert":3},rr={none:0,stir:1,light:2,both:3},ir={evolve:0,drift:1,swirl:2};function or(e){return"keyword"in e&&typeof e.keyword=="function"?e.keyword("mode"):e.text("mode","displace")}function sr(e,t){return t==="logo"?pt[e.text("mask","alpha")]??pt.alpha:0}function ar(e,t,n){return{isDuotone:!!(e&&t),c1Rgba:M(e||"#000000",n),c2Rgba:M(t||"#ffffff",n)}}function ur(e,t){let n=or(e),r=e.text("color1",""),i=e.text("color2",""),o=e.text("backdrop","").trim(),s={normal:0,screen:1,multiply:2,add:3},{palette:a,colorCount:u}=Ln([r,i,e.text("color3",""),e.text("color4",""),e.text("color5","")],t);return{mode:n,seed:e.num("seed",0),scale:e.num("scale",1),warp:e.num("warp",0),noise:e.num("noise",0),grain:e.num("grain",0),hue:mt(e.text("hue","0deg")),detail:e.num("detail",3),bands:e.num("bands",0),palette:a,colorCount:u,maskMode:sr(e,n),hover:rr[e.text("hover","none")]??0,angle:mt(e.text("angle","0deg")),motion:ir[e.text("motion","evolve")]??0,backdropRgba:o?M(o,t):[0,0,0,0],strength:e.num("strength",.5),speed:e.num("speed",1),frequency:e.num("frequency",10),chromatic:e.num("chromatic",0),iridescence:e.num("iridescence",0),tintRgba:M(e.text("tint","#ffffff"),t),...ar(r,i,t),blendMode:s[e.text("blend","normal")]??0,to:e.text("to",""),progress:e.num?e.num("progress",-1):-1,scrubsFromScroll:e.text("scrub","off")==="scroll",audioBand:G(e.text("audio","off"))}}function vt(e){if(!e)return null;let t=parseFloat(e);return Number.isFinite(t)?d(t,0,1):null}function lr(e){let t=vt(e.style?.getPropertyValue?.("--kui-progress"));if(t!==null)return t;let n=e.ownerDocument?.defaultView,r=vt(n?.getComputedStyle?.(e).getPropertyValue("--kui-progress"));return r!==null?r:-1}var B=0;function U(e){try{e()}catch{return}}function gt(e,t,n){let r=t?.innerWidth??1e3,i=t?.innerHeight??800,o=Math.round(r*n),s=Math.round(i*n);(e.width!==o||e.height!==s)&&(e.width=o,e.height=s);let a=e.style;if(!a)return;let u=`${r}px`,l=`${i}px`;a.width!==u&&(a.width=u),a.height!==l&&(a.height=l)}var bt=1,kt="--kui-shader-z";function cr(e,t){let n=e?.documentElement;return n?St(n.style?.getPropertyValue?.(kt))??dr(n,t)??bt:bt}function dr(e,t){return St(t?.getComputedStyle?.(e)?.getPropertyValue?.(kt))}function St(e){let t=e?.trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)?Math.trunc(n):null}var ae=class{env;window;document;createCanvas;raf;caf;canvas=null;gl=null;quadBuffer=null;rafId=null;drawCalls=new Map;contextCallbacks=new Map;inputReaders=new Map;programs={};refCount=0;mouse={x:0,y:0};hasPointer=!1;isContextLost=!1;contextGeneration=0;mapKey;onPointer;onContextLost;onContextRestored;constructor(t={}){this.env=t;let n=h(null,t);this.window=n.window,this.document=n.document,this.createCanvas=n.createCanvas,this.raf=n.raf,this.caf=n.caf,this.mapKey=n.document??n.window??Ct}isDestroyed=!1;acquire(){if(this.isDestroyed)return!1;if(this.canvas&&this.isContextLost)return this.refCount++,!0;if(this.gl&&!this.isContextLost)return this.refCount++,!0;let t=this.init();return t&&this.refCount++,t}release(){this.refCount>0&&this.refCount--,this.refCount===0&&this.destroy()}init(){return!this.document?.body?.appendChild||(this.canvas=this.createCanvas(),!this.canvas)||(this.canvas.className="kui-shader-canvas",this.canvas.style.cssText=`position:fixed;top:0;left:0;pointer-events:none;z-index:${cr(this.document,this.window)};`,this.gl=this.canvas.getContext?this.canvas.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0}):null,!this.gl)?!1:(gt(this.canvas,this.window,q(this.window).dpr),this.document.body.appendChild(this.canvas),this.initQuad()?(this.initPrograms(),this.bindEvents(),this.startLoop(),!0):this.abandonInit())}abandonInit(){return Z(this.gl,this.quadBuffer,this.programs),this.canvas?.remove(),this.canvas=null,this.gl=null,this.quadBuffer=null,this.programs={},!1}initQuad(){let t=this.gl;if(!t||(this.quadBuffer=t.createBuffer(),!this.quadBuffer))return!1;try{t.bindBuffer(t.ARRAY_BUFFER,this.quadBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),t.STATIC_DRAW)}catch{return t.deleteBuffer&&t.deleteBuffer(this.quadBuffer),this.quadBuffer=null,!1}return!0}initPrograms(){let t=this.gl;if(t){this.programs={};for(let[n,r]of nr){let i=et(t,De,r);if(!i)continue;let o=tt(t,i);for(let s of n)this.programs[s]=o}}}bindEvents(){this.onPointer=t=>{this.mouse.x=t.clientX,this.mouse.y=t.clientY,this.hasPointer=!0},this.window?.addEventListener?.("pointermove",this.onPointer,{passive:!0}),this.canvas&&(this.onContextLost=t=>{t&&typeof t.preventDefault=="function"&&t.preventDefault(),this.isContextLost=!0,this.contextGeneration++,this.stopLoop();for(let n of this.contextCallbacks.values())U(()=>n.onLost())},this.onContextRestored=()=>{this.isContextLost=!1;let t=this.initQuad();this.initPrograms();for(let n of this.contextCallbacks.values())U(()=>n.onRestored());t&&this.startLoop()},this.canvas.addEventListener("webglcontextlost",this.onContextLost,!1),this.canvas.addEventListener("webglcontextrestored",this.onContextRestored,!1))}createTexture(t){return this.gl?nt(this.gl,t):null}register(t,n,r,i){this.drawCalls.set(t,n),r&&this.contextCallbacks.set(t,r),i&&this.inputReaders.set(t,i),this.isContextLost||this.startLoop()}unregister(t){this.drawCalls.delete(t),this.contextCallbacks.delete(t),this.inputReaders.delete(t)}startLoop(){if(this.rafId||this.isContextLost)return;let t=n=>{this.renderFrame(n*.001),this.drawCalls.size>0&&!this.isContextLost?this.rafId=this.raf(t):this.rafId=null};this.rafId=this.raf(t)}stopLoop(){this.rafId&&(this.caf(this.rafId),this.rafId=null)}renderFrame(t){let n=this.gl;if(!n||!this.canvas||this.isContextLost)return;let r=Math.min(this.window?.devicePixelRatio??1,2);gt(this.canvas,this.window,r),n.disable(n.SCISSOR_TEST),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT);for(let i of this.inputReaders.values())U(i);this.runDrawCalls(t)}runDrawCalls(t){for(let[n,r]of Array.from(this.drawCalls.entries())){let i=this.gl;if(!i||this.isContextLost)return;try{r(i,t)}catch{let o=this.contextCallbacks.get(n);o&&U(()=>o.onLost()),this.unregister(n)}}}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.stopLoop(),this.window?.removeEventListener&&this.onPointer&&this.window.removeEventListener("pointermove",this.onPointer),this.canvas&&(this.onContextLost&&this.canvas.removeEventListener("webglcontextlost",this.onContextLost),this.onContextRestored&&this.canvas.removeEventListener("webglcontextrestored",this.onContextRestored),this.canvas.remove(),this.canvas=null),Z(this.gl,this.quadBuffer,this.programs),this.gl=null,this.quadBuffer=null,this.isContextLost=!1,this.drawCalls.clear(),this.contextCallbacks.clear(),this.inputReaders.clear(),this.programs={},this.refCount=0,H.get(this.mapKey)===this&&H.delete(this.mapKey))}},H=new WeakMap,Ct={};function ue(e){let t=h(null,e),n=t.document??t.window??Ct,r=H.get(n);return(!r||r.isDestroyed)&&(r=new ae(e),H.set(n,r)),r}function mr(e){let t=ue(e);return{get(){return t.isDestroyed&&(t=ue(e)),t}}}function yt(e,t){let n=null,r=null,i=-1,o=s=>{n&&(r!==s||i!==s.contextGeneration)&&(n=null)};return{get(){let s=t.renderer;if(o(s),!n&&!s.isContextLost){let a=e();a&&(n=s.createTexture(a),r=s,i=s.contextGeneration)}return n},peek(){return o(t.renderer),n},reset(){n=null}}}function hr(e,t,n){let r=s=>s instanceof HTMLImageElement&&s.complete&&s.naturalWidth>0,i=yt(()=>r(e)?e:null,n),o=yt(()=>{let s=n.renderer.document;if(!t.to||!s)return null;try{let a=s.querySelector?.(t.to);return r(a)?a:null}catch{return null}},n);return{texHolder:i,toHolder:o}}function fr(e,t,n){let r=e.peek(),i=t.peek();r&&n.gl&&n.gl.deleteTexture(r),i&&i!==r&&n.gl&&n.gl.deleteTexture(i),e.reset(),t.reset(),n.release()}function pr(e,t){if(t.hiddenByRenderer)return;let n=g(t.ledgers,e);n&&(n.set("opacity","0"),t.hiddenByRenderer=!0)}function N(e,t){if(!t.hiddenByRenderer)return;t.hiddenByRenderer=!1;let n=g(t.ledgers,e);n&&n.set("opacity",n.peek("opacity")??"")}var vr=5e3;function gr(e,t){if(t&&!e.renderer.isDestroyed)return!0;let n=e.ref.get();return n.acquire()?(e.renderer=n,e.tex.reset(),e.to.reset(),!0):!1}function br(e){let t=e.opt.progress;return t!==void 0&&t>=0?t:e.opt.scrubsFromScroll?lr(e.el):-1}function yr(e,t,n,r){return(i,o)=>{let s=!1;try{let a=e.tex.get();s=(!!a||n)&&Et(e.renderer,e.el,{...e.opt,texture:a,toTexture:e.to.get(),time:o,progress:t.progress,audio:t.audio,geometry:t.geometry})}catch{r(),N(e.el,t),e.renderer.unregister(e.id);return}s&&!n?pr(e.el,t):n||N(e.el,t)}}function xr(e,t,n){return()=>{t(),n()&&e.arm()}}function wr(e,t,n){let r=null,i=0,o=()=>{i+=1;let s=r;r=null,s!==null&&e.clearTimer(s)};return{cancel:o,arm(){o();let s=i,a=e.setTimer(()=>{i===s&&(i+=1,r=null,n()||t())},vr);i===s&&(r=a)}}}function _r(e){let t={ledgers:L(e.el),hiddenByRenderer:!1,progress:-1,audio:0,geometry:null,hostAlpha:1},n=!1,r=!1,i=de.has(e.opt.mode),o=()=>{t.progress=br(e),t.audio=e.opt.audioBand?W(e.el,e.opt.audioBand):0;let p=t.hiddenByRenderer?t.hostAlpha:void 0;t.geometry=Lt(e.el,e.renderer.window,i,p),t.geometry?.hostAlpha!==void 0&&(t.hostAlpha=t.geometry.hostAlpha)},s=()=>{n&&(n=!1,e.renderer.unregister(e.id),N(e.el,t))},a=()=>{r&&(r=!1,fr(e.tex,e.to,e.renderer))},u=wr(e,a,()=>n),l=xr(u,()=>{n=!1},()=>r),c=yr(e,t,i,l),m=()=>{if(n)try{s()}finally{l()}};return w({continuous:!0,activate(){n||gr(e,r)&&(u.cancel(),r=!0,n=!0,e.renderer.register(e.id,c,{onLost(){e.tex.reset(),e.to.reset(),N(e.el,t)},onRestored(){}},o),e.renderer.startLoop())},cancel:m,finish:m,destroy(){s(),u.cancel(),a(),t.ledgers.restore()}})}var Lr=640;function Er(e,t,n){if(!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)return null;let r=Math.max(e.width,e.height)*n,i=Math.min(Lr,t.width,t.height),o=r>i?i/r:n,s=Math.max(1,Math.round(e.width*o)),a=Math.max(1,Math.round(e.height*o));return s<=t.width&&a<=t.height?[s,a]:null}function Rr(e,t,n,r){let i=r(),o=i?.getContext?.("2d");if(!i||!o)return null;i.width=t,i.height=n;try{return o.drawImage(e,0,0,t,n,0,0,t,n),i.toDataURL("image/png")}catch{return null}}function kr(e,t,n,r){let i=e.gl,o=e.canvas;if(!i||!o||typeof t.getBoundingClientRect!="function")return null;let s=q(e.window).dpr,a=Er(t.getBoundingClientRect(),o,s);if(!a)return null;let[u,l]=a,c={left:0,top:0,right:u/s,bottom:l/s};if(!Et(e,t,{...n,time:0,audio:0,texture:null,geometry:{border:c,paint:c,clip:c,radii:[0,0,0,0,0,0,0,0],alpha:1}}))return null;let p=Rr(o,u,l,r);return i.enable(i.SCISSOR_TEST),i.scissor(0,o.height-l,u,l),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),p}function Sr(e,t,n){if(!de.has(t.mode))return f();let r=e?.ownerDocument,i=h(n,r?{document:r,window:r.defaultView}:void 0),o=ue(i);if(!o.acquire())return f();let s=L(e);B+=1;let a=`kui-shader-static-${B}`,u=!1,l=()=>{u||(u=!0,o.unregister(a),o.release())};return o.register(a,()=>{let c=kr(o,e,t,i.createCanvas);if(!c)return;let m=g(s,e);m&&(m.set("background-image",`url("${c}")`),m.set("background-size","100% 100%"),m.set("background-repeat","no-repeat")),l()}),o.startLoop(),f(()=>{l(),s.restore()})}function me(e,t,n){let r=e?.ownerDocument,i=h(n,r?{document:r,window:r.defaultView}:void 0),o=ur(t,i.createCanvas);if(!Rt.includes(o.mode))return f();if(x(n))return Sr(e,o,n);let s=mr(i);B+=1;let u={id:`kui-shader-instance-${B}`,el:e,opt:o,renderer:s.get(),ref:s,setTimer:i.setTimer,clearTimer:i.clearTimer},l=hr(e,o,u);return u.tex=l.texHolder,u.to=l.toHolder,_r(u)}var he={mode:{type:"keyword",default:"displace",keywords:[...Rt],cssProperty:"--kui-shader-mode"},strength:{type:"number",default:"0.5",minimum:0,maximum:10,cssProperty:"--kui-shader-strength"},speed:{type:"number",default:"1.0",minimum:0,maximum:10,cssProperty:"--kui-shader-speed"},frequency:{type:"number",default:"10.0",minimum:.1,maximum:50,cssProperty:"--kui-shader-frequency"},chromatic:{type:"number",default:"0.0",minimum:0,maximum:1,cssProperty:"--kui-shader-chromatic"},iridescence:{type:"number",default:"0.0",minimum:0,maximum:8,cssProperty:"--kui-shader-iridescence"},tint:{type:"color",default:"#ffffff",cssProperty:"--kui-shader-tint"},color1:{type:"color",default:"",cssProperty:"--kui-shader-color1"},color2:{type:"color",default:"",cssProperty:"--kui-shader-color2"},color3:{type:"color",default:"",cssProperty:"--kui-shader-color3"},color4:{type:"color",default:"",cssProperty:"--kui-shader-color4"},color5:{type:"color",default:"",cssProperty:"--kui-shader-color5"},seed:{type:"number",default:"0",minimum:0,maximum:9999,integer:!0,cssProperty:"--kui-shader-seed"},scale:{type:"number",default:"1",minimum:.05,maximum:20,cssProperty:"--kui-shader-scale"},detail:{type:"number",default:"3",minimum:1,maximum:6,integer:!0,cssProperty:"--kui-shader-detail"},warp:{type:"number",default:"0",minimum:0,maximum:2,cssProperty:"--kui-shader-warp"},noise:{type:"number",default:"0",minimum:0,maximum:1,cssProperty:"--kui-shader-noise"},bands:{type:"number",default:"0",minimum:0,maximum:32,integer:!0,cssProperty:"--kui-shader-bands"},grain:{type:"number",default:"0",minimum:0,maximum:1,cssProperty:"--kui-shader-grain"},hue:{type:"angle",default:"0deg",cssProperty:"--kui-shader-hue"},mask:{type:"keyword",default:"alpha",keywords:["alpha","luma","luma-invert"],cssProperty:"--kui-shader-mask"},hover:{type:"keyword",default:"none",keywords:["none","stir","light","both"],cssProperty:"--kui-shader-hover"},backdrop:{type:"color",default:"",cssProperty:"--kui-shader-backdrop"},angle:{type:"angle",default:"0deg",cssProperty:"--kui-shader-angle"},motion:{type:"keyword",default:"evolve",keywords:["evolve","drift","swirl"],cssProperty:"--kui-shader-motion"},blend:{type:"keyword",default:"normal",keywords:["normal","screen","multiply","add"],cssProperty:"--kui-shader-blend"},to:{type:"text",default:"",cssProperty:"--kui-shader-to"},progress:{type:"number",default:"-1",minimum:-1,maximum:1,cssProperty:"--kui-shader-progress"},scrub:{type:"keyword",default:"off",keywords:["off","scroll"],cssProperty:"--kui-shader-scrub"},audio:{type:"keyword",default:"off",keywords:["off",...F],cssProperty:"--kui-shader-audio"}},fe={id:"shaders",renderer:"javascript",channels:["opacity"],parameters:he,supportedTimelines:["time","view","scroll"],supportedActivations:["load","enter","hover","click"],defaultActivation:"load",perfClass:"continuous",reducedMotion:"disable",prepare:me},pe=[{name:"shaders",primitive:"shaders"},{name:"shader-displace",primitive:"shaders",params:{mode:"displace"}},{name:"shader-fluid",primitive:"shaders",params:{mode:"fluid"}},{name:"fluid-pointer",primitive:"shaders",params:{mode:"fluid"}},{name:"shader-liquid",primitive:"shaders",params:{mode:"liquid"}},{name:"liquid-distort",primitive:"shaders",params:{mode:"liquid"}},{name:"shader-particles",primitive:"shaders",params:{mode:"particles"}},{name:"particle-field",primitive:"shaders",params:{mode:"particles"}},{name:"shader-morph",primitive:"shaders",params:{mode:"morph"}},{name:"image-morph",primitive:"shaders",params:{mode:"morph"}},{name:"shader-gradient",primitive:"shaders",params:{mode:"gradient"}},{name:"gradient-liquid",primitive:"shaders",params:{mode:"gradient",warp:"1.1",detail:"4",speed:"0.4"}},{name:"gradient-bands",primitive:"shaders",params:{mode:"gradient",bands:"8",warp:"0.6",speed:"0.3"}},{name:"gradient-holo",primitive:"shaders",params:{mode:"gradient",iridescence:"3",chromatic:"0.5",warp:"0.4",speed:"0.5"}},{name:"shader-logo",primitive:"shaders",params:{mode:"logo"}},{name:"logo-gradient",primitive:"shaders",params:{mode:"logo",warp:"0.8",detail:"4",scale:"1.6",speed:"0.4"}}];function z(e){return _(e,fe,pe,"Shaders")}var Mt=String.raw`-?(?:\d+(?:\.\d+)?|\.\d+)`,Cr=new RegExp(String.raw`\bfrom:(${Mt})`),Ar=new RegExp(String.raw`\bto:(${Mt})`),Tr=/\bopacity:([0-9.]+)->([0-9.]+)/,Mr=/\bx:([+-]?[0-9.]+[a-z%]*)->([+-]?[0-9.]+[a-z%]*)/i,Pr=/\by:([+-]?[0-9.]+[a-z%]*)->([+-]?[0-9.]+[a-z%]*)/i,Ir=/\bscale:([0-9.]+)->([0-9.]+)/;function Fr(e){return[At(Cr,e,0),At(Ar,e,1)]}function At(e,t,n){let r=e.exec(t);if(!r)return n;let i=parseFloat(r[1]);return i>=0&&i<=1?i:n}function Tt(e){let t=e.length-1;for(;t>=0&&(e[t]>="a"&&e[t]<="z"||e[t]>="A"&&e[t]<="Z"||e[t]==="%");)t--;return e.slice(t+1)}function j(e){if(!e)return null;let t=e.indexOf("->");if(t===-1)return null;let n=e.slice(0,t).trim(),r=e.slice(t+2).trim(),i=parseFloat(n),o=parseFloat(r);if(Number.isNaN(i)||Number.isNaN(o))return null;let s=Tt(n)||Tt(r);return{from:i,to:o,unit:s}}function Gr(e){let t=e?.getAttribute&&e.getAttribute("data-kui")||"",n=Fr(t),r=Tr.exec(t),i=r?j(`${r[1]}->${r[2]}`):null,o=Mr.exec(t),s=o?j(`${o[1]}->${o[2]}`):null,a=Pr.exec(t),u=a?j(`${a[1]}->${a[2]}`):null,l=Ir.exec(t),c=l?j(`${l[1]}->${l[2]}`):null;return{range:n,opacity:i,x:s,y:u,scale:c}}function Wr(e,t){let n=[];return e.x&&n.push(`translateX(${A(e.x.from,e.x.to,t)}${e.x.unit})`),e.y&&n.push(`translateY(${A(e.y.from,e.y.to,t)}${e.y.unit})`),e.scale&&n.push(`scale(${A(e.scale.from,e.scale.to,t)})`),n.join(" ")}var Or=800,ve=class{container;options;env;window;raf;caf;steps=[];progress=0;rafId=null;isListening=!1;timeStart=0;ledgers;constructor(t,n={},r={}){this.container=t,this.options=n,this.env=r;let i=h(null,r);this.window=i.window,this.raf=i.raf,this.caf=i.caf,this.ledgers=L(t),this.onScroll=this.onScroll.bind(this)}addStep(t,n){this.steps.push({element:t,config:n})}start(t){this.isListening||!this.window&&this.options.progress!=="time"||(this.isListening=!0,this.options.progress==="time"?this.startTimeLoop(t):(this.window?.addEventListener&&(this.window.addEventListener("scroll",this.onScroll,{passive:!0}),this.window.addEventListener("resize",this.onScroll,{passive:!0})),this.onScroll()))}stop(){this.isListening&&(this.window?.removeEventListener&&(this.window.removeEventListener("scroll",this.onScroll),this.window.removeEventListener("resize",this.onScroll)),this.rafId&&this.caf(this.rafId),this.rafId=null,this.isListening=!1)}startTimeLoop(t){let n=this.options.duration||1e3,r=()=>this.window?.performance?.now?this.window.performance.now():Date.now();this.timeStart=r();let i=()=>{if(!this.isListening){this.rafId=null;return}let o=r()-this.timeStart;if(this.progress=d(o/n,0,1),this.updateAll(),this.progress<1){this.rafId=this.raf(i);return}this.rafId=null,this.isListening=!1,t&&t()};this.rafId=this.raf(i)}onScroll(){this.rafId||(this.rafId=this.raf(()=>{this.rafId=null,this.calculateProgress(),this.updateAll()}))}calculateProgress(){if(!this.container?.getBoundingClientRect){this.progress=0;return}let t=this.window?.innerHeight??Or,n=this.container.getBoundingClientRect(),r=t+n.height,i=t-n.top;this.progress=r>0?d(i/r,0,1):0}updateAll(){for(let t of this.steps)this.updateElement(t.element,t.config,this.progress)}updateElement(t,n,r){let[i,o]=n.range;if(i>=o)return;let s=g(this.ledgers,t);if(!s)return;let a=d((r-i)/(o-i),0,1);n.opacity&&s.set("opacity",String(A(n.opacity.from,n.opacity.to,a)));let u=Wr(n,a);u&&s.set("transform",u)}destroy(){try{this.stop()}finally{this.ledgers.restore(),this.steps=[]}}};function ge(e,t,n){let r=h(n),o=(t.text?t.text("progress","scroll"):"scroll")==="time"?"time":"scroll",s=d(t.num?t.num("duration",1e3):1e3,100,6e4),a=e,u=new ve(a,{progress:o,duration:s},r),l=I(a,"scene","scene-step");for(let m of l){let p=Gr(m),[v,E]=p.range;v>=E&&n?.warn(`scene-step from:${v} to:${E} is an empty window \u2014 from: must be less than to:, so this step never animates`),u.addStep(m,p)}if(x(n))return u.progress=1,u.updateAll(),f(()=>u.destroy());let c=w({continuous:o==="scroll",activate(){o==="time"?u.start(()=>c.finish()):u.start()},cancel(){u.stop()},finish(){u.progress=1,u.updateAll(),u.stop()},destroy(){u.destroy()}});return c}var be={progress:{type:"keyword",default:"scroll",keywords:["scroll","time"],cssProperty:"--kui-scene-progress"},duration:{type:"number",default:"1000",minimum:100,maximum:6e4,cssProperty:"--kui-scene-duration"}},Dr={from:{type:"number",default:"0",minimum:0,maximum:1,cssProperty:"--kui-scene-step-from"},to:{type:"number",default:"1",minimum:0,maximum:1,cssProperty:"--kui-scene-step-to"},opacity:{type:"text",default:"",cssProperty:"--kui-scene-step-opacity"},x:{type:"text",default:"",cssProperty:"--kui-scene-step-x"},y:{type:"text",default:"",cssProperty:"--kui-scene-step-y"},scale:{type:"text",default:"",cssProperty:"--kui-scene-step-scale"}};function Ur(){return f()}var ye=[{id:"scene",renderer:"javascript",channels:["opacity","skew"],parameters:be,supportedTimelines:["scroll","time"],supportedActivations:["load","enter"],defaultActivation:"load",perfClass:"continuous",reducedMotion:"disable",prepare:ge},{id:"scene-step",renderer:"javascript",channels:["opacity","skew"],parameters:Dr,supportedTimelines:["scroll","time"],supportedActivations:["load","enter"],defaultActivation:"load",perfClass:"dom-transform",reducedMotion:"disable",prepare:Ur}],xe=[{name:"scene",primitive:"scene"},{name:"scene-step",primitive:"scene-step"}];function V(e){return _(e,ye,xe,"Scenes")}var Br=.1;function Hr(e){if(!e)return 0;let t=parseFloat(e);return Number.isNaN(t)?0:t}function Nr(e,t,n=0,r=0){let i=e+t*.5;return n||r?`translate3d(0, 0, ${i}px) rotateX(${n}deg) rotateY(${r}deg)`:`translate3d(0, 0, ${i}px)`}var we=class{container;options;env;window;raf;caf;layers=[];cameraZ=0;mouse={x:0,y:0,targetX:0,targetY:0};rafId=null;scrollRafId=null;audioRafId=null;audioLevel=0;isListening=!1;ledgers;constructor(t,n={},r={}){this.container=t,this.options=n,this.env=r;let i=h(null,r);this.window=i.window,this.raf=i.raf,this.caf=i.caf,this.ledgers=L(t),this.onScroll=this.onScroll.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}addLayer(t,n){this.layers.push({element:t,depthZ:n})}applyLayer3D(){for(let t of this.layers)g(this.ledgers,t.element)?.set("transform-style","preserve-3d")}bindEvents(){this.window?.addEventListener&&(this.window.addEventListener("scroll",this.onScroll,{passive:!0}),this.options.mouseTilt&&this.window.addEventListener("pointermove",this.onMouseMove,{passive:!0}))}applyStage(){let t=g(this.ledgers,this.container);t?.set("perspective",`${this.options.depth||1e3}px`),t?.set("transform-style","preserve-3d"),this.applyLayer3D()}renderStatic(){this.container&&(this.applyStage(),this.render())}start(){this.isListening||!this.container||(this.applyStage(),this.bindEvents(),this.isListening=!0,this.updateScroll(),this.readAudio(),this.render(),this.startAudioLoop(),this.startLoop())}stop(){this.isListening&&(this.window?.removeEventListener&&(this.window.removeEventListener("scroll",this.onScroll),this.window.removeEventListener("pointermove",this.onMouseMove)),this.rafId&&this.caf(this.rafId),this.rafId=null,this.scrollRafId&&this.caf(this.scrollRafId),this.scrollRafId=null,this.audioRafId&&this.caf(this.audioRafId),this.audioRafId=null,this.isListening=!1)}updateScroll(){if(!this.container?.getBoundingClientRect)return;let t=this.window?.innerHeight??800,n=this.container.getBoundingClientRect(),r=t+n.height,i=t-n.top,o=r>0?d(i/r,0,1):0;this.cameraZ=o*(this.options.depth||1e3)}readAudio(){this.audioLevel=this.options.audio?W(this.container,this.options.audio):0}startAudioLoop(){if(this.audioRafId||!this.options.audio)return;let t=()=>{this.updateScroll(),this.readAudio(),this.options.mouseTilt&&this.stepMouse(),this.render(),this.audioRafId=this.isListening?this.raf(t):null};this.audioRafId=this.raf(t)}onScroll(){if(this.scrollRafId||this.audioRafId)return;let t=this.raf(()=>{this.scrollRafId=null,this.updateScroll(),this.render()});t==null?(this.updateScroll(),this.render()):this.scrollRafId=t}onMouseMove(t){if(!this.options.mouseTilt)return;let n=this.window?.innerWidth??1e3,r=this.window?.innerHeight??800,i=n*.5,o=r*.5;this.mouse.targetX=(t.clientX-i)/i,this.mouse.targetY=(t.clientY-o)/o,this.startLoop()}stepMouse(){let t=this.mouse.targetX-this.mouse.x,n=this.mouse.targetY-this.mouse.y;return this.mouse.x+=t*.08,this.mouse.y+=n*.08,Math.abs(t)<.001&&Math.abs(n)<.001?(this.mouse.x=this.mouse.targetX,this.mouse.y=this.mouse.targetY,!1):!0}startLoop(){if(this.rafId||this.audioRafId||!this.options.mouseTilt)return;let t=()=>{let n=this.stepMouse();this.render(),this.isListening&&n?this.rafId=this.raf(t):this.rafId=null};this.rafId=this.raf(t)}renderStageTilt(t,n){let r=g(this.ledgers,this.container);if(r){if(r.claim("transform"),t!==0||n!==0){r.set("transform",`rotateX(${t.toFixed(2)}deg) rotateY(${n.toFixed(2)}deg)`);return}this.restStageTransform(r)}}restStageTransform(t){let n=t.peek("transform");if(n){t.set("transform",n);return}this.container.style.removeProperty("transform")}render(){this.options.mouseTilt&&this.renderStageTilt(this.mouse.y*-8,this.mouse.x*8);let t=this.cameraZ+this.audioLevel*(this.options.depth||1e3)*Br;for(let n of this.layers)g(this.ledgers,n.element)?.set("transform",Nr(n.depthZ,t))}destroy(){try{this.stop()}finally{this.ledgers.restore(),this.layers=[]}}};function qr(e){return e.is?e.is("mouse-tilt","on"):e.text?e.text("mouse-tilt","on")==="on":!0}function _e(e,t,n){let r=h(n),i=d(t.num?t.num("depth",1e3):1e3,100,5e3),o=qr(t),s=G(t.text?t.text("audio","off"):"off"),a=x(n),u=a?{depth:i,mouseTilt:!1,audio:null}:{depth:i,mouseTilt:o,audio:s},l=e,c=new we(l,u,r),m=I(l,"camera-scene","camera-layer");for(let p of m){let v=p.getAttribute("data-kui")||"",E=/z:([+-]?[0-9.]+)(?:px)?/.exec(v),It=E?Hr(E[1]):0;c.addLayer(p,It)}return a?(c.renderStatic(),f(()=>c.destroy())):w({continuous:!0,activate(){c.start()},cancel(){c.stop()},finish(){c.stop()},destroy(){c.destroy()}})}var Le={depth:{type:"number",default:"1000",minimum:100,maximum:5e3,cssProperty:"--kui-camera-depth"},"mouse-tilt":{type:"keyword",default:"on",keywords:["on","off"],cssProperty:"--kui-camera-tilt"},audio:{type:"keyword",default:"off",keywords:["off",...F],cssProperty:"--kui-camera-audio"}},zr={z:{type:"number",default:"0",minimum:-5e3,maximum:5e3,cssProperty:"--kui-camera-layer-z"}};function jr(){return f()}var Ee=[{id:"camera-scene",renderer:"javascript",channels:["skew","perspective","transform-style"],parameters:Le,supportedTimelines:["scroll","time"],supportedActivations:["load","enter"],defaultActivation:"load",perfClass:"continuous",reducedMotion:"disable",prepare:_e},{id:"camera-layer",renderer:"javascript",channels:["translate","rotate","transform-style"],parameters:zr,supportedTimelines:["scroll","time"],supportedActivations:["load","enter"],defaultActivation:"load",perfClass:"dom-transform",reducedMotion:"disable",prepare:jr}],Re=[{name:"camera-scene",primitive:"camera-scene"},{name:"camera-layer",primitive:"camera-layer"}];function $(e){return _(e,Ee,Re,"Camera")}function Vr(e,t,n,r){let i=t-e.x,o=n-e.y,s=Math.hypot(i,o);if(s<r&&s>0){let l=(r-s)/r;e.vx-=i/s*l*5,e.vy-=o/s*l*5}let a=e.originX-e.x,u=e.originY-e.y;e.vx+=a*.05,e.vy+=u*.05,e.vx*=.88,e.vy*=.88,e.x+=e.vx,e.y+=e.vy}function $r(e,t,n,r){let i=Math.max(1,Math.round(Math.sqrt(e*(n/Math.max(r,1))))),o=Math.max(1,Math.ceil(e/i)),s=[];for(let a=0;a<e;a++){let u=a%i*(n/i)+n/(i*2),l=Math.floor(a/i)*(r/o)+r/(o*2);s.push({x:u,y:l,originX:u,originY:l,vx:0,vy:0,radius:a%3+1.5,color:t})}return s}function Xr(e){return Math.abs(e.vx)>.02||Math.abs(e.vy)>.02?!0:Math.abs(e.x-e.originX)>.5||Math.abs(e.y-e.originY)>.5}var ke=class{element;options;env;window;document;createCanvas;raf;caf;canvas=null;ctx=null;particles=[];mouse={x:-999,y:-999};rafId=null;isListening=!1;dpr=1;ledgers;constructor(t,n={},r={}){this.element=t,this.options=n,this.env=r,this.ledgers=L(t);let i=h(null,r);this.window=i.window,this.document=i.document,this.createCanvas=i.createCanvas,this.raf=i.raf,this.caf=i.caf,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onResize=this.onResize.bind(this)}syncDimensions(){if(!this.canvas||!this.element?.getBoundingClientRect)return 1;let t=this.element.getBoundingClientRect();this.dpr=Math.min(this.window?.devicePixelRatio??1,2);let n=Math.round(t.width*this.dpr),r=Math.round(t.height*this.dpr);return(this.canvas.width!==n||this.canvas.height!==r)&&(this.canvas.width=n,this.canvas.height=r,this.canvas.style.width=`${t.width}px`,this.canvas.style.height=`${t.height}px`),this.dpr}setupPosition(){this.window?.getComputedStyle&&this.window.getComputedStyle(this.element).position==="static"&&g(this.ledgers,this.element)?.set("position","relative")}init(){if(!this.document||!this.element?.getBoundingClientRect||(this.canvas=this.createCanvas(),!this.canvas)||(this.canvas.className="kui-particle-canvas",this.canvas.style.cssText="position:absolute;top:0;left:0;pointer-events:none;z-index:10;",this.ctx=this.canvas.getContext?this.canvas.getContext("2d"):null,!this.ctx))return!1;this.setupPosition(),this.element.appendChild(this.canvas),this.syncDimensions();let t=this.element.getBoundingClientRect();return this.spawnParticles(t.width,t.height),this.bindEvents(),!0}spawnParticles(t,n){let r=this.options.count||60,i=this.options.color||"#e4f222";this.particles=$r(r,i,t,n)}resizeObserver=null;bindEvents(){this.isListening||(this.element.addEventListener("pointermove",this.onMouseMove,{passive:!0}),this.element.addEventListener("pointerleave",this.onMouseLeave,{passive:!0}),typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(()=>this.onResize()),this.resizeObserver.observe(this.element)):this.window?.addEventListener&&this.window.addEventListener("resize",this.onResize,{passive:!0}),this.isListening=!0)}unbindEvents(){this.isListening&&(this.element?.removeEventListener&&(this.element.removeEventListener("pointermove",this.onMouseMove),this.element.removeEventListener("pointerleave",this.onMouseLeave)),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.window?.removeEventListener&&this.window.removeEventListener("resize",this.onResize),this.isListening=!1)}onResize(){if(this.syncDimensions(),this.element?.getBoundingClientRect){let t=this.element.getBoundingClientRect();t.width>0&&t.height>0&&this.spawnParticles(t.width,t.height)}this.draw()}onMouseMove(t){if(!this.canvas?.getBoundingClientRect)return;let n=this.canvas.getBoundingClientRect();this.mouse.x=t.clientX-n.left,this.mouse.y=t.clientY-n.top,this.startLoop()}onMouseLeave(){this.mouse.x=-999,this.mouse.y=-999}startLoop(){if(this.rafId)return;let t=()=>{let n=this.update();this.draw(),this.isListening&&(n||this.mouse.x!==-999)?this.rafId=this.raf(t):this.rafId=null};this.rafId=this.raf(t)}stopLoop(){this.rafId&&(this.caf(this.rafId),this.rafId=null)}update(){let t=this.options.radius||80,n=!1;for(let r of this.particles)Vr(r,this.mouse.x,this.mouse.y,t),Xr(r)&&(n=!0);return n}draw(){if(!this.ctx||!this.canvas)return;let t=this.dpr||1;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(let n of this.particles)this.ctx.beginPath(),this.ctx.arc(n.x*t,n.y*t,n.radius*t,0,Math.PI*2),this.ctx.fillStyle=n.color,this.ctx.fill()}destroy(){try{this.stopLoop(),this.unbindEvents()}finally{this.ledgers.restore(),this.removeCanvas()}}removeCanvas(){this.canvas?.remove(),this.canvas=null,this.ctx=null,this.particles=[]}};function Se(e,t,n){if(x(n))return f();let r=h(n),i=d(t.num?t.num("count",60):60,10,300),o=d(t.num?t.num("radius",80):80,20,300),s=t.text?t.text("color","#e4f222"):"#e4f222",a=e,u=new ke(a,{count:i,radius:o,color:s},r),l=!1;return w({continuous:!0,activate(){l?u.isListening||u.bindEvents():l=u.init(),l&&u.startLoop()},cancel(){u.stopLoop(),u.unbindEvents()},finish(){u.stopLoop(),u.unbindEvents()},destroy(){l&&(u.destroy(),l=!1)}})}var Ce={count:{type:"number",default:"60",minimum:10,maximum:300,cssProperty:"--kui-particle-count"},radius:{type:"number",default:"80",minimum:20,maximum:300,cssProperty:"--kui-particle-radius"},color:{type:"color",default:"#e4f222",cssProperty:"--kui-particle-color"}},Ae=[{id:"particle-dissolve",renderer:"javascript",channels:["position"],parameters:Ce,supportedTimelines:["time"],supportedActivations:["hover","load"],defaultActivation:"hover",perfClass:"continuous",reducedMotion:"disable",prepare:Se}],Te=[{name:"particle-dissolve",primitive:"particle-dissolve"}];function X(e){return _(e,Ae,Te,"Particles")}function Yr(e,t){return e.x+=e.vx,e.y+=e.vy,e.vx*=t,e.vy*=t,e.alpha*=.94,e.alpha<.02}function Kr(e,t,n){let r=e.style;if(!r)return;let i=`${t}px`,o=`${n}px`;r.width!==i&&(r.width=i),r.height!==o&&(r.height=o)}function Me(e,t){if(!e)return 1;let n=Math.min(t?.devicePixelRatio??1,2),r=t?.innerWidth??1e3,i=t?.innerHeight??800,o=Math.round(r*n),s=Math.round(i*n);return(e.width!==o||e.height!==s)&&(e.width=o,e.height=s),Kr(e,r,i),n}var Pe=class{options;env;window;document;createCanvas;raf;caf;drops=[];canvas=null;ctx=null;rafId=null;isListening=!1;lastMouse={x:0,y:0};hasLastMouse=!1;wasOutside=!1;refCount=0;clients=new Map;activeClients=new Map;nextClientId=1;onResize;onPointerMove;mapKey;constructor(t={},n={}){this.options=t,this.env=n;let r=h(null,n);this.window=r.window,this.document=r.document,this.createCanvas=r.createCanvas,this.raf=r.raf,this.caf=r.caf,this.mapKey=r.document??r.window??Pt}acquire(){if(this.ctx)return this.refCount++,!0;let t=this.init();return t&&this.refCount++,t}release(){this.refCount>0&&this.refCount--,this.refCount===0&&this.clients.size===0&&this.destroy()}registerClient(t,n){let r=this.nextClientId++;return this.clients.set(r,{options:t,el:n}),r}activateClient(t){let n=this.clients.get(t);return!n||(this.activeClients.set(t,n),!this.canvas&&!this.setupCanvas())?!1:(this.attachListeners(),this.startLoop(),!0)}deactivateClient(t){this.activeClients.delete(t),!(this.activeClients.size>0||this.refCount>0)&&(this.detachListeners(),this.stopLoop(),this.clearOverlay())}clearOverlay(){this.drops=[];let t=this.canvas;!t||typeof this.ctx?.clearRect!="function"||this.ctx.clearRect(0,0,t.width,t.height)}unregisterClient(t){this.deactivateClient(t),this.clients.delete(t),this.clients.size===0&&this.refCount===0&&this.destroy()}setupCanvas(){return this.canvas&&this.ctx?!0:!this.document?.body?.appendChild||(this.canvas=this.createCanvas(),!this.canvas)?!1:(this.canvas.className="kui-fluid-canvas",this.canvas.style.cssText="position:fixed;top:0;left:0;pointer-events:none;z-index:9998;",this.ctx=this.canvas.getContext?this.canvas.getContext("2d"):null,this.ctx?(this.document.body.appendChild(this.canvas),Me(this.canvas,this.window),!0):(this.canvas=null,!1))}attachListeners(){this.isListening||(this.onResize=()=>Me(this.canvas,this.window),this.onPointerMove=t=>{let n=this.resolveClientOwner(t);if(!n){this.lastMouse.x=t.clientX,this.lastMouse.y=t.clientY,this.wasOutside=!0;return}let r=this.wasOutside,i=r?0:t.clientX-this.lastMouse.x,o=r?0:t.clientY-this.lastMouse.y;if(this.wasOutside=!1,Math.hypot(i,o)>2||r||!this.hasLastMouse){this.hasLastMouse=!0;let s=Math.max(-20,Math.min(20,i*.2)),a=Math.max(-20,Math.min(20,o*.2));this.spawnDrop(t.clientX,t.clientY,s,a,n.options),this.startLoop()}this.lastMouse.x=t.clientX,this.lastMouse.y=t.clientY},this.window?.addEventListener&&(this.window.addEventListener("resize",this.onResize,{passive:!0}),this.window.addEventListener("pointermove",this.onPointerMove,{passive:!0}),this.isListening=!0))}detachListeners(){this.window?.removeEventListener&&this.isListening&&(this.onResize&&this.window.removeEventListener("resize",this.onResize),this.onPointerMove&&this.window.removeEventListener("pointermove",this.onPointerMove),this.isListening=!1,this.hasLastMouse=!1,this.wasOutside=!1)}init(){return this.setupCanvas()?(this.attachListeners(),!0):!1}findClientByTarget(t){let n=t&&typeof t.nodeType=="number"?t:null;for(;n;){for(let r of this.activeClients.values())if(r.el&&r.el===n)return r;n=n.parentNode}return null}findClientByCoords(t,n){for(let r of this.activeClients.values()){let i=r.el?.getBoundingClientRect?.();if(i&&t>=i.left&&t<=i.right&&n>=i.top&&n<=i.bottom)return r}return null}resolveClientOwner(t){return this.activeClients.size===0?{options:this.options,el:void 0}:this.findClientByTarget(t.target)??this.findClientByCoords(t.clientX,t.clientY)}getOptionsAt(t,n){return this.findClientByCoords(t,n)?.options??null}spawnDrop(t,n,r,i,o){let s=o??(this.activeClients.size===0?this.options:this.getOptionsAt(t,n));s&&this.drops.push({x:t,y:n,vx:r,vy:i,size:s.size??this.options.size??28,alpha:.8,color:s.color??this.options.color??"#e4f222",viscosity:s.viscosity??this.options.viscosity??.88})}startLoop(){if(this.rafId)return;let t=()=>{this.update(),this.draw(),this.drops.length>0&&this.ctx?this.rafId=this.raf(t):this.rafId=null};this.rafId=this.raf(t)}stopLoop(){this.rafId&&(this.caf(this.rafId),this.rafId=null)}update(){for(let t=this.drops.length-1;t>=0;t--){let n=this.drops[t];n&&Yr(n,n.viscosity??.88)&&this.drops.splice(t,1)}}draw(){let t=this.ctx;if(!t||!this.canvas)return;let n=Me(this.canvas,this.window);t.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r of this.drops)typeof t.save=="function"&&t.save(),t.globalAlpha=r.alpha,t.fillStyle=r.color,t.beginPath(),t.arc(r.x*n,r.y*n,r.size*n*.5,0,Math.PI*2),t.fill(),typeof t.restore=="function"&&t.restore()}destroy(){this.stopLoop(),this.detachListeners(),this.canvas&&(this.canvas.remove(),this.canvas=null),this.ctx=null,this.drops=[],this.refCount=0,this.clients.clear(),this.activeClients.clear(),Ie.delete(this.mapKey)}},Ie=new WeakMap,Pt={};function Zr(e){let t=h(null,e),n=t.document??t.window??Pt,r=Ie.get(n);return r||(r=new Pe({},e),Ie.set(n,r)),r}function Fe(e,t,n){if(x(n))return f();let r=e?.ownerDocument,i=h(n,r?{document:r,window:r.defaultView}:void 0);if(!i.document?.body)return f();let o=d(t.num?t.num("size",28):28,4,120),s=d(t.num?t.num("viscosity",.88):.88,.1,.99),a=t.text?t.text("color","#e4f222"):"#e4f222",u=Zr(i),l=u.registerClient({size:o,viscosity:s,color:a},e);return w({continuous:!0,activate(){u.activateClient(l)},cancel(){u.deactivateClient(l)},finish(){u.deactivateClient(l)},destroy(){u.unregisterClient(l)}})}var Ge={size:{type:"number",default:"28",minimum:4,maximum:120,cssProperty:"--kui-fluid-size"},viscosity:{type:"number",default:"0.88",minimum:.1,maximum:.99,cssProperty:"--kui-fluid-viscosity"},color:{type:"color",default:"#e4f222",cssProperty:"--kui-fluid-color"}},We=[{id:"fluid-trail",renderer:"javascript",channels:[],parameters:Ge,supportedTimelines:["time"],supportedActivations:["load","hover"],defaultActivation:"load",perfClass:"continuous",reducedMotion:"disable",prepare:Fe}],Oe=[{name:"fluid-trail",primitive:"fluid-trail"},{name:"cursor-fluid",primitive:"fluid-trail"},{name:"fluid-cursor",primitive:"fluid-trail"}];function Y(e){return _(e,We[0],Oe,"FluidCursor")}function Qr(e){return z(e),V(e),$(e),X(e),Y(e),O(e),e?.registry||e}return Ut(Jr);})();
|
|
744
|
+
|
|
745
|
+
;(function () {
|
|
746
|
+
"use strict";var __kuineticBoot=(()=>{var l=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var v=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},R=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of b(n))!w.call(e,o)&&o!==t&&l(e,o,{get:()=>n[o],enumerable:!(r=k(n,o))||r.enumerable});return e};var y=e=>R(l({},"__esModule",{value:!0}),e);var I={};v(I,{boot:()=>B});var g="__kuineticRuntime";function c(){return globalThis}function O(){let e=c(),n=e[g];if(n)return n;let t={v:1,animator:null,pending:[],booted:!1,started:!1,manual:!1,scheduled:!1,warnedVersion:!1,warnedManual:!1};return e[g]=t,t}function A(){let e=document.currentScript;return!!e&&e.hasAttribute("data-kui-manual")}function d(e){typeof console<"u"&&typeof console.warn=="function"&&console.warn(`kuinetic: ${e}`)}function N(e,n){e.v===1||e.warnedVersion||(e.warnedVersion=!0,d(`the "${n}" bundle expects runtime v1 but found v${e.v} on this page \u2014 the bundles are from different releases. Serve them all from the same version.`))}function L(e,n,t){if(!t)return;let r=c();if(!(t in r))return;let o=n,a=n.kuinetic,i={};for(let u of Object.getOwnPropertyNames(o))i[u]=o[u];let s=u=>C(e,a,n,u);i.kuinetic=s,o.default===a&&(i.default=s);try{r[t]=i}catch{}}function C(e,n,t,r){if(!e.started){let i=n.call(t,r);return p(e,i),f(e,"yours is now the one this page uses, exactly as it would have been before the script tag started one, so the call is safe to delete"),i}let o=e.animator,a=!r||Object.entries(r).every(([i,s])=>i==="observe"&&s===!0);return o&&a?(f(e,"you have been handed the one it already made, so this call is safe to delete"),o):(f(e,"a second animator is now observing the same document, because this call arrived after the page was scanned and named its own root/registry/reporter"),n.call(t,r))}function f(e,n){e.warnedManual||(e.warnedManual=!0,d(`an animator was created by hand, and the script tag had already started one \u2014 ${n}. To turn the auto-start off entirely, put data-kui-manual on the <script> tag.`))}function p(e,n){let t=n.start.bind(n);n.start=()=>(e.started=!0,t()),e.animator=n,c().__kuinetic=n}function h(e,n){p(e,n.kuinetic({observe:!0}))}function S(e){if(document.readyState!=="loading"){m(e);return}e.scheduled||(e.scheduled=!0,document.addEventListener("DOMContentLoaded",()=>m(e),{once:!0}))}function E(e){for(let n of document.querySelectorAll("[data-kui]"))e.reset(n);e.scan()}function M(){let e=c().kuinetic;return e&&typeof e.kuinetic=="function"?e:null}function V(e){let n=e.pending.map(t=>`"${t.tier}"`).join(", ");n&&d(`the ${n} tier bundle loaded but core did not \u2014 add <script src=".../kuinetic.min.js"><\/script> to the page (in any order).`)}function $(e,n){let t=e.pending.splice(0,e.pending.length);for(let r of t)try{r.register(n)}catch(o){d(`the "${r.tier}" tier failed to register: ${String(o)}`)}return t.length}function m(e){if(e.manual)return;if(!e.animator){let r=M();r&&h(e,r)}let n=e.animator;if(!n){V(e);return}let t=$(e,n);if(e.booted=!0,!e.started){n.start();return}t&&E(n)}function T(e,n){return A()?(n.core&&(e.manual=!0),!0):e.manual}function x(e,n){if(n.core){if(e.animator)return;h(e,n.core),L(e,n.core,n.globalName);return}n.register&&e.pending.push({tier:n.tier,register:n.register})}function B(e){if(typeof document>"u"||typeof globalThis>"u")return;let n=O();N(n,e.tier),!T(n,e)&&(x(n,e),S(n))}return y(I);})();
|
|
747
|
+
|
|
748
|
+
__kuineticBoot.boot({ tier: 'advanced', register: kuineticAdvanced.registerAdvanced });
|
|
749
|
+
})();
|