kuinetic 0.2.0 → 0.2.2
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 +13 -6
- package/dist/esm/advanced/index.mjs +5 -5
- package/dist/esm/{chunk-RVTYN6NZ.mjs → chunk-BBQ22D7A.mjs} +7 -1
- package/dist/esm/{chunk-U43BX5O2.mjs → chunk-K2M7O6W5.mjs} +22 -6
- package/dist/esm/{chunk-MQSNMYRP.mjs → chunk-XDDJVANU.mjs} +89 -24
- package/dist/esm/core/index.mjs +2 -2
- package/dist/esm/effects/index.mjs +2 -2
- package/dist/esm/index.mjs +3 -3
- package/dist/kuinetic.advanced.js +63 -25
- package/dist/kuinetic.advanced.min.js +3 -3
- package/dist/kuinetic.all.js +175 -50
- package/dist/kuinetic.all.min.js +2 -2
- package/dist/kuinetic.css +1 -1
- package/dist/kuinetic.js +174 -49
- package/dist/kuinetic.min.css +1 -1
- package/dist/kuinetic.min.js +2 -2
- package/dist/types/advanced/camera-3d.d.ts +0 -4
- package/dist/types/advanced/fluid-cursor.d.ts +0 -4
- package/dist/types/advanced/particles.d.ts +0 -4
- package/dist/types/advanced/scenes.d.ts +0 -4
- package/dist/types/browser/boot.d.ts +9 -4
- package/dist/types/core/activation.d.ts +11 -0
- package/dist/types/core/compile.d.ts +7 -0
- package/dist/types/core/derived/types.d.ts +0 -1
- package/dist/types/core/gesture.d.ts +6 -1
- package/dist/types/core/stagger.d.ts +1 -1
- package/package.json +9 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var kuineticAdvanced=(()=>{var K=Object.defineProperty;var
|
|
1
|
+
"use strict";var kuineticAdvanced=(()=>{var K=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Gt=Object.prototype.hasOwnProperty;var Wt=(e,t)=>{for(var n in t)K(e,n,{get:t[n],enumerable:!0})},Ot=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ft(t))!Gt.call(e,i)&&i!==n&&K(e,i,{get:()=>t[i],enumerable:!(r=It(t,i))||r.enumerable});return e};var Dt=e=>Ot(K({},"__esModule",{value:!0}),e);var Jr={};Wt(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
2
|
float audioGain() { return 1.0 + clamp(u_audio, 0.0, 1.0); }
|
|
3
3
|
`,k=`uniform vec4 u_maskBox;
|
|
4
4
|
uniform vec4 u_maskRx;
|
|
@@ -740,10 +740,10 @@ void main() {
|
|
|
740
740
|
}
|
|
741
741
|
fragColor = px;
|
|
742
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);})();
|
|
743
|
+
`;function Ut(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 Bt(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 Ht(e,t){let n={},r=new Map;return{join(i){let o=r.get(i);return o||(o=Bt(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=Ht("style",Ut),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 Nt(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&&Nt(t).test(n)}function qt(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)&&qt(e,i,t)&&r.push(i);return r}function A(e,t,n){return e+(t-e)*n}function zt(e,t){return e&&typeof e.requestAnimationFrame=="function"?e.requestAnimationFrame(t):null}function jt(e,t){return e&&typeof e.cancelAnimationFrame=="function"&&t!=null&&e.cancelAnimationFrame(t),null}function Vt(e,t){return typeof globalThis.setTimeout!="function"?null:globalThis.setTimeout(e,t)}function $t(e){typeof globalThis.clearTimeout=="function"&&e!=null&&globalThis.clearTimeout(e)}function Xt(e,t){return e?.win!==void 0?e.win:t.window!==void 0?t.window:typeof window<"u"?window:null}function Yt(e,t){return e?.doc!==void 0?e.doc:t.document!==void 0?t.document:typeof document<"u"?document:null}var Ye=new WeakMap,Kt=()=>null;function Zt(e,t,n){if(e?.createCanvas)return e.createCanvas;if(t.createCanvas)return t.createCanvas;if(!n)return Kt;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 Qt(e,t,n){return e?.raf?e.raf:t.raf?t.raf:r=>zt(n,r)}function Jt(e,t,n){return e?.caf?e.caf:t.caf?t.caf:r=>jt(n,r)}function en(e,t){return e?.setTimer&&e.clearTimer?[e.setTimer,e.clearTimer]:t.setTimer&&t.clearTimer?[t.setTimer,t.clearTimer]:[Vt,$t]}function h(e=null,t={}){let n=e,r=Xt(n,t),i=Yt(n,t),[o,s]=en(n,t);return{window:r,document:i,createCanvas:Zt(n,t,i),raf:Qt(n,t,r),caf:Jt(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 tn(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=tn(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 nn(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 rn(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]=nn(t);return r>n||i>n}function on(e){if(typeof e.getError=="function"){for(let t=0;t<8;t+=1)if(Number(e.getError())===0)return}}function sn(e){if(typeof e.getError!="function")return!1;let t=e.getError();return typeof t=="number"&&t!==0}function nt(e,t){if(rn(e,t))return null;let n=e.createTexture();if(!n)return null;on(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),sn(e)?(e.deleteTexture&&e.deleteTexture(n),null):n}catch{return e.deleteTexture&&e.deleteTexture(n),null}}var an=["--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 un(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 ln="audio, video";function cn(e,t){let r=t?.HTMLMediaElement??(typeof HTMLMediaElement<"u"?HTMLMediaElement:null);return r?e instanceof r:!1}function dn(e,t,n,r){if(cn(e,n))return e;let i=e.querySelector?.(t??ln);return i||t&&r?.querySelector?.(t)||null}function it(e){if(!(!e||typeof e.disconnect!="function"))try{e.disconnect()}catch{return}}function mn(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 hn(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 fn(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:hn(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 pn(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=dn(this.element,this.options.target||null,r,i);if(!o)return;let s=pn(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=fn(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=un(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?mn(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:[...an],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 vn(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 gn=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)$/i;function bn(e){let t=gn.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 yn(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 xn(e,t){try{let n=yn(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=vn(n.slice(1));if(s)return s}let r=bn(n);if(r)return r;let i=n.toLowerCase();if(i in lt)return lt[i];let o=xn(n,t);return o||[1,1,1,1]}var wn={deg:Math.PI/180,grad:Math.PI/200,rad:1,turn:Math.PI*2};function dt(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*wn[(t[2]??"deg").toLowerCase()]: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 yt(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 xt(e,t){return{left:e.left+t.left,top:e.top+t.top,right:e.right-t.right,bottom:e.bottom-t.bottom}}function wt(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=wt(t);return xt(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 mt(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+mt(a[0],r-o),l=e.top+mt(a[1]??"50%",i-s);return{left:u,top:l,right:u+o,bottom:l+s}}function ht(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[ht(r[0],t),ht(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=yt(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,xt(ce(o),wt(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 _t(e,t,n=!1,r){let i=e.getBoundingClientRect(),{height:o}=q(t);if(!Gn(i,o))return null;let s=t??null,a=yt(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 Lt(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:_t(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"]),Et=["displace","fluid","liquid","particles","morph","gradient","logo"],nr=[[["displace"],Ue],[["fluid"],Be],[["liquid"],He],[["particles"],Ne],[["morph"],qe],[["gradient","logo"],ze]],ft={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"?ft[e.text("mask","alpha")]??ft.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:dt(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:dt(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("progress",-1),scrubsFromScroll:e.text("scrub","off")==="scroll",audioBand:G(e.text("audio","off"))}}function pt(e){if(!e)return null;let t=parseFloat(e);return Number.isFinite(t)?d(t,0,1):null}function lr(e){let t=pt(e.style?.getPropertyValue?.("--kui-progress"));if(t!==null)return t;let n=e.ownerDocument?.defaultView,r=pt(n?.getComputedStyle?.(e).getPropertyValue("--kui-progress"));return r!==null?r:-1}var B=0;function U(e){try{e()}catch{return}}function vt(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 gt=1,Rt="--kui-shader-z";function cr(e,t){let n=e?.documentElement;return n?kt(n.style?.getPropertyValue?.(Rt))??dr(n,t)??gt:gt}function dr(e,t){return kt(t?.getComputedStyle?.(e)?.getPropertyValue?.(Rt))}function kt(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??St}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:(vt(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);vt(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,St={};function ue(e){let t=h(null,e),n=t.document??t.window??St,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 bt(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=bt(()=>r(e)?e:null,n),o=bt(()=>{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)&&Lt(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=_t(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(!Lt(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(!Et.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:[...Et],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 Tt=String.raw`-?(?:\d+(?:\.\d+)?|\.\d+)`,Cr=new RegExp(String.raw`\bfrom:(${Tt})`),Ar=new RegExp(String.raw`\bto:(${Tt})`),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[Ct(Cr,e,0),Ct(Ar,e,1)]}function Ct(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 At(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=At(n)||At(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),Pt=E?Hr(E[1]):0;c.addLayer(p,Pt)}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??Mt}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,Mt={};function Zr(e){let t=h(null,e),n=t.document??t.window??Mt,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 Dt(Jr);})();
|
|
744
744
|
|
|
745
745
|
;(function () {
|
|
746
|
-
"use strict";var __kuineticBoot=(()=>{var l=Object.defineProperty;var
|
|
746
|
+
"use strict";var __kuineticBoot=(()=>{var l=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var O=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},A=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of R(n))!y.call(e,o)&&o!==t&&l(e,o,{get:()=>n[o],enumerable:!(r=v(n,o))||r.enumerable});return e};var L=e=>A(l({},"__esModule",{value:!0}),e);var j={};O(j,{boot:()=>_});var m="__kuineticRuntime";function d(){return globalThis}function N(){let e=d(),n=e[m];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[m]=t,t}function C(){let e=document.currentScript;return!!e&&e.hasAttribute("data-kui-manual")}function c(e){typeof console<"u"&&typeof console.warn=="function"&&console.warn(`kuinetic: ${e}`)}function M(e,n){e.v===1||e.warnedVersion||(e.warnedVersion=!0,c(`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 k(e,n,t){if(!t)return;let r=d();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=>S(e,a,n,u);i.kuinetic=s,o.default===a&&(i.default=s);try{r[t]=i}catch{}}function S(e,n,t,r){let o=!r||Object.entries(r).every(([i,s])=>i==="observe"&&s===!0);if(e.manual){let i=n.call(t,r);return B(e,i),i}if(!e.started){let i=n.call(t,r);return g(e,i),o&&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 a=e.animator;return a&&o?(f(e,"you have been handed the one it already made, so this call is safe to delete"),a):(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,c(`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 g(e,n){let t=n.start.bind(n);n.start=()=>(e.started=!0,t()),e.animator=n,d().__kuinetic=n}function B(e,n){e.animator||g(e,n);let t={animator:n,started:!1},r=e.handBuilt??=[];r.push(t);let o=n.start.bind(n);if(n.start=()=>(t.started=!0,o()),typeof n.destroy=="function"){let a=n.destroy.bind(n);n.destroy=()=>{let i=r.indexOf(t);return i>=0&&r.splice(i,1),a()}}for(let a of e.pending)p(a,n)}function p(e,n){try{e.register(n)}catch(t){c(`the "${e.tier}" tier failed to register: ${String(t)}`)}}function E(e,n){e.pending.push(n);for(let{animator:t,started:r}of[...e.handBuilt??[]])p(n,t),r&&w(t)}function b(e,n){g(e,n.kuinetic({observe:!0}))}function T(e){if(document.readyState!=="loading"){h(e);return}e.scheduled||(e.scheduled=!0,document.addEventListener("DOMContentLoaded",()=>h(e),{once:!0}))}function w(e){for(let n of document.querySelectorAll("[data-kui]"))e.reset(n);e.scan()}function V(){let e=d().kuinetic;return e&&typeof e.kuinetic=="function"?e:null}function $(e){let n=e.pending.map(t=>`"${t.tier}"`).join(", ");n&&c(`the ${n} tier bundle loaded but core did not \u2014 add <script src=".../kuinetic.min.js"><\/script> to the page (in any order).`)}function x(e,n){let t=e.pending.splice(0,e.pending.length);for(let r of t)p(r,n);return t.length}function h(e){if(e.manual)return;if(!e.animator){let r=V();r&&b(e,r)}let n=e.animator;if(!n){$(e);return}let t=x(e,n);if(e.booted=!0,!e.started){n.start();return}t&&w(n)}function I(e,n){if(n.core){if(e.animator)return;b(e,n.core),k(e,n.core,n.globalName);return}n.register&&e.pending.push({tier:n.tier,register:n.register})}function _(e){if(typeof document>"u"||typeof globalThis>"u")return;let n=N();if(M(n,e.tier),C()){e.core&&(n.manual=!0,k(n,e.core,e.globalName));return}if(n.manual){e.register&&E(n,{tier:e.tier,register:e.register});return}I(n,e),T(n)}return L(j);})();
|
|
747
747
|
|
|
748
748
|
__kuineticBoot.boot({ tier: 'advanced', register: kuineticAdvanced.registerAdvanced });
|
|
749
749
|
})();
|