@votax572002/fluxfx 0.1.5 → 0.1.6

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/dist/react.cjs CHANGED
@@ -1,14 +1,14 @@
1
1
  'use client';
2
- "use strict";"use client";var gt=Object.create;var ne=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,Tt=Object.prototype.hasOwnProperty;var Mt=(s,e)=>{for(var t in e)ne(s,t,{get:e[t],enumerable:!0})},De=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of xt(e))!Tt.call(s,r)&&r!==t&&ne(s,r,{get:()=>e[r],enumerable:!(i=bt(e,r))||i.enumerable});return s};var Ct=(s,e,t)=>(t=s!=null?gt(yt(s)):{},De(e||!s||!s.__esModule?ne(t,"default",{value:s,enumerable:!0}):t,s)),wt=s=>De(ne({},"__esModule",{value:!0}),s);var si={};Mt(si,{Aetheria:()=>Zt,Aurora:()=>qt,BrushReveal:()=>ti,DepthCarousel:()=>ri,Fluid:()=>Kt,Ink:()=>Jt,LiquidMetal:()=>$t,Magnetic:()=>jt,Prism3D:()=>ei,Spotlight:()=>ii,TiltCard:()=>Yt,useFX:()=>H});module.exports=wt(si);var P=Ct(require("react"),1);var Pe=["normal","reduced-res","low-fps","survival"];var le=class{constructor(e){this.idx=0;this.count=0;this.lastSampleAt=0;this.samples=new Float32Array(e)}push(e,t){this.samples[this.idx]=e,this.idx=(this.idx+1)%this.samples.length,this.count<this.samples.length&&this.count++,this.lastSampleAt=t}reset(){this.idx=0,this.count=0,this.lastSampleAt=0}isReady(e,t){return this.count>=this.samples.length&&e-this.lastSampleAt<=t}compute(){if(this.count===0)return{avgMs:0,slowRatio:0};let e=0,t=0;for(let i=0;i<this.count;i++){let r=this.samples[i];e+=r,r>26&&t++}return{avgMs:e/this.count,slowRatio:t/this.count}}},ge=class{constructor(){this.mainChannel=new le(30);this.gpuChannel=new le(12);this.listeners=new Set;this.currentTier=0;this.lastEvalAt=0;this.lastTransitionAt=0;this.badChecks=0;this.goodChecks=0;this.lastAvgFrameMs=0;this.lastSlowRatio=0;this.survivalTimer=null}recordMainThread(e,t){e<=0||e>250||(this.mainChannel.push(e,t),this.maybeEvaluate(t))}recordGpuFrame(e,t,i){if(e<=0||e>250||t<=0)return;let r=e*(t/60);this.gpuChannel.push(r,i),this.maybeEvaluate(i)}resetMainThread(){this.mainChannel.reset()}resetAll(){this.mainChannel.reset(),this.gpuChannel.reset(),this.badChecks=0,this.goodChecks=0,this.lastAvgFrameMs=0,this.lastSlowRatio=0}onTierChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}get tier(){return this.currentTier}get label(){return Pe[this.currentTier]}getSnapshot(){return{tier:this.currentTier,label:Pe[this.currentTier],avgFrameMs:Math.round(this.lastAvgFrameMs*100)/100,slowFrameRatio:Math.round(this.lastSlowRatio*1e3)/1e3}}clearSurvivalProbe(){this.survivalTimer!==null&&(clearTimeout(this.survivalTimer),this.survivalTimer=null)}scheduleSurvivalProbe(){this.clearSurvivalProbe(),typeof setTimeout=="function"&&(this.survivalTimer=setTimeout(()=>{if(this.survivalTimer=null,this.currentTier===3){if(typeof document<"u"&&document.hidden){this.scheduleSurvivalProbe();return}this.mainChannel.reset(),this.gpuChannel.reset(),this.badChecks=0,this.goodChecks=0,this.setTier(2,performance.now())}},6e3))}maybeEvaluate(e){if(e-this.lastEvalAt<400)return;this.lastEvalAt=e;let t=this.mainChannel.isReady(e,1500),i=this.gpuChannel.isReady(e,2500);if(!t&&!i)return;let r=0,o=0;if(t){let n=this.mainChannel.compute();r=Math.max(r,n.avgMs),o=Math.max(o,n.slowRatio)}if(i){let n=this.gpuChannel.compute();r=Math.max(r,n.avgMs),o=Math.max(o,n.slowRatio)}if(this.lastAvgFrameMs=r,this.lastSlowRatio=o,r>22.5||o>=.35){this.badChecks++,this.goodChecks=0,this.badChecks>=2&&this.currentTier<3&&e-this.lastTransitionAt>=2e3&&(this.setTier(this.currentTier+1,e),this.badChecks=0);return}if(r<18.2&&o<.1){this.goodChecks++,this.badChecks=0,this.currentTier>0&&this.goodChecks>=3&&e-this.lastTransitionAt>=5e3&&(this.setTier(this.currentTier-1,e),this.goodChecks=0);return}this.badChecks=0,this.goodChecks=0}setTier(e,t){if(e===this.currentTier)return;let i=this.currentTier;this.currentTier=e,this.lastTransitionAt=t,e===3?this.scheduleSurvivalProbe():this.clearSurvivalProbe(),this.listeners.forEach(r=>r(e,i))}},W=new ge;var be=class{constructor(){this.listeners=new Set;this.visibilityListeners=new Set;this.rafId=null;this.startTime=0;this.lastTime=0;this.avgFrameTimeMs=0;this.isDocumentHidden=!1;this.handleVisibilityChange=()=>{this.isDocumentHidden=typeof document<"u"?document.hidden:!1,this.isDocumentHidden?(this.stopLoop(),W.resetAll()):this.listeners.size>0&&(this.lastTime=0,this.startLoop()),this.visibilityListeners.forEach(e=>{e(this.isDocumentHidden)})};this.tick=e=>{if(this.listeners.size===0||this.isDocumentHidden){this.stopLoop();return}this.startTime===0&&(this.startTime=e);let t=this.lastTime===0?16.67:e-this.lastTime,i=Math.min(t,100);this.lastTime=e,t>0&&t<500&&(this.avgFrameTimeMs=this.avgFrameTimeMs===0?t:this.avgFrameTimeMs*.9+t*.1),W.recordMainThread(t,e);let r=(e-this.startTime)*.001,o=i*.001;this.listeners.forEach(n=>{n(r,o,e)}),this.listeners.size>0&&!this.isDocumentHidden?this.rafId=window.requestAnimationFrame(this.tick):this.rafId=null};typeof document<"u"&&(this.isDocumentHidden=document.hidden,document.addEventListener("visibilitychange",this.handleVisibilityChange))}startLoop(){this.rafId!==null||typeof window>"u"||this.isDocumentHidden||(this.lastTime=0,this.rafId=window.requestAnimationFrame(this.tick))}stopLoop(){this.rafId!==null&&typeof window<"u"&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.lastTime=0,this.avgFrameTimeMs=0,W.resetMainThread()}onVisibilityChange(e){return this.visibilityListeners.add(e),()=>{this.visibilityListeners.delete(e)}}add(e){return this.listeners.add(e),this.listeners.size===1&&this.startLoop(),()=>this.remove(e)}remove(e){this.listeners.delete(e),this.listeners.size===0&&this.stopLoop()}get isHidden(){return this.isDocumentHidden}get activeCount(){return this.listeners.size}get isRunning(){return this.rafId!==null}get frameTimeMs(){return!this.isRunning||this.avgFrameTimeMs<=0?0:Math.round(this.avgFrameTimeMs*100)/100}get fps(){return!this.isRunning||this.avgFrameTimeMs<=0?0:Math.round(1e3/this.avgFrameTimeMs)}},N=new be;var k=class{static acquireVec2(e=0,t=0){let i=this.vec2Pool.pop()??new Float32Array(2);return i[0]=e,i[1]=t,i}static releaseVec2(e){this.vec2Pool.length<128&&this.vec2Pool.push(e)}static acquireVec3(e=0,t=0,i=0){let r=this.vec3Pool.pop()??new Float32Array(3);return r[0]=e,r[1]=t,r[2]=i,r}static releaseVec3(e){this.vec3Pool.length<128&&this.vec3Pool.push(e)}static acquireVec4(e=0,t=0,i=0,r=1){let o=this.vec4Pool.pop()??new Float32Array(4);return o[0]=e,o[1]=t,o[2]=i,o[3]=r,o}static releaseVec4(e){this.vec4Pool.length<128&&this.vec4Pool.push(e)}static hexToVec3Into(e,t){let i=e.charCodeAt(0)===35?e.slice(1):e;if(i.length===3){let o=parseInt(i[0],16),n=parseInt(i[1],16),l=parseInt(i[2],16);return t[0]=(o<<4|o)/255,t[1]=(n<<4|n)/255,t[2]=(l<<4|l)/255,t}let r=parseInt(i,16);return Number.isNaN(r)?(t[0]=1,t[1]=1,t[2]=1,t):(t[0]=(r>>16&255)/255,t[1]=(r>>8&255)/255,t[2]=(r&255)/255,t)}};k.vec2Pool=[],k.vec3Pool=[],k.vec4Pool=[],k.scratchVec2=new Float32Array(2),k.scratchVec3=new Float32Array(3),k.scratchVec4=new Float32Array(4);var ce=class{constructor(e){this.samples=new Float32Array(30);this.sampleIdx=0;this.sampleCount=0;this.stableUpWindows=0;this.lastAdjustAt=0;this.minScale=Math.max(.5,e.minScale),this.maxScale=Math.max(this.minScale,e.maxScale),this.currentScale=this.maxScale,this.downThresholdMs=e.downThresholdMs??20.5,this.upThresholdMs=e.upThresholdMs??17.2,this.cooldownMs=e.cooldownMs??750}get scale(){return this.currentScale}setBounds(e,t){let i=Math.max(.5,e),r=Math.max(i,t),o=this.currentScale;return this.minScale=i,this.maxScale=r,this.currentScale=Math.min(r,Math.max(i,this.currentScale)),r>o&&(this.currentScale=r),this.sampleCount=0,this.sampleIdx=0,this.stableUpWindows=0,Math.abs(this.currentScale-o)>.01}recordFrame(e,t){if(this.minScale>=this.maxScale||e<=0||e>60)return!1;if(this.samples[this.sampleIdx]=e,this.sampleIdx=(this.sampleIdx+1)%this.samples.length,this.sampleCount<this.samples.length)return this.sampleCount++,!1;if(t-this.lastAdjustAt<this.cooldownMs)return!1;let i=0;for(let o=0;o<this.samples.length;o++)i+=this.samples[o];let r=i/this.samples.length;if(r>this.downThresholdMs&&this.currentScale>this.minScale)return this.currentScale=Math.max(this.minScale,Number((this.currentScale-.15).toFixed(2))),this.stableUpWindows=0,this.lastAdjustAt=t,!0;if(r<this.upThresholdMs&&this.currentScale<this.maxScale){if(this.stableUpWindows++,this.stableUpWindows>=2)return this.currentScale=Math.min(this.maxScale,Number((this.currentScale+.1).toFixed(2))),this.stableUpWindows=0,this.lastAdjustAt=t,!0}else this.stableUpWindows=0;return!1}};var te=null;function D(s,e="#ffffff"){if(typeof s!="string")return e;let t=s.trim();if(!t)return e;if(typeof document<"u"){if(!te){let i=document.createElement("canvas");i.width=1,i.height=1,te=i.getContext("2d")}if(te){te.fillStyle="#010203",te.fillStyle=t;let i=te.fillStyle;if(/^#[0-9a-f]{6}$/i.test(i))return i;let r=i.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(r)return"#"+[Number(r[1]),Number(r[2]),Number(r[3])].map(o=>Math.max(0,Math.min(255,o)).toString(16).padStart(2,"0")).join("")}}return e}function Ae(s){let e=s.trim().toLowerCase();if(!e||e==="transparent"||e==="none")return null;let t=e.match(/^rgba?\(\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*[,\s]\s*([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/);if(t){let r=Math.max(0,Math.min(255,parseFloat(t[1])))/255,o=Math.max(0,Math.min(255,parseFloat(t[2])))/255,n=Math.max(0,Math.min(255,parseFloat(t[3])))/255,l=1;return t[4]!==void 0&&(l=t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4])),[r,o,n,Math.max(0,Math.min(1,l))]}let i=e.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(i){let r=i[1],o=r.length===3?r.split("").map(n=>n+n).join(""):r;return[parseInt(o.slice(0,2),16)/255,parseInt(o.slice(2,4),16)/255,parseInt(o.slice(4,6),16)/255,1]}return null}function Be(s,e,t){let i=r=>r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4);return .2126*i(s)+.7152*i(e)+.0722*i(t)}function Ue(s){if(typeof document>"u"||typeof window>"u")return!0;let e=s;for(;e;){let n=(e.getAttribute("data-theme")||e.getAttribute("data-mode")||e.getAttribute("data-bs-theme")||"").trim().toLowerCase();if(n==="dark")return!0;if(n==="light")return!1;if(e.classList.contains("dark")||e.classList.contains("dark-mode"))return!0;if(e.classList.contains("light")||e.classList.contains("light-mode"))return!1;e=e.parentElement}let t=document.documentElement,i=document.body,r=(t?.getAttribute("data-theme")||t?.getAttribute("data-mode")||t?.getAttribute("data-bs-theme")||"").trim().toLowerCase();if(r==="dark")return!0;if(r==="light")return!1;if(t?.classList.contains("dark")||i?.classList.contains("dark"))return!0;if(t?.classList.contains("light")||i?.classList.contains("light"))return!1;let o=s;for(;o;){let n=window.getComputedStyle(o).backgroundColor,l=Ae(n);if(l&&l[3]>.12)return Be(l[0],l[1],l[2])<.42;o=o.parentElement}return typeof window.matchMedia=="function"?window.matchMedia("(prefers-color-scheme: dark)").matches:!0}function xe(s,e,t){let i=Math.max(s,e,t),r=Math.min(s,e,t),o=(i+r)*.5;if(i===r)return[0,0,o];let n=i-r,l=o>.5?n/(2-i-r):n/(i+r),a=0;return i===s?a=((e-t)/n+(e<t?6:0))/6:i===e?a=((t-s)/n+2)/6:a=((s-e)/n+4)/6,[a,l,o]}function Ie(s,e,t){if(e===0)return[t,t,t];let i=(n,l,a)=>{let c=a;return c<0&&(c+=1),c>1&&(c-=1),c<1/6?n+(l-n)*6*c:c<1/2?l:c<2/3?n+(l-n)*(2/3-c)*6:n},r=t<.5?t*(1+e):t+e-t*e,o=2*t-r;return[i(o,r,s+1/3),i(o,r,s),i(o,r,s-1/3)]}function ue(s,e){return s.map(([t,i,r])=>{let[o,n,l]=xe(t,i,r);if(e)return[t,i,r];let a=Math.min(n,.72)*.92,c=Math.max(.36,Math.min(.6,l*.78+.14));return Ie(o,a,c)})}function Oe(s,e){if(typeof window>"u"||!s)return null;let t=s;for(;t;){if(t.getAttribute("data-fluxfx-canvas")!=="true"){let i=window.getComputedStyle(t).backgroundColor,r=Ae(i);if(r&&r[3]>.14)return r}if(t===e)break;t=t.parentElement}return null}function _e(s,e){let[t,i,r]=xe(e[0],e[1],e[2]),o=Be(e[0],e[1],e[2]);if(i<.2)return ue(s,o<.42);let n=o<.38;return s.map(([l,a,c],u)=>{let[d,f,h]=xe(l,a,c),m=Math.abs(d-t),v=Math.min(m,1-m),g=d;if(v<.22){let T=[.46,.56,.34];g=(t+T[u%T.length])%1}let b=Math.max(.55,Math.min(.92,f<.35?.72:f)),x=n?Math.max(.68,Math.min(.86,h*.45+.48)):Math.max(.24,Math.min(.44,h*.5+.12)),y=Math.abs(x-r)<.22?n?Math.min(.88,r+.34):Math.max(.2,r-.34):x;return Ie(g,b,y)})}var oe=`#version 300 es
2
+ "use strict";"use client";var fr=Object.create;var rt=Object.defineProperty;var mr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var pr=Object.getPrototypeOf,vr=Object.prototype.hasOwnProperty;var gr=(r,e)=>{for(var t in e)rt(r,t,{get:e[t],enumerable:!0})},St=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of hr(e))!vr.call(r,i)&&i!==t&&rt(r,i,{get:()=>e[i],enumerable:!(o=mr(e,i))||o.enumerable});return r};var br=(r,e,t)=>(t=r!=null?fr(pr(r)):{},St(e||!r||!r.__esModule?rt(t,"default",{value:r,enumerable:!0}):t,r)),xr=r=>St(rt({},"__esModule",{value:!0}),r);var ui={};gr(ui,{Aetheria:()=>ri,Aurora:()=>Kr,BrushReveal:()=>oi,CardStack:()=>ci,DepthCarousel:()=>ni,Fluid:()=>Jr,Ink:()=>ti,LiquidMetal:()=>jr,Magnetic:()=>ei,MotionScrub:()=>ai,Prism3D:()=>ii,ScrollPath:()=>li,Spotlight:()=>si,TiltCard:()=>Zr,useFX:()=>ce});module.exports=xr(ui);var X=br(require("react"),1);var Et=["normal","reduced-res","low-fps","survival"];var it=class{constructor(e){this.idx=0;this.count=0;this.lastSampleAt=0;this.samples=new Float32Array(e)}push(e,t){this.samples[this.idx]=e,this.idx=(this.idx+1)%this.samples.length,this.count<this.samples.length&&this.count++,this.lastSampleAt=t}reset(){this.idx=0,this.count=0,this.lastSampleAt=0}isReady(e,t){return this.count>=this.samples.length&&e-this.lastSampleAt<=t}compute(){if(this.count===0)return{avgMs:0,slowRatio:0};let e=0,t=0;for(let o=0;o<this.count;o++){let i=this.samples[o];e+=i,i>26&&t++}return{avgMs:e/this.count,slowRatio:t/this.count}}},ft=class{constructor(){this.mainChannel=new it(30);this.gpuChannel=new it(12);this.listeners=new Set;this.currentTier=0;this.lastEvalAt=0;this.lastTransitionAt=0;this.badChecks=0;this.goodChecks=0;this.lastAvgFrameMs=0;this.lastSlowRatio=0;this.survivalTimer=null}recordMainThread(e,t){e<=0||e>250||(this.mainChannel.push(e,t),this.maybeEvaluate(t))}recordGpuFrame(e,t,o){if(e<=0||e>250||t<=0)return;let i=e*(t/60);this.gpuChannel.push(i,o),this.maybeEvaluate(o)}resetMainThread(){this.mainChannel.reset()}resetAll(){this.mainChannel.reset(),this.gpuChannel.reset(),this.badChecks=0,this.goodChecks=0,this.lastAvgFrameMs=0,this.lastSlowRatio=0}onTierChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}get tier(){return this.currentTier}get label(){return Et[this.currentTier]}getSnapshot(){return{tier:this.currentTier,label:Et[this.currentTier],avgFrameMs:Math.round(this.lastAvgFrameMs*100)/100,slowFrameRatio:Math.round(this.lastSlowRatio*1e3)/1e3}}clearSurvivalProbe(){this.survivalTimer!==null&&(clearTimeout(this.survivalTimer),this.survivalTimer=null)}scheduleSurvivalProbe(){this.clearSurvivalProbe(),typeof setTimeout=="function"&&(this.survivalTimer=setTimeout(()=>{if(this.survivalTimer=null,this.currentTier===3){if(typeof document<"u"&&document.hidden){this.scheduleSurvivalProbe();return}this.mainChannel.reset(),this.gpuChannel.reset(),this.badChecks=0,this.goodChecks=0,this.setTier(2,performance.now())}},6e3))}maybeEvaluate(e){if(e-this.lastEvalAt<400)return;this.lastEvalAt=e;let t=this.mainChannel.isReady(e,1500),o=this.gpuChannel.isReady(e,2500);if(!t&&!o)return;let i=0,s=0;if(t){let n=this.mainChannel.compute();i=Math.max(i,n.avgMs),s=Math.max(s,n.slowRatio)}if(o){let n=this.gpuChannel.compute();i=Math.max(i,n.avgMs),s=Math.max(s,n.slowRatio)}if(this.lastAvgFrameMs=i,this.lastSlowRatio=s,i>22.5||s>=.35){this.badChecks++,this.goodChecks=0,this.badChecks>=2&&this.currentTier<3&&e-this.lastTransitionAt>=2e3&&(this.setTier(this.currentTier+1,e),this.badChecks=0);return}if(i<18.2&&s<.1){this.goodChecks++,this.badChecks=0,this.currentTier>0&&this.goodChecks>=3&&e-this.lastTransitionAt>=5e3&&(this.setTier(this.currentTier-1,e),this.goodChecks=0);return}this.badChecks=0,this.goodChecks=0}setTier(e,t){if(e===this.currentTier)return;let o=this.currentTier;this.currentTier=e,this.lastTransitionAt=t,e===3?this.scheduleSurvivalProbe():this.clearSurvivalProbe(),this.listeners.forEach(i=>i(e,o))}},Te=new ft;var mt=class{constructor(){this.listeners=new Set;this.visibilityListeners=new Set;this.rafId=null;this.startTime=0;this.lastTime=0;this.avgFrameTimeMs=0;this.isDocumentHidden=!1;this.handleVisibilityChange=()=>{this.isDocumentHidden=typeof document<"u"?document.hidden:!1,this.isDocumentHidden?(this.stopLoop(),Te.resetAll()):this.listeners.size>0&&(this.lastTime=0,this.startLoop()),this.visibilityListeners.forEach(e=>{e(this.isDocumentHidden)})};this.tick=e=>{if(this.listeners.size===0||this.isDocumentHidden){this.stopLoop();return}this.startTime===0&&(this.startTime=e);let t=this.lastTime===0?16.67:e-this.lastTime,o=Math.min(t,100);this.lastTime=e,t>0&&t<500&&(this.avgFrameTimeMs=this.avgFrameTimeMs===0?t:this.avgFrameTimeMs*.9+t*.1),Te.recordMainThread(t,e);let i=(e-this.startTime)*.001,s=o*.001;this.listeners.forEach(n=>{n(i,s,e)}),this.listeners.size>0&&!this.isDocumentHidden?this.rafId=window.requestAnimationFrame(this.tick):this.rafId=null};typeof document<"u"&&(this.isDocumentHidden=document.hidden,document.addEventListener("visibilitychange",this.handleVisibilityChange))}startLoop(){this.rafId!==null||typeof window>"u"||this.isDocumentHidden||(this.lastTime=0,this.rafId=window.requestAnimationFrame(this.tick))}stopLoop(){this.rafId!==null&&typeof window<"u"&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.lastTime=0,this.avgFrameTimeMs=0,Te.resetMainThread()}onVisibilityChange(e){return this.visibilityListeners.add(e),()=>{this.visibilityListeners.delete(e)}}add(e){return this.listeners.add(e),this.listeners.size===1&&this.startLoop(),()=>this.remove(e)}remove(e){this.listeners.delete(e),this.listeners.size===0&&this.stopLoop()}get isHidden(){return this.isDocumentHidden}get activeCount(){return this.listeners.size}get isRunning(){return this.rafId!==null}get frameTimeMs(){return!this.isRunning||this.avgFrameTimeMs<=0?0:Math.round(this.avgFrameTimeMs*100)/100}get fps(){return!this.isRunning||this.avgFrameTimeMs<=0?0:Math.round(1e3/this.avgFrameTimeMs)}},Se=new mt;var J=class{static acquireVec2(e=0,t=0){let o=this.vec2Pool.pop()??new Float32Array(2);return o[0]=e,o[1]=t,o}static releaseVec2(e){this.vec2Pool.length<128&&this.vec2Pool.push(e)}static acquireVec3(e=0,t=0,o=0){let i=this.vec3Pool.pop()??new Float32Array(3);return i[0]=e,i[1]=t,i[2]=o,i}static releaseVec3(e){this.vec3Pool.length<128&&this.vec3Pool.push(e)}static acquireVec4(e=0,t=0,o=0,i=1){let s=this.vec4Pool.pop()??new Float32Array(4);return s[0]=e,s[1]=t,s[2]=o,s[3]=i,s}static releaseVec4(e){this.vec4Pool.length<128&&this.vec4Pool.push(e)}static hexToVec3Into(e,t){let o=e.charCodeAt(0)===35?e.slice(1):e;if(o.length===3){let s=parseInt(o[0],16),n=parseInt(o[1],16),l=parseInt(o[2],16);return t[0]=(s<<4|s)/255,t[1]=(n<<4|n)/255,t[2]=(l<<4|l)/255,t}let i=parseInt(o,16);return Number.isNaN(i)?(t[0]=1,t[1]=1,t[2]=1,t):(t[0]=(i>>16&255)/255,t[1]=(i>>8&255)/255,t[2]=(i&255)/255,t)}};J.vec2Pool=[],J.vec3Pool=[],J.vec4Pool=[],J.scratchVec2=new Float32Array(2),J.scratchVec3=new Float32Array(3),J.scratchVec4=new Float32Array(4);var ot=class{constructor(e){this.samples=new Float32Array(30);this.sampleIdx=0;this.sampleCount=0;this.stableUpWindows=0;this.lastAdjustAt=0;this.minScale=Math.max(.5,e.minScale),this.maxScale=Math.max(this.minScale,e.maxScale),this.currentScale=this.maxScale,this.downThresholdMs=e.downThresholdMs??20.5,this.upThresholdMs=e.upThresholdMs??17.2,this.cooldownMs=e.cooldownMs??750}get scale(){return this.currentScale}setBounds(e,t){let o=Math.max(.5,e),i=Math.max(o,t),s=this.currentScale;return this.minScale=o,this.maxScale=i,this.currentScale=Math.min(i,Math.max(o,this.currentScale)),i>s&&(this.currentScale=i),this.sampleCount=0,this.sampleIdx=0,this.stableUpWindows=0,Math.abs(this.currentScale-s)>.01}recordFrame(e,t){if(this.minScale>=this.maxScale||e<=0||e>60)return!1;if(this.samples[this.sampleIdx]=e,this.sampleIdx=(this.sampleIdx+1)%this.samples.length,this.sampleCount<this.samples.length)return this.sampleCount++,!1;if(t-this.lastAdjustAt<this.cooldownMs)return!1;let o=0;for(let s=0;s<this.samples.length;s++)o+=this.samples[s];let i=o/this.samples.length;if(i>this.downThresholdMs&&this.currentScale>this.minScale)return this.currentScale=Math.max(this.minScale,Number((this.currentScale-.15).toFixed(2))),this.stableUpWindows=0,this.lastAdjustAt=t,!0;if(i<this.upThresholdMs&&this.currentScale<this.maxScale){if(this.stableUpWindows++,this.stableUpWindows>=2)return this.currentScale=Math.min(this.maxScale,Number((this.currentScale+.1).toFixed(2))),this.stableUpWindows=0,this.lastAdjustAt=t,!0}else this.stableUpWindows=0;return!1}};var Ge=null;function te(r,e="#ffffff"){if(typeof r!="string")return e;let t=r.trim();if(!t)return e;if(typeof document<"u"){if(!Ge){let o=document.createElement("canvas");o.width=1,o.height=1,Ge=o.getContext("2d")}if(Ge){Ge.fillStyle="#010203",Ge.fillStyle=t;let o=Ge.fillStyle;if(/^#[0-9a-f]{6}$/i.test(o))return o;let i=o.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i)return"#"+[Number(i[1]),Number(i[2]),Number(i[3])].map(s=>Math.max(0,Math.min(255,s)).toString(16).padStart(2,"0")).join("")}}return e}function Rt(r){let e=r.trim().toLowerCase();if(!e||e==="transparent"||e==="none")return null;let t=e.match(/^rgba?\(\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*[,\s]\s*([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/);if(t){let i=Math.max(0,Math.min(255,parseFloat(t[1])))/255,s=Math.max(0,Math.min(255,parseFloat(t[2])))/255,n=Math.max(0,Math.min(255,parseFloat(t[3])))/255,l=1;return t[4]!==void 0&&(l=t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4])),[i,s,n,Math.max(0,Math.min(1,l))]}let o=e.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){let i=o[1],s=i.length===3?i.split("").map(n=>n+n).join(""):i;return[parseInt(s.slice(0,2),16)/255,parseInt(s.slice(2,4),16)/255,parseInt(s.slice(4,6),16)/255,1]}return null}function Lt(r,e,t){let o=i=>i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4);return .2126*o(r)+.7152*o(e)+.0722*o(t)}function kt(r){if(typeof document>"u"||typeof window>"u")return!0;let e=r;for(;e;){let n=(e.getAttribute("data-theme")||e.getAttribute("data-mode")||e.getAttribute("data-bs-theme")||"").trim().toLowerCase();if(n==="dark")return!0;if(n==="light")return!1;if(e.classList.contains("dark")||e.classList.contains("dark-mode"))return!0;if(e.classList.contains("light")||e.classList.contains("light-mode"))return!1;e=e.parentElement}let t=document.documentElement,o=document.body,i=(t?.getAttribute("data-theme")||t?.getAttribute("data-mode")||t?.getAttribute("data-bs-theme")||"").trim().toLowerCase();if(i==="dark")return!0;if(i==="light")return!1;if(t?.classList.contains("dark")||o?.classList.contains("dark"))return!0;if(t?.classList.contains("light")||o?.classList.contains("light"))return!1;let s=r;for(;s;){let n=window.getComputedStyle(s).backgroundColor,l=Rt(n);if(l&&l[3]>.12)return Lt(l[0],l[1],l[2])<.42;s=s.parentElement}return typeof window.matchMedia=="function"?window.matchMedia("(prefers-color-scheme: dark)").matches:!0}function ht(r,e,t){let o=Math.max(r,e,t),i=Math.min(r,e,t),s=(o+i)*.5;if(o===i)return[0,0,s];let n=o-i,l=s>.5?n/(2-o-i):n/(o+i),a=0;return o===r?a=((e-t)/n+(e<t?6:0))/6:o===e?a=((t-r)/n+2)/6:a=((r-e)/n+4)/6,[a,l,s]}function Ft(r,e,t){if(e===0)return[t,t,t];let o=(n,l,a)=>{let u=a;return u<0&&(u+=1),u>1&&(u-=1),u<1/6?n+(l-n)*6*u:u<1/2?l:u<2/3?n+(l-n)*(2/3-u)*6:n},i=t<.5?t*(1+e):t+e-t*e,s=2*t-i;return[o(s,i,r+1/3),o(s,i,r),o(s,i,r-1/3)]}function st(r,e){return r.map(([t,o,i])=>{let[s,n,l]=ht(t,o,i);if(e)return[t,o,i];let a=Math.min(n,.72)*.92,u=Math.max(.36,Math.min(.6,l*.78+.14));return Ft(s,a,u)})}function Pt(r,e){if(typeof window>"u"||!r)return null;let t=r;for(;t;){if(t.getAttribute("data-fluxfx-canvas")!=="true"){let o=window.getComputedStyle(t).backgroundColor,i=Rt(o);if(i&&i[3]>.14)return i}if(t===e)break;t=t.parentElement}return null}function Dt(r,e){let[t,o,i]=ht(e[0],e[1],e[2]),s=Lt(e[0],e[1],e[2]);if(o<.2)return st(r,s<.42);let n=s<.38;return r.map(([l,a,u],c)=>{let[f,m,p]=ht(l,a,u),h=Math.abs(f-t),v=Math.min(h,1-h),g=f;if(v<.22){let S=[.46,.56,.34];g=(t+S[c%S.length])%1}let x=Math.max(.55,Math.min(.92,m<.35?.72:m)),y=n?Math.max(.68,Math.min(.86,p*.45+.48)):Math.max(.24,Math.min(.44,p*.5+.12)),M=Math.abs(y-i)<.22?n?Math.min(.88,i+.34):Math.max(.2,i-.34):y;return Ft(g,x,M)})}var Je=`#version 300 es
3
3
  precision highp float;
4
4
  layout(location = 0) in vec2 aPosition;
5
5
  out vec2 vUv;
6
6
  void main() {
7
7
  vUv = aPosition * 0.5 + 0.5;
8
8
  gl_Position = vec4(aPosition, 0.0, 1.0);
9
- }`,F=class{static hashSource(e,t){let i=e+"|"+t,r=2166136261;for(let o=0;o<i.length;o++)r^=i.charCodeAt(o),r=Math.imul(r,16777619);return(r>>>0).toString(36)}static compileShader(e,t,i){let r=e.createShader(t);if(!r)throw new Error("[FluxFX] Failed to create WebGLShader");if(e.shaderSource(r,i),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let o=e.getShaderInfoLog(r);throw e.deleteShader(r),new Error(`[FluxFX] Shader compile error:
10
- ${o}`)}return r}static getOrCreateProgram(e,t,i=oe){let r=this.contextCache.get(e);r||(r=new Map,this.contextCache.set(e,r));let o=this.hashSource(i,t),n=r.get(o);if(n)return n;e.getExtension("KHR_parallel_shader_compile");let l=this.compileShader(e,e.VERTEX_SHADER,i),a=this.compileShader(e,e.FRAGMENT_SHADER,t),c=e.createProgram();if(!c)throw e.deleteShader(l),e.deleteShader(a),new Error("[FluxFX] Failed to create WebGLProgram");if(e.attachShader(c,l),e.attachShader(c,a),e.linkProgram(c),e.deleteShader(l),e.deleteShader(a),!e.getProgramParameter(c,e.LINK_STATUS)){let d=e.getProgramInfoLog(c);throw e.deleteProgram(c),new Error(`[FluxFX] Program link error:
11
- ${d}`)}let u={program:c,uniforms:new Map};return r.set(o,u),u}static getUniformLocation(e,t,i){if(t.uniforms.has(i))return t.uniforms.get(i)??null;let r=e.getUniformLocation(t.program,i);return t.uniforms.set(i,r),r}static precompile(e,t){for(let i=0;i<t.length;i++)this.getOrCreateProgram(e,t[i])}static disposeContext(e){let t=this.contextCache.get(e);t&&(t.forEach(i=>e.deleteProgram(i.program)),t.clear(),this.contextCache.delete(e))}};F.contextCache=new WeakMap;var Rt=`
9
+ }`,j=class{static hashSource(e,t){let o=e+"|"+t,i=2166136261;for(let s=0;s<o.length;s++)i^=o.charCodeAt(s),i=Math.imul(i,16777619);return(i>>>0).toString(36)}static compileShader(e,t,o){let i=e.createShader(t);if(!i)throw new Error("[FluxFX] Failed to create WebGLShader");if(e.shaderSource(i,o),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS)){let s=e.getShaderInfoLog(i);throw e.deleteShader(i),new Error(`[FluxFX] Shader compile error:
10
+ ${s}`)}return i}static getOrCreateProgram(e,t,o=Je){let i=this.contextCache.get(e);i||(i=new Map,this.contextCache.set(e,i));let s=this.hashSource(o,t),n=i.get(s);if(n)return n;e.getExtension("KHR_parallel_shader_compile");let l=this.compileShader(e,e.VERTEX_SHADER,o),a=this.compileShader(e,e.FRAGMENT_SHADER,t),u=e.createProgram();if(!u)throw e.deleteShader(l),e.deleteShader(a),new Error("[FluxFX] Failed to create WebGLProgram");if(e.attachShader(u,l),e.attachShader(u,a),e.linkProgram(u),e.deleteShader(l),e.deleteShader(a),!e.getProgramParameter(u,e.LINK_STATUS)){let f=e.getProgramInfoLog(u);throw e.deleteProgram(u),new Error(`[FluxFX] Program link error:
11
+ ${f}`)}let c={program:u,uniforms:new Map};return i.set(s,c),c}static getUniformLocation(e,t,o){if(t.uniforms.has(o))return t.uniforms.get(o)??null;let i=e.getUniformLocation(t.program,o);return t.uniforms.set(o,i),i}static precompile(e,t){for(let o=0;o<t.length;o++)this.getOrCreateProgram(e,t[o])}static disposeContext(e){let t=this.contextCache.get(e);t&&(t.forEach(o=>e.deleteProgram(o.program)),t.clear(),this.contextCache.delete(e))}};j.contextCache=new WeakMap;var yr=`
12
12
  let gl = null;
13
13
  let canvas = null;
14
14
  let displayProgram = null;
@@ -856,7 +856,7 @@ self.onmessage = function(e) {
856
856
  break;
857
857
  }
858
858
  };
859
- `,ye=null;function Te(){if(typeof window>"u"||typeof Worker>"u"||typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"||!("transferControlToOffscreen"in HTMLCanvasElement.prototype))return!1;let s=typeof navigator<"u"?navigator.userAgent:"";return!(/iP(ad|hone|od)/i.test(s)||/^((?!chrome|android).)*safari/i.test(s))}function Ve(){if(!ye){let s=new Blob([Rt],{type:"application/javascript"});ye=URL.createObjectURL(s)}return new Worker(ye)}var He=oe;var ie={low:{max:1,min:.65,retinaMin:.85,fboMaxDim:512},medium:{max:2,min:.75,retinaMin:1,fboMaxDim:896},high:{max:2,min:1,retinaMin:1.25,fboMaxDim:1152}},Et=new Float32Array([-1,-1,3,-1,-1,3]),St=12;function Ge(){if(typeof navigator>"u")return!1;let s=navigator.userAgent||"";return/Safari/i.test(s)&&!/Chrome|Chromium|Edg|CriOS|FxiOS|OPR/i.test(s)}function We(){if(typeof navigator>"u")return 8;let s=navigator.userAgent||"",e=/Mobi|Android|iPhone|iPad|iPod/i.test(s);return Ge()||e?6:8}function ae(){return typeof performance<"u"?performance.now():Date.now()}var Me=30,Ce=60,re=1800;function de(s,e){return 1-Math.exp(-s*e)}var B=class B{constructor(e,t){this.resizeObserver=null;this.visibilityObserver=null;this.reducedMotionQuery=null;this.dprMediaQuery=null;this.worker=null;this.isOffscreen=!1;this.gl=null;this.programEntry=null;this.feedbackProgramEntry=null;this.vao=null;this.vbo=null;this.dynamicRes=null;this.lastRenderNow=0;this.lastDrawNow=0;this.lastTargetFps=0;this.prevFrameDrew=!1;this.avgDrawDeltaMs=0;this.boostUntil=0;this.reportedFps=0;this.reportedFrameTimeMs=0;this.elapsedSec=0;this.lastDeltaSec=.01667;this.currentSpeed=1;this.targetSpeed=1;this.needsResize=!1;this.pingPong=null;this.fboW=1;this.fboH=1;this.fboFormat=0;this.fboType=0;this.readIdx=0;this.writeIdx=1;this.customUniforms=new Map;this.textureUrls=new Map;this.textureUnits=new Map;this.loadedImages=new Map;this.mainTextures=new Map;this.textureLoadTokens=new Map;this.nextTextureUnit=1;this.mouse=k.acquireVec2(.5,.5);this.targetMouse=k.acquireVec2(.5,.5);this.mouseVel=k.acquireVec2(0,0);this.mouseDown=0;this.mouseActive=0;this.targetMouseActive=0;this.isPointerInside=!1;this.scroll=0;this.targetScroll=0;this.scrollVel=0;this.hasScrollListener=!1;this.width=1;this.height=1;this.isPaused=!1;this.isHiddenByViewport=!1;this.isContextLost=!1;this.isReducedMotion=!1;this.isDestroyed=!1;this.wakeCallback=null;this.ambientFps=Me;this.activeFps=Ce;this.protectionTier=W.tier;this.isSurvivalSuspended=!1;this.unsubscribeGuard=null;this.isBudgetSuspended=!1;this.lastActiveAt=ae();this.hasDocVisibilityListener=!1;this.hasPointerListener=!1;this.countedContext=!1;this.isBodyMount=!1;this.origBodyMinHeight="";this.themeMode="auto";this.resolvedDarkTheme=!0;this.currentTheme=1;this.themeTweenRaf=0;this.colorSchemeQuery=null;this.themeMutationObserver=null;this.basePaletteRgb=[];this.activePaletteRgb=[];this.scrollStopsRgb=[];this.lastScrollColorT=-1;this.hasScrollColorListener=!1;this.scrollColorRaf=0;this.hasTouchListener=!1;this.touchBurstTimer=0;this.touchLeaveTimer=0;this.layerMode="background";this.adaptToSurface=!1;this.rawBasePaletteRgb=[];this.lastSurfaceEl=null;this.lastSurfaceKey="";this.lastSurfaceCheckAt=0;this.isSurfaceAdapted=!1;this.handleThemeChange=()=>{if(this.isDestroyed)return;let e=this.detectDarkTheme(this.themeMode);e!==this.resolvedDarkTheme&&(this.resolvedDarkTheme=e,this.startThemeTransition(e))};this.handleScrollColorEvent=()=>{this.isDestroyed||this.scrollStopsRgb.length<2||this.scrollColorRaf||(this.scrollColorRaf=requestAnimationFrame(()=>{if(this.scrollColorRaf=0,this.isDestroyed||this.scrollStopsRgb.length<2)return;let e=this.computeScrollProgress();this.updateScrollColorShift(e)}))};this.handleTouchStart=e=>{if(!this.interactive||this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;let t=e.touches[0];if(!t)return;if(this.isShadowedByChildInteractive(t.target)){this.isPointerInside&&this.handlePointerLeave();return}let i=this.getLocalTouchCoords(t);if(!i)return;this.touchLeaveTimer&&(window.clearTimeout(this.touchLeaveTimer),this.touchLeaveTimer=0),this.touchBurstTimer&&(window.clearTimeout(this.touchBurstTimer),this.touchBurstTimer=0);let[r,o]=i;this.inspectSurfaceFromTarget(t.target,!0),this.isPointerInside=!0,this.targetMouseActive=1,this.mouseDown=1,this.boostInteraction(re),this.isOffscreen&&this.worker?(this.worker.postMessage({type:"mouseEnter",x:r,y:o}),this.worker.postMessage({type:"mouseDown",down:!0})):(this.mouse[0]=r,this.mouse[1]=o,this.targetMouse[0]=r,this.targetMouse[1]=o,this.mouseVel[0]=0,this.mouseVel[1]=0),this.touchBurstTimer=window.setTimeout(()=>{this.touchBurstTimer=0,!this.isDestroyed&&(this.mouseDown=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!1}))},160)};this.handleTouchMove=e=>{if(!this.interactive||this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;let t=e.touches[0];if(!t)return;if(this.isShadowedByChildInteractive(t.target)){this.isPointerInside&&this.handlePointerLeave();return}let i=this.getLocalTouchCoords(t);if(!i)return;let[r,o]=i;this.inspectSurfaceFromTarget(t.target),this.boostInteraction(re),this.targetMouseActive=1,this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouse",x:r,y:o}):(this.targetMouse[0]=r,this.targetMouse[1]=o)};this.handleTouchEnd=()=>{this.isDestroyed||(this.mouseDown=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!1}),this.touchLeaveTimer&&window.clearTimeout(this.touchLeaveTimer),this.touchLeaveTimer=window.setTimeout(()=>{this.touchLeaveTimer=0,this.isDestroyed||this.handlePointerLeave()},550))};this.handleContextLost=e=>{e.preventDefault(),this.isContextLost=!0,this.resetFrameTracking(),this.gl&&F.disposeContext(this.gl),this.programEntry=null,this.feedbackProgramEntry=null,this.pingPong=null,this.mainTextures.clear(),this.vao=null,this.vbo=null,this.wakeCallback?.()};this.handleContextRestored=()=>{if(!(this.isDestroyed||!this.gl))try{this.isContextLost=!1,this.initMainThreadPipeline(this.gl),this.reuploadLoadedTextures(),this.drawMainThreadFrame(),this.wakeCallback?.()}catch(e){console.error("[FluxFX] Failed to restore WebGL2 context:",e)}};this.handleProtectionTierChange=e=>{this.isDestroyed||this.protectionTier===e||(this.protectionTier=e,this.applyProtectionState(),this.isDestroyed||this.pushUniformBatch({uQuality:this.computeEffectiveQuality()}))};this.handleDprChange=()=>{this.isDestroyed||(this.syncDprBounds(),this.watchDevicePixelRatio())};this.handleReducedMotionChange=e=>{this.applyReducedMotionState(this.respectReducedMotion&&e.matches)};this.handlePointerEnter=e=>{if(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;if(this.isShadowedByChildInteractive(e.target)){this.isPointerInside&&this.handlePointerLeave();return}let t=this.getLocalPointerCoords(e);if(!t)return;let[i,r]=t;this.isPointerInside=!0,this.targetMouseActive=1,this.boostInteraction(re),this.protectionTier>=3&&this.applyProtectionState(),this.lastActiveAt=ae(),this.isBudgetSuspended&&!this.isPaused&&this.restoreContextFromBudget(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouseEnter",x:i,y:r}):(this.mouse[0]=i,this.mouse[1]=r,this.targetMouse[0]=i,this.targetMouse[1]=r,this.mouseVel[0]=0,this.mouseVel[1]=0)};this.handlePointerMove=e=>{if(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;if(this.isShadowedByChildInteractive(e.target)){this.isPointerInside&&this.handlePointerLeave();return}let t=this.getLocalPointerCoords(e);if(!t){this.isPointerInside&&this.handlePointerLeave();return}let[i,r]=t;if(!this.isPointerInside){this.handlePointerEnter(e),this.inspectSurfaceFromTarget(e.target,!0);return}this.inspectSurfaceFromTarget(e.target),this.boostInteraction(re),this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouse",x:i,y:r}):(this.targetMouse[0]=i,this.targetMouse[1]=r)};this.handlePointerLeave=()=>{!this.isPointerInside&&this.targetMouseActive===0||(this.isPointerInside=!1,this.targetMouseActive=0,this.lastSurfaceEl=null,this.lastSurfaceKey="",this.isSurfaceAdapted&&(this.isSurfaceAdapted=!1,this.startPaletteTween(this.basePaletteRgb,240)),this.mouseDown=0,this.mouseVel[0]=0,this.mouseVel[1]=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseLeave"}),this.protectionTier>=3&&this.applyProtectionState())};this.handlePointerDown=e=>{if(!(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)){if(this.isShadowedByChildInteractive(e.target)){this.isPointerInside&&this.handlePointerLeave();return}this.isPointerInside||this.handlePointerEnter(e),this.mouseDown=1,this.boostInteraction(re),this.protectionTier>=3&&this.applyProtectionState(),this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!0})}};this.handlePointerUp=()=>{this.mouseDown!==0&&(this.mouseDown=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!1}),this.protectionTier>=3&&this.applyProtectionState())};this.handleScroll=()=>{if(!this.trackScroll||this.isDestroyed)return;let e=this.computeScrollProgress();this.boostInteraction(1200),this.isOffscreen&&this.worker?this.worker.postMessage({type:"scroll",progress:e}):(this.targetScroll=e,this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport&&(this.scroll=e,this.scrollVel=0,this.drawMainThreadFrame()))};this.handleDocVisibility=()=>{!this.isOffscreen||!this.worker||(document.hidden?(this.resetFrameTracking(),this.worker.postMessage({type:"pause"})):!this.isPaused&&!this.isHiddenByViewport&&this.worker.postMessage({type:"resume"}))};this.container=e,this.options={...t},this.interactive=t.interactive??!0,this.respectReducedMotion=t.respectReducedMotion??!0,this.trackScroll=t.trackScroll??!1,this.feedbackScale=t.feedbackScale??.5,this.feedbackFloat=t.feedbackFloat??!0,B.instances.add(this);let i=t.quality??"medium",r=ie[i]??ie.medium;this.baseFeedbackMaxDim=t.feedbackMaxDim??r.fboMaxDim;let o=this.resolveTierConfig();this.ambientFps=o.ambientFps,this.activeFps=o.activeFps,this.feedbackMaxDim=o.feedbackMaxDim,this.isSurvivalSuspended=o.suspended,typeof window<"u"&&typeof window.matchMedia=="function"&&(this.reducedMotionQuery=window.matchMedia("(prefers-reduced-motion: reduce)"),this.isReducedMotion=this.respectReducedMotion&&this.reducedMotionQuery.matches),this.isBodyMount=typeof document<"u"&&this.container===document.body,window.getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.style.isolation="isolate",this.isBodyMount&&(this.origBodyMinHeight=this.container.style.minHeight,this.container.style.minHeight||(this.container.style.minHeight="100dvh")),this.canvas=document.createElement("canvas"),this.canvas.setAttribute("data-fluxfx-canvas","true"),this.canvas.style.position=this.isBodyMount?"fixed":"absolute",this.canvas.style.inset="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.zIndex="-1",this.canvas.style.pointerEvents="none",this.canvas.style.display="block",this.container.prepend(this.canvas),this.layerMode=t.layer??"background",this.adaptToSurface=t.adaptToSurface??!1,this.applyCanvasLayerStyle(),this.themeMode=t.theme??"auto",this.resolvedDarkTheme=this.detectDarkTheme(this.themeMode),this.currentTheme=this.resolvedDarkTheme?1:0;let l=this.container.getBoundingClientRect();if(this.width=Math.max(1,Math.floor(l.width)),this.height=Math.max(1,Math.floor(l.height)),this.trackScroll){let v=this.computeScrollProgress();this.scroll=v,this.targetScroll=v}let{minDpr:a,maxDpr:c}=this.resolveDprBounds(),u=t.dynamicResolution??!0,d=t.offscreen??!0;this.seedUniformsFromOptions(t,!0);let f=typeof window<"u"&&window.innerHeight||0,h=typeof window<"u"&&window.innerWidth||0,m=(t.pauseWhenHidden??!0)&&f>0&&(l.bottom<-50||l.top>f+50||l.right<-50||l.left>h+50);m&&(this.isHiddenByViewport=!0),B.ensureContextBudget(this,m)?d&&Te()?this.initOffscreenMode(t,a,c,u):this.initMainThreadMode(t,a,c,u):(this.isBudgetSuspended=!0,this.applyBudgetFallbackStyle()),this.bindObservers(t.pauseWhenHidden??!0),this.unsubscribeGuard=W.onTierChange(this.handleProtectionTierChange),this.syncTexturesFromOptions(t.textures)}static acquireRecycledMainContext(){for(;this.recycledMainContexts.length>0;){let e=this.recycledMainContexts.pop();if(!e.gl.isContextLost())return e}return null}static recycleMainContext(e,t){let i=Math.max(this._maxContexts,We());return this.recycledMainContexts.length>=i?!1:(this.recycledMainContexts.push({canvas:e,gl:t}),!0)}static get activeContexts(){return this._activeContexts}static get maxActiveContexts(){return this._maxContexts}static get suspendedContexts(){let e=0;return this.instances.forEach(t=>{!t.isDestroyed&&t.isBudgetSuspended&&e++}),e}static setMaxActiveContexts(e){let t=Math.max(1,Math.floor(e));t!==this._maxContexts&&(this._maxContexts=t,this.enforceContextBudget(),this.reclaimBudgetForWaiting())}static pickEvictionVictim(e,t){let i=null,r=null;return this.instances.forEach(o=>{o===e||o.isDestroyed||o.isBudgetSuspended||!o.countedContext||(o.isHiddenByViewport||o.isPaused?(!i||o.lastActiveAt<i.lastActiveAt)&&(i=o):t&&!o.isPointerInside&&o.mouseDown===0&&(!r||o.lastActiveAt<r.lastActiveAt)&&(r=o))}),i??r}static ensureContextBudget(e,t){if(this._activeContexts<this._maxContexts)return!0;if(t)return!1;let i=this.pickEvictionVictim(e,!0);return i?(i.suspendContextForBudget(),this._activeContexts<this._maxContexts):!1}static enforceContextBudget(){for(;this._activeContexts>this._maxContexts;){let e=this.pickEvictionVictim(null,!0);if(!e)break;e.suspendContextForBudget()}}static reclaimBudgetForWaiting(){for(;this._activeContexts<this._maxContexts;){let e=null;if(this.instances.forEach(t=>{t.isDestroyed||!t.isBudgetSuspended||t.isPaused||t.isHiddenByViewport||(!e||t.lastActiveAt>e.lastActiveAt)&&(e=t)}),!e||!e.restoreContextFromBudget())break}}static getRenderStats(){let e=0,t=0,i=0;return this.instances.forEach(r=>{r.isDestroyed||r.isPaused||r.isHiddenByViewport||r.isReducedMotion||r.isContextLost||r.isSurvivalSuspended||r.reportedFps>0&&(e++,r.reportedFps>t&&(t=r.reportedFps,i=r.reportedFrameTimeMs))}),{activeRendering:e,fps:t,frameTimeMs:i}}boostInteraction(e=re){let t=performance.now()+e;t>this.boostUntil&&(this.boostUntil=t)}resetFrameTracking(){this.lastRenderNow=0,this.lastDrawNow=0,this.lastTargetFps=0,this.prevFrameDrew=!1,this.avgDrawDeltaMs=0,this.reportedFps=0,this.reportedFrameTimeMs=0}resolveTierConfig(){let e=this.baseFeedbackMaxDim;return this.protectionTier===1?{ambientFps:Me,activeFps:Ce,feedbackMaxDim:Math.max(256,Math.round(e*.75)),suspended:!1}:this.protectionTier===2?{ambientFps:20,activeFps:30,feedbackMaxDim:Math.max(256,Math.round(e*.55)),suspended:!1}:this.protectionTier>=3?{ambientFps:15,activeFps:30,feedbackMaxDim:Math.max(256,Math.round(e*.5)),suspended:!this.isPointerInside&&this.mouseDown===0}:{ambientFps:Me,activeFps:Ce,feedbackMaxDim:e,suspended:!1}}resolveDprBounds(){let e=this.options.quality??"medium",t=ie[e]??ie.medium,i=typeof window<"u"&&window.devicePixelRatio||1,r=i>=1.5,o=this.options.maxDpr??Math.min(i,t.max),n=r?t.retinaMin:t.min,l=this.options.minDpr??Math.min(n,o);if(this.protectionTier===1){let a=Math.max(.65,Number((o*.75).toFixed(2)));return{minDpr:Math.min(l,a),maxDpr:a}}if(this.protectionTier>=2){let a=Math.max(.55,Math.min(l,Number((o*.6).toFixed(2))));return{minDpr:a,maxDpr:a}}return{minDpr:l,maxDpr:o}}computeScrollProgress(){if(typeof window>"u")return 0;let e=this.container.getBoundingClientRect(),t=window.innerHeight||1,i=t+e.height;return i<=0?0:Math.min(1,Math.max(0,(t-e.top)/i))}markContextActive(){this.countedContext||(this.countedContext=!0,B._activeContexts++,B._activeContexts>St&&console.warn(`[FluxFX] ${B._activeContexts} active WebGL contexts detected. Browsers typically cap contexts around 8\u201316; consider limiting simultaneous WebGL backgrounds.`))}markContextReleased(){this.countedContext&&(this.countedContext=!1,B._activeContexts=Math.max(0,B._activeContexts-1))}uniformVec3Css(e,t,i=1){let r=this.customUniforms.get(e),o=t[0],n=t[1],l=t[2];return r&&typeof r!="number"&&r.length>=3&&(o=Math.round(Math.min(1,Math.max(0,r[0]))*255),n=Math.round(Math.min(1,Math.max(0,r[1]))*255),l=Math.round(Math.min(1,Math.max(0,r[2]??0))*255)),i<1?`rgba(${o}, ${n}, ${l}, ${i})`:`rgb(${o}, ${n}, ${l})`}applyBudgetFallbackStyle(){if(this.isDestroyed)return;let e=this.customUniforms.get("uTransparentBg"),t=typeof e=="number"&&e>.5,i=this.customUniforms.get("uBgColor"),r=i&&typeof i!="number"&&i.length>=3&&i[0]+i[1]+(i[2]??0)>.003,o=this.uniformVec3Css("uColor1",[99,102,241],t?.38:.45),n=this.uniformVec3Css("uColor2",[6,182,212],t?.32:.38),l=this.uniformVec3Css("uColor3",[244,63,94],t?.22:.28),a=t?"transparent":r?this.uniformVec3Css("uBgColor",[6,8,16],1):"#070a14";this.canvas.style.background=`radial-gradient(circle at 22% 28%, ${o}, transparent 60%), radial-gradient(circle at 78% 72%, ${n}, transparent 62%), radial-gradient(circle at 55% 45%, ${l}, transparent 68%), ${a}`}syncDocVisibilityListener(){typeof document>"u"||(this.isOffscreen&&!this.hasDocVisibilityListener?(document.addEventListener("visibilitychange",this.handleDocVisibility),this.hasDocVisibilityListener=!0):!this.isOffscreen&&this.hasDocVisibilityListener&&(document.removeEventListener("visibilitychange",this.handleDocVisibility),this.hasDocVisibilityListener=!1))}releaseMainThreadContext(e){if(!this.gl){e||this.canvas.remove();return}let t=this.gl;if(t.isContextLost())this.pingPong=null,this.mainTextures.clear(),F.disposeContext(t),e||this.canvas.remove();else{this.destroyPingPongMain(),this.destroyMainTextures(),this.vbo&&t.deleteBuffer(this.vbo),this.vao&&t.deleteVertexArray(this.vao),F.disposeContext(t),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),t.useProgram(null),t.viewport(0,0,1,1),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.canvas.width=1,this.canvas.height=1;let r=this.canvas;if(e){let o=this.canvas.cloneNode(!1);this.canvas.replaceWith(o),this.canvas=o}else this.canvas.remove();!B.recycleMainContext(r,t)&&!Ge()&&t.getExtension("WEBGL_lose_context")?.loseContext()}this.gl=null}suspendContextForBudget(){this.isDestroyed||this.isBudgetSuspended||(this.isBudgetSuspended=!0,this.resetFrameTracking(),this.canvas.removeEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.removeEventListener("webglcontextrestored",this.handleContextRestored,!1),this.isOffscreen&&this.worker&&(this.worker.postMessage({type:"destroy"}),this.worker=null),this.isOffscreen=!1,this.syncDocVisibilityListener(),this.releaseMainThreadContext(!0),this.programEntry=null,this.feedbackProgramEntry=null,this.vao=null,this.vbo=null,this.dynamicRes=null,this.isContextLost=!1,this.markContextReleased(),this.applyBudgetFallbackStyle(),this.wakeCallback?.())}restoreContextFromBudget(){if(this.isDestroyed||!this.isBudgetSuspended||!B.ensureContextBudget(this,!1))return!1;let e=this.canvas.cloneNode(!1);e.style.background="",this.canvas.replaceWith(e),this.canvas=e;let t=this.container.getBoundingClientRect();this.width=Math.max(1,Math.floor(t.width)),this.height=Math.max(1,Math.floor(t.height));let{minDpr:i,maxDpr:r}=this.resolveDprBounds(),o=this.options.dynamicResolution??!0,n=this.options.offscreen??!0;return this.isBudgetSuspended=!1,this.isContextLost=!1,this.lastActiveAt=ae(),n&&Te()?this.initOffscreenMode(this.options,i,r,o):this.initMainThreadMode(this.options,i,r,o),this.reuploadLoadedTextures(),this.syncDocVisibilityListener(),this.wakeCallback?.(),this.countedContext}computeEffectiveQuality(){let e=this.options.quality??"medium",t=e==="high"?1:e==="low"?0:.5;return this.protectionTier>=2?t=0:this.protectionTier===1&&(t=Math.min(t,.5)),t}shouldPreserveBg(){return typeof this.options.preserveBg=="boolean"?this.options.preserveBg:this.layerMode==="overlay"}applyCanvasLayerStyle(){if(this.layerMode==="overlay"){this.canvas.style.zIndex="10";let e=typeof this.options.overlayOpacity=="number"?Math.max(.05,Math.min(1,this.options.overlayOpacity)):.78;this.canvas.style.opacity=String(e)}else this.canvas.style.zIndex="-1",this.canvas.style.opacity="1"}startPaletteTween(e,t=220){if(e.length===0)return;this.themeTweenRaf&&(cancelAnimationFrame(this.themeTweenRaf),this.themeTweenRaf=0);let i=this.toTriplet(this.activePaletteRgb.length>0?this.activePaletteRgb:this.basePaletteRgb),r=this.toTriplet(e);if(this.isReducedMotion||typeof requestAnimationFrame!="function"){this.activePaletteRgb=r,this.pushUniformBatch({uColor1:r[0],uColor2:r[1],uColor3:r[2]});return}let o=performance.now();this.boostInteraction(420);let n=l=>{if(this.isDestroyed){this.themeTweenRaf=0;return}let a=Math.min(1,(l-o)/t),c=a<.5?2*a*a:1-Math.pow(-2*a+2,2)/2,u=(m,v)=>[m[0]+(v[0]-m[0])*c,m[1]+(v[1]-m[1])*c,m[2]+(v[2]-m[2])*c],d=u(i[0],r[0]),f=u(i[1],r[1]),h=u(i[2],r[2]);this.activePaletteRgb=[d,f,h],this.pushUniformBatch({uColor1:d,uColor2:f,uColor3:h}),a<1?this.themeTweenRaf=requestAnimationFrame(n):this.themeTweenRaf=0};this.themeTweenRaf=requestAnimationFrame(n)}inspectSurfaceFromTarget(e,t=!1){if(!this.adaptToSurface||this.isDestroyed)return;let i=e instanceof HTMLElement?e:null,r=performance.now();if(!t&&i===this.lastSurfaceEl&&r-this.lastSurfaceCheckAt<180)return;this.lastSurfaceEl=i,this.lastSurfaceCheckAt=r;let o=Oe(i,this.container);if(!o){this.isSurfaceAdapted&&(this.isSurfaceAdapted=!1,this.lastSurfaceKey="",this.startPaletteTween(this.basePaletteRgb,220));return}let n=`${Math.round(o[0]*255)},${Math.round(o[1]*255)},${Math.round(o[2]*255)}`;if(!t&&n===this.lastSurfaceKey)return;this.lastSurfaceKey=n;let l=this.rawBasePaletteRgb.length>0?this.rawBasePaletteRgb:this.basePaletteRgb;if(l.length===0)return;let a=_e(l,[o[0],o[1],o[2]]);this.isSurfaceAdapted=!0,this.startPaletteTween(a,220)}parseColorList(e){if(!e)return[];let t=Array.isArray(e)?e:String(e).split(",").map(o=>o.trim()).filter(Boolean);if(t.length===0)return[];let i=D(t[0],"#6366f1"),r=[];for(let o=0;o<t.length;o++){let n=D(t[o],i),l=k.hexToVec3Into(n,k.scratchVec3);r.push([l[0],l[1],l[2]])}return r}parseScrollStops(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let i=0;i<e.length;i++){let r=e[i],o=Array.isArray(r)?r[0]:r;if(typeof o=="string"&&o.trim()){let n=D(o,"#6366f1"),l=k.hexToVec3Into(n,k.scratchVec3);t.push([l[0],l[1],l[2]])}}return t}detectDarkTheme(e){return e==="dark"?!0:e==="light"?!1:Ue(this.container)}resolveTargetPalette(e){let t=e?this.parseColorList(this.options.darkColors):this.parseColorList(this.options.lightColors);if(t.length>0)return t;let i=this.parseColorList(this.options.colors);return i.length>0?ue(i,e):this.basePaletteRgb}toTriplet(e){let t=e[0]??[.39,.4,.95],i=e[1]??t,r=e[2]??i;return[[t[0],t[1],t[2]],[i[0],i[1],i[2]],[r[0],r[1],r[2]]]}pushUniformBatch(e){if(!this.isDestroyed){for(let[t,i]of Object.entries(e))this.customUniforms.set(t,i);if(this.isBudgetSuspended){this.applyBudgetFallbackStyle();return}this.isOffscreen&&this.worker?this.worker.postMessage({type:"uniformsBatch",uniforms:e}):this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport&&this.drawMainThreadFrame()}}startThemeTransition(e){this.themeTweenRaf&&(cancelAnimationFrame(this.themeTweenRaf),this.themeTweenRaf=0);let t=e?1:0,i=this.resolveTargetPalette(e);i.length>0&&(this.basePaletteRgb=i);let r=this.currentTheme,o=this.toTriplet(this.activePaletteRgb.length>0?this.activePaletteRgb:this.basePaletteRgb),n=this.toTriplet(this.basePaletteRgb);if(this.isReducedMotion||typeof requestAnimationFrame!="function"){this.currentTheme=t,this.activePaletteRgb=n,this.pushUniformBatch({uTheme:t,uColor1:n[0],uColor2:n[1],uColor3:n[2]});return}let l=performance.now(),a=280;this.boostInteraction(500);let c=u=>{if(this.isDestroyed){this.themeTweenRaf=0;return}let d=Math.min(1,(u-l)/a),f=d<.5?2*d*d:1-Math.pow(-2*d+2,2)/2;this.currentTheme=r+(t-r)*f;let h=(b,x)=>[b[0]+(x[0]-b[0])*f,b[1]+(x[1]-b[1])*f,b[2]+(x[2]-b[2])*f],m=h(o[0],n[0]),v=h(o[1],n[1]),g=h(o[2],n[2]);this.activePaletteRgb=[m,v,g],this.pushUniformBatch({uTheme:this.currentTheme,uColor1:m,uColor2:v,uColor3:g}),d<1?this.themeTweenRaf=requestAnimationFrame(c):(this.themeTweenRaf=0,this.scrollStopsRgb.length>=2&&(this.lastScrollColorT=-1,this.updateScrollColorShift(this.computeScrollProgress())))};this.themeTweenRaf=requestAnimationFrame(c)}bindThemeWatchers(){if(this.unbindThemeWatchers(),!(typeof window>"u"||typeof document>"u")&&(typeof window.matchMedia=="function"&&(this.colorSchemeQuery=window.matchMedia("(prefers-color-scheme: dark)"),typeof this.colorSchemeQuery.addEventListener=="function"&&this.colorSchemeQuery.addEventListener("change",this.handleThemeChange)),typeof MutationObserver<"u")){this.themeMutationObserver=new MutationObserver(this.handleThemeChange);let e=["class","data-theme","data-mode","data-bs-theme","style"];this.themeMutationObserver.observe(document.documentElement,{attributes:!0,attributeFilter:e}),document.body&&this.themeMutationObserver.observe(document.body,{attributes:!0,attributeFilter:e}),this.container!==document.body&&this.container!==document.documentElement&&this.themeMutationObserver.observe(this.container,{attributes:!0,attributeFilter:e})}}unbindThemeWatchers(){this.themeTweenRaf&&(cancelAnimationFrame(this.themeTweenRaf),this.themeTweenRaf=0),this.colorSchemeQuery&&typeof this.colorSchemeQuery.removeEventListener=="function"&&this.colorSchemeQuery.removeEventListener("change",this.handleThemeChange),this.colorSchemeQuery=null,this.themeMutationObserver?.disconnect(),this.themeMutationObserver=null}updateScrollColorShift(e){if(this.scrollStopsRgb.length<2)return;let t=Math.min(1,Math.max(0,e));if(Math.abs(t-this.lastScrollColorT)<.002)return;this.lastScrollColorT=t;let i=ue(this.scrollStopsRgb,this.resolvedDarkTheme),r=i.length-1,o=t*r,n=Math.min(r-1,Math.floor(o)),l=o-n,a=i[n],c=i[n+1],u=i[Math.min(i.length-1,n+2)]??a,d=[a[0]+(c[0]-a[0])*l,a[1]+(c[1]-a[1])*l,a[2]+(c[2]-a[2])*l],f=[c[0]+(u[0]-c[0])*l,c[1]+(u[1]-c[1])*l,c[2]+(u[2]-c[2])*l],h=this.basePaletteRgb[2]??u;this.activePaletteRgb=[d,f,h],this.pushUniformBatch({uColor1:d,uColor2:f,uColor3:h})}syncScrollColorListener(){if(typeof window>"u")return;let e=this.scrollStopsRgb.length>=2;e&&!this.hasScrollColorListener?(window.addEventListener("scroll",this.handleScrollColorEvent,{passive:!0}),this.hasScrollColorListener=!0,this.lastScrollColorT=-1,this.updateScrollColorShift(this.computeScrollProgress())):!e&&this.hasScrollColorListener&&(window.removeEventListener("scroll",this.handleScrollColorEvent),this.hasScrollColorListener=!1,this.scrollColorRaf&&(cancelAnimationFrame(this.scrollColorRaf),this.scrollColorRaf=0))}getLocalTouchCoords(e){let t=this.container.getBoundingClientRect();if(t.width<=0||t.height<=0)return null;let i=(e.clientX-t.left)/t.width,r=1-(e.clientY-t.top)/t.height;return i<0||i>1||r<0||r>1?null:[i,r]}syncTouchListener(){typeof window>"u"||(this.interactive&&!this.hasTouchListener?(this.container.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),this.container.addEventListener("touchmove",this.handleTouchMove,{passive:!0}),this.container.addEventListener("touchend",this.handleTouchEnd,{passive:!0}),this.container.addEventListener("touchcancel",this.handleTouchEnd,{passive:!0}),this.hasTouchListener=!0):!this.interactive&&this.hasTouchListener&&(this.container.removeEventListener("touchstart",this.handleTouchStart),this.container.removeEventListener("touchmove",this.handleTouchMove),this.container.removeEventListener("touchend",this.handleTouchEnd),this.container.removeEventListener("touchcancel",this.handleTouchEnd),this.hasTouchListener=!1))}seedUniformsFromOptions(e,t=!1){let i={};if(typeof e.speed=="number"?(this.targetSpeed=e.speed,t&&(this.currentSpeed=e.speed),this.customUniforms.set("uSpeed",e.speed),i.uSpeed=e.speed):this.customUniforms.has("uSpeed")||(this.targetSpeed=1,this.currentSpeed=1,this.customUniforms.set("uSpeed",1),i.uSpeed=1),t||e.quality!==void 0){let l=this.computeEffectiveQuality();this.customUniforms.set("uQuality",l),i.uQuality=l}e.scrollColors!==void 0&&(this.scrollStopsRgb=this.parseScrollStops(e.scrollColors),this.lastScrollColorT=-1);let r=this.resolvedDarkTheme;e.theme!==void 0&&(this.themeMode=e.theme);let o=this.detectDarkTheme(this.themeMode);if(this.resolvedDarkTheme=o,t&&(this.currentTheme=o?1:0,this.customUniforms.set("uTheme",this.currentTheme),i.uTheme=this.currentTheme),t||e.colors!==void 0||e.lightColors!==void 0||e.darkColors!==void 0||e.theme!==void 0||e.scrollColors!==void 0){let l=this.parseColorList(this.options.colors);l.length>0&&(this.rawBasePaletteRgb=l);let a=this.resolveTargetPalette(o);if(a.length>0)if(this.basePaletteRgb=a,this.rawBasePaletteRgb.length===0&&(this.rawBasePaletteRgb=a),!t&&o!==r)this.startThemeTransition(o);else{let[c,u,d]=this.toTriplet(a);this.activePaletteRgb=[c,u,d],this.customUniforms.set("uColor1",c),this.customUniforms.set("uColor2",u),this.customUniforms.set("uColor3",d),i.uColor1=c,i.uColor2=u,i.uColor3=d,t||(this.currentTheme=o?1:0,this.customUniforms.set("uTheme",this.currentTheme),i.uTheme=this.currentTheme)}}if(e.uniforms)for(let[l,a]of Object.entries(e.uniforms))this.customUniforms.set(l,a),i[l]=typeof a=="number"?a:Array.from(a);return this.shouldPreserveBg()&&(this.customUniforms.set("uTransparentBg",1),i.uTransparentBg=1),i}fallbackToMainThread(e,t,i,r){if(this.isDestroyed)return;this.worker&&(this.worker.terminate(),this.worker=null),this.isOffscreen=!1,this.resetFrameTracking(),this.markContextReleased();let o=this.canvas.cloneNode(!1);this.canvas.replaceWith(o),this.canvas=o,this.initMainThreadMode(e,t,i,r)}initOffscreenMode(e,t,i,r){try{let o=Ve(),n=this.canvas.transferControlToOffscreen();this.worker=o,this.isOffscreen=!0,this.markContextActive(),o.onmessage=a=>{if(a.data?.type==="error")this.fallbackToMainThread(e,t,i,r);else if(a.data?.type==="stats"){this.reportedFps=typeof a.data.fps=="number"?a.data.fps:0,this.reportedFrameTimeMs=typeof a.data.frameTimeMs=="number"?a.data.frameTimeMs:0;let c=typeof a.data.targetFps=="number"?a.data.targetFps:0;this.reportedFrameTimeMs>0&&c>0&&W.recordGpuFrame(this.reportedFrameTimeMs,c,performance.now())}else a.data?.type==="needTextures"&&this.reuploadLoadedTextures()},o.onerror=()=>{this.fallbackToMainThread(e,t,i,r)};let l={};this.customUniforms.forEach((a,c)=>{l[c]=typeof a=="number"?a:Array.from(a)}),o.postMessage({type:"init",canvas:n,width:this.width,height:this.height,minDpr:t,maxDpr:i,dynamicRes:r,reducedMotion:this.isReducedMotion,vertexShader:e.vertexShader??He,fragmentShader:e.fragmentShader,feedbackShader:e.feedbackShader??null,feedbackScale:this.feedbackScale,feedbackMaxDim:this.feedbackMaxDim,feedbackFloat:this.feedbackFloat,initialScroll:this.scroll,ambientFps:this.ambientFps,activeFps:this.activeFps,survivalPaused:this.isSurvivalSuspended,uniforms:l},[n])}catch{this.isOffscreen=!1,this.markContextReleased(),this.initMainThreadMode(e,t,i,r)}}computeFboDimsMain(e,t){let i=Math.max(1,Math.floor(e*this.feedbackScale)),r=Math.max(1,Math.floor(t*this.feedbackScale)),o=Math.max(i,r);if(o>this.feedbackMaxDim){let n=this.feedbackMaxDim/o;i=Math.max(1,Math.floor(i*n)),r=Math.max(1,Math.floor(r*n))}return[i,r]}destroyPingPongMain(){if(!this.pingPong||!this.gl){this.pingPong=null;return}for(let e=0;e<2;e++)this.gl.deleteFramebuffer(this.pingPong[e].fbo),this.gl.deleteTexture(this.pingPong[e].tex);this.pingPong=null}createPingPongMain(e){if(this.destroyPingPongMain(),!this.options.feedbackShader||this.isContextLost)return;let[t,i]=this.computeFboDimsMain(this.canvas.width,this.canvas.height);this.fboW=t,this.fboH=i;let r=e.RGBA8,o=e.UNSIGNED_BYTE;this.feedbackFloat&&(e.getExtension("EXT_color_buffer_float")||e.getExtension("EXT_color_buffer_half_float"))&&(r=e.RGBA16F,o=e.HALF_FLOAT);let l=(c,u)=>{let d=[];for(let f=0;f<2;f++){let h=e.createTexture(),m=e.createFramebuffer();if(!h||!m)return h&&e.deleteTexture(h),m&&e.deleteFramebuffer(m),d.forEach(v=>{e.deleteFramebuffer(v.fbo),e.deleteTexture(v.tex)}),null;if(e.bindTexture(e.TEXTURE_2D,h),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,c,this.fboW,this.fboH,0,e.RGBA,u,null),e.bindFramebuffer(e.FRAMEBUFFER,m),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,h,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return e.deleteFramebuffer(m),e.deleteTexture(h),d.forEach(v=>{e.deleteFramebuffer(v.fbo),e.deleteTexture(v.tex)}),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),null;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),d.push({fbo:m,tex:h})}return e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),[d[0],d[1]]},a=l(r,o);!a&&r!==e.RGBA8&&(r=e.RGBA8,o=e.UNSIGNED_BYTE,a=l(r,o)),this.fboFormat=r,this.fboType=o,this.pingPong=a,this.readIdx=0,this.writeIdx=1}resizePingPongMain(){if(!this.pingPong||!this.gl||this.isContextLost)return;let[e,t]=this.computeFboDimsMain(this.canvas.width,this.canvas.height);if(e===this.fboW&&t===this.fboH)return;let i=this.gl,r=this.fboW,o=this.fboH,n=this.pingPong[this.readIdx],l=[];for(let a=0;a<2;a++){let c=i.createTexture(),u=i.createFramebuffer();i.bindTexture(i.TEXTURE_2D,c),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,this.fboFormat,e,t,0,i.RGBA,this.fboType,null),i.bindFramebuffer(i.FRAMEBUFFER,u),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,c,0),l.push({fbo:u,tex:c})}i.bindFramebuffer(i.READ_FRAMEBUFFER,n.fbo),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,l[0].fbo),i.blitFramebuffer(0,0,r,o,0,0,e,t,i.COLOR_BUFFER_BIT,i.LINEAR),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindTexture(i.TEXTURE_2D,null);for(let a=0;a<2;a++)i.deleteFramebuffer(this.pingPong[a].fbo),i.deleteTexture(this.pingPong[a].tex);this.pingPong=[l[0],l[1]],this.fboW=e,this.fboH=t,this.readIdx=0,this.writeIdx=1}initMainThreadPipeline(e){let t=this.options.vertexShader??oe;this.programEntry=F.getOrCreateProgram(e,this.options.fragmentShader,t),this.options.feedbackShader?this.feedbackProgramEntry=F.getOrCreateProgram(e,this.options.feedbackShader,t):this.feedbackProgramEntry=null,this.vao=e.createVertexArray(),e.bindVertexArray(this.vao),this.vbo=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vbo),e.bufferData(e.ARRAY_BUFFER,Et,e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),this.needsResize=!1,this.applyCanvasSize(),this.options.feedbackShader&&this.createPingPongMain(e)}initMainThreadMode(e,t,i,r){let o=null,n=B.acquireRecycledMainContext();if(n?(n.canvas.style.background="",this.canvas.replaceWith(n.canvas),this.canvas=n.canvas,o=n.gl):o=this.canvas.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1}),!o){console.warn("[FluxFX] WebGL2 is not supported on this device."),this.isBudgetSuspended=!0,this.applyBudgetFallbackStyle();return}this.gl=o,this.markContextActive(),this.canvas.addEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.addEventListener("webglcontextrestored",this.handleContextRestored,!1),this.dynamicRes=new ce({minScale:r?t:i,maxScale:i}),this.initMainThreadPipeline(o),this.reuploadLoadedTextures(),this.drawMainThreadFrame()}applyCanvasSize(){if(!this.gl||!this.dynamicRes||this.isContextLost)return;let e=this.dynamicRes.scale,t=Math.max(1,Math.round(this.width*e)),i=Math.max(1,Math.round(this.height*e));(this.canvas.width!==t||this.canvas.height!==i)&&(this.canvas.width=t,this.canvas.height=i,this.gl.viewport(0,0,t,i)),this.pingPong&&this.resizePingPongMain()}bindCommonUniformsMain(e,t,i,r){let o=F.getUniformLocation(e,t,"uTime");o&&e.uniform1f(o,this.elapsedSec);let n=F.getUniformLocation(e,t,"uDelta");n&&e.uniform1f(n,this.lastDeltaSec);let l=F.getUniformLocation(e,t,"uResolution");l&&e.uniform2f(l,i,r);let a=F.getUniformLocation(e,t,"uCanvasResolution");a&&e.uniform2f(a,this.canvas.width,this.canvas.height);let c=F.getUniformLocation(e,t,"uDpr");c&&this.dynamicRes&&e.uniform1f(c,this.dynamicRes.scale);let u=F.getUniformLocation(e,t,"uMouse");u&&e.uniform2f(u,this.mouse[0],this.mouse[1]);let d=F.getUniformLocation(e,t,"uMouseVel");d&&e.uniform2f(d,this.mouseVel[0],this.mouseVel[1]);let f=F.getUniformLocation(e,t,"uMouseDown");f&&e.uniform1f(f,this.mouseDown);let h=F.getUniformLocation(e,t,"uMouseActive");h&&e.uniform1f(h,this.mouseActive);let m=F.getUniformLocation(e,t,"uScroll");m&&e.uniform1f(m,this.scroll);let v=F.getUniformLocation(e,t,"uScrollVel");v&&e.uniform1f(v,this.scrollVel),this.customUniforms.forEach((g,b)=>{let x=F.getUniformLocation(e,t,b);x&&(b==="uSpeed"?e.uniform1f(x,this.currentSpeed):typeof g=="number"?e.uniform1f(x,g):g.length===2?e.uniform2f(x,g[0],g[1]):g.length===3?e.uniform3f(x,g[0],g[1],g[2]):g.length===4&&e.uniform4f(x,g[0],g[1],g[2],g[3]))})}drawMainThreadFrame(){if(!this.gl||!this.programEntry||this.isContextLost)return;let e=this.gl;if(e.bindVertexArray(this.vao),this.feedbackProgramEntry&&this.pingPong){e.bindFramebuffer(e.FRAMEBUFFER,this.pingPong[this.writeIdx].fbo),e.viewport(0,0,this.fboW,this.fboH),e.useProgram(this.feedbackProgramEntry.program),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.pingPong[this.readIdx].tex);let t=F.getUniformLocation(e,this.feedbackProgramEntry,"uPrevFrame");t&&e.uniform1i(t,0),this.bindMainTextures(e,this.feedbackProgramEntry),this.bindCommonUniformsMain(e,this.feedbackProgramEntry,this.fboW,this.fboH),e.drawArrays(e.TRIANGLES,0,3);let i=this.readIdx;this.readIdx=this.writeIdx,this.writeIdx=i,e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,this.canvas.width,this.canvas.height)}if(e.useProgram(this.programEntry.program),this.pingPong){e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.pingPong[this.readIdx].tex);let t=F.getUniformLocation(e,this.programEntry,"uFeedback");t&&e.uniform1i(t,0);let i=F.getUniformLocation(e,this.programEntry,"uPrevFrame");i&&e.uniform1i(i,0)}this.bindMainTextures(e,this.programEntry),this.bindCommonUniformsMain(e,this.programEntry,this.canvas.width,this.canvas.height),e.drawArrays(e.TRIANGLES,0,3)}render(e,t){if(this.isOffscreen||this.isPaused||this.isHiddenByViewport||this.isReducedMotion||this.isContextLost||this.isSurvivalSuspended||this.isBudgetSuspended||this.isDestroyed||!this.gl||!this.programEntry)return;let i=performance.now(),r=this.lastRenderNow?Math.min(i-this.lastRenderNow,100):16.67;this.lastRenderNow=i,this.prevFrameDrew&&(this.dynamicRes&&this.dynamicRes.recordFrame(r,i)&&(this.needsResize=!0),this.prevFrameDrew=!1);let n=i<this.boostUntil||this.mouseDown>.5?this.activeFps:this.ambientFps,l=1e3/n-2;if(this.lastDrawNow>0&&i-this.lastDrawNow<l)return;let a=this.lastDrawNow?i-this.lastDrawNow:1e3/n,c=Math.min(a,100);this.lastDrawNow=i,n!==this.lastTargetFps?(this.lastTargetFps=n,this.avgDrawDeltaMs=0):a>0&&a<500&&(this.avgDrawDeltaMs=this.avgDrawDeltaMs===0?a:this.avgDrawDeltaMs*.85+a*.15),this.avgDrawDeltaMs>0&&(this.reportedFps=Math.round(1e3/this.avgDrawDeltaMs),this.reportedFrameTimeMs=Math.round(this.avgDrawDeltaMs*100)/100),a>0&&a<500&&W.recordGpuFrame(a,n,i);let u=Math.max(.001,Math.min(c*.001,.05));if(this.lastDeltaSec=u,this.currentSpeed+=(this.targetSpeed-this.currentSpeed)*de(7.5,u),this.elapsedSec+=u*this.currentSpeed,this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.mouseActive+=(this.targetMouseActive-this.mouseActive)*de(7,u),this.mouseActive<.001&&this.targetMouseActive===0&&(this.mouseActive=0),this.targetMouseActive>.5){let d=this.mouse[0],f=this.mouse[1],h=de(13,u);this.mouse[0]+=(this.targetMouse[0]-this.mouse[0])*h,this.mouse[1]+=(this.targetMouse[1]-this.mouse[1])*h,this.mouseVel[0]=Math.max(-8,Math.min(8,(this.mouse[0]-d)/u)),this.mouseVel[1]=Math.max(-8,Math.min(8,(this.mouse[1]-f)/u))}else this.mouseVel[0]=0,this.mouseVel[1]=0;if(this.trackScroll){let d=this.scroll;this.scroll+=(this.targetScroll-this.scroll)*de(9.5,u),this.scrollVel=Math.max(-6,Math.min(6,(this.scroll-d)/u))}this.drawMainThreadFrame(),this.prevFrameDrew=!0}applyProtectionState(){if(this.isDestroyed||this.isBudgetSuspended)return;let e=this.resolveTierConfig(),{minDpr:t,maxDpr:i}=this.resolveDprBounds(),o=this.options.dynamicResolution??!0?t:i,n=this.isSurvivalSuspended,l=this.feedbackMaxDim;this.ambientFps=e.ambientFps,this.activeFps=e.activeFps,this.feedbackMaxDim=e.feedbackMaxDim,this.isSurvivalSuspended=e.suspended,this.isSurvivalSuspended&&!n&&this.resetFrameTracking(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"protection",minDpr:o,maxDpr:i,feedbackMaxDim:this.feedbackMaxDim,ambientFps:this.ambientFps,activeFps:this.activeFps,suspended:this.isSurvivalSuspended}):((this.dynamicRes?.setBounds(o,i)??!1)||l!==this.feedbackMaxDim)&&(this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport?(this.needsResize=!1,this.applyCanvasSize(),this.drawMainThreadFrame()):this.needsResize=!0),n!==this.isSurvivalSuspended&&this.wakeCallback?.()}syncDprBounds(){this.applyProtectionState()}watchDevicePixelRatio(){if(this.dprMediaQuery&&(this.dprMediaQuery.removeEventListener("change",this.handleDprChange),this.dprMediaQuery=null),typeof window>"u"||typeof window.matchMedia!="function")return;let e=window.devicePixelRatio||1;this.dprMediaQuery=window.matchMedia(`(resolution: ${e}dppx)`),this.dprMediaQuery.addEventListener("change",this.handleDprChange)}updateOptions(e){if(this.isDestroyed)return;let t=this.options.quality;this.options={...this.options,...e},e.layer!==void 0&&(this.layerMode=e.layer),(e.layer!==void 0||e.overlayOpacity!==void 0)&&this.applyCanvasLayerStyle(),typeof e.adaptToSurface=="boolean"&&(this.adaptToSurface=e.adaptToSurface,!this.adaptToSurface&&this.isSurfaceAdapted&&(this.isSurfaceAdapted=!1,this.lastSurfaceEl=null,this.lastSurfaceKey="",this.startPaletteTween(this.basePaletteRgb,200)));let i=this.seedUniformsFromOptions(e,!1);if(e.preserveBg!==void 0||e.layer!==void 0){let o=this.shouldPreserveBg()?1:Number(this.customUniforms.get("uTransparentBg")??0);this.customUniforms.set("uTransparentBg",o),i.uTransparentBg=o}if(this.boostInteraction(1200),e.quality!==void 0&&e.quality!==t){let r=ie[e.quality]??ie.medium;this.baseFeedbackMaxDim=this.options.feedbackMaxDim??r.fboMaxDim}if(e.feedbackMaxDim!==void 0&&(this.baseFeedbackMaxDim=e.feedbackMaxDim),(e.quality!==void 0&&e.quality!==t||e.feedbackMaxDim!==void 0||e.minDpr!==void 0||e.maxDpr!==void 0||e.dynamicResolution!==void 0)&&this.syncDprBounds(),typeof e.interactive=="boolean"&&e.interactive!==this.interactive&&(this.interactive=e.interactive,this.syncPointerListener(),this.syncTouchListener()),typeof e.trackScroll=="boolean"&&e.trackScroll!==this.trackScroll&&(this.trackScroll=e.trackScroll,this.syncScrollListener()),e.scrollColors!==void 0&&this.syncScrollColorListener(),typeof e.respectReducedMotion=="boolean"){this.respectReducedMotion=e.respectReducedMotion;let r=this.reducedMotionQuery?.matches??!1;this.applyReducedMotionState(this.respectReducedMotion&&r)}if(this.isBudgetSuspended){this.applyBudgetFallbackStyle();return}this.isOffscreen&&this.worker?Object.keys(i).length>0&&this.worker.postMessage({type:"uniformsBatch",uniforms:i}):this.isReducedMotion&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame()),e.textures!==void 0&&this.syncTexturesFromOptions(e.textures)}applyReducedMotionState(e){this.isReducedMotion!==e&&(this.isReducedMotion=e,this.resetFrameTracking(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"reducedMotion",value:e}):e&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame()),this.wakeCallback?.())}getLocalPointerCoords(e){let t=this.container.getBoundingClientRect();if(t.width<=0||t.height<=0||e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)return null;let i=(e.clientX-t.left)/t.width,r=1-(e.clientY-t.top)/t.height;return[i,r]}syncInteractiveAttr(){if(this.interactive&&!this.isDestroyed){this.container.setAttribute("data-fluxfx-interactive","true");return}let e=!1;B.instances.forEach(t=>{t!==this&&!t.isDestroyed&&t.interactive&&t.container===this.container&&(e=!0)}),e||this.container.removeAttribute("data-fluxfx-interactive")}isShadowedByChildInteractive(e){if(!(e instanceof Element))return!1;let t=e.closest('[data-fluxfx-interactive="true"]');return!!(t&&t!==this.container&&this.container.contains(t))}syncPointerListener(){this.syncInteractiveAttr(),this.interactive&&!this.hasPointerListener?(this.container.addEventListener("pointerenter",this.handlePointerEnter,{passive:!0}),this.container.addEventListener("pointermove",this.handlePointerMove,{passive:!0}),this.container.addEventListener("pointerleave",this.handlePointerLeave,{passive:!0}),this.container.addEventListener("pointerdown",this.handlePointerDown,{passive:!0}),window.addEventListener("pointerup",this.handlePointerUp,{passive:!0}),window.addEventListener("pointercancel",this.handlePointerUp,{passive:!0}),this.hasPointerListener=!0):!this.interactive&&this.hasPointerListener&&(this.container.removeEventListener("pointerenter",this.handlePointerEnter),this.container.removeEventListener("pointermove",this.handlePointerMove),this.container.removeEventListener("pointerleave",this.handlePointerLeave),this.container.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp),this.handlePointerLeave(),this.hasPointerListener=!1)}syncScrollListener(){this.trackScroll&&!this.hasScrollListener?(window.addEventListener("scroll",this.handleScroll,{passive:!0}),this.hasScrollListener=!0,this.handleScroll()):!this.trackScroll&&this.hasScrollListener&&(window.removeEventListener("scroll",this.handleScroll),this.hasScrollListener=!1)}bindObservers(e){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(t=>{let i=t[0];if(!i)return;let r=Math.max(1,Math.floor(i.contentRect.width)),o=Math.max(1,Math.floor(i.contentRect.height));r===this.width&&o===this.height||(this.width=r,this.height=o,this.boostInteraction(600),this.trackScroll&&this.handleScroll(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"resize",width:this.width,height:this.height}):this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport?(this.needsResize=!1,this.applyCanvasSize(),this.drawMainThreadFrame()):this.needsResize=!0)}),this.resizeObserver.observe(this.container)),e&&typeof IntersectionObserver<"u"&&(this.visibilityObserver=new IntersectionObserver(t=>{let i=t[0]?.isIntersecting??!0;if(this.isHiddenByViewport=!i,i){if(this.lastActiveAt=ae(),this.isBudgetSuspended&&!this.isPaused){this.restoreContextFromBudget();return}}else this.handlePointerLeave(),this.resetFrameTracking();this.isOffscreen&&this.worker&&this.worker.postMessage({type:i&&!this.isPaused?"resume":"pause"}),this.wakeCallback?.()},{rootMargin:"50px"}),this.visibilityObserver.observe(this.container)),this.reducedMotionQuery&&this.reducedMotionQuery.addEventListener("change",this.handleReducedMotionChange),this.isOffscreen&&typeof document<"u"&&document.addEventListener("visibilitychange",this.handleDocVisibility),this.watchDevicePixelRatio(),this.bindThemeWatchers(),this.syncPointerListener(),this.syncTouchListener(),this.syncScrollListener(),this.syncScrollColorListener()}setUniform(e,t){if(!this.isDestroyed){if(this.customUniforms.set(e,t),e==="uSpeed"&&typeof t=="number"&&(this.targetSpeed=t),this.boostInteraction(1200),this.isBudgetSuspended){this.applyBudgetFallbackStyle();return}this.isOffscreen&&this.worker?this.worker.postMessage({type:"uniform",name:e,value:typeof t=="number"?t:Array.from(t)}):this.isReducedMotion&&this.drawMainThreadFrame()}}setColor(e,t){let i=D(t,"#ffffff"),r=k.hexToVec3Into(i,k.scratchVec3);this.setUniform(e,[r[0],r[1],r[2]])}get isIdle(){return this.isDestroyed||this.isPaused||this.isHiddenByViewport||this.isReducedMotion||this.isContextLost}onWake(e){this.wakeCallback=e}pause(){this.isPaused||this.isDestroyed||(this.isPaused=!0,this.resetFrameTracking(),this.handlePointerLeave(),this.isOffscreen&&this.worker&&this.worker.postMessage({type:"pause"}))}resume(){if(!(!this.isPaused||this.isDestroyed)){if(this.isPaused=!1,this.lastRenderNow=0,this.lastDrawNow=0,this.lastActiveAt=ae(),this.isBudgetSuspended&&!this.isHiddenByViewport){this.restoreContextFromBudget();return}this.isOffscreen&&this.worker&&!this.isHiddenByViewport?this.worker.postMessage({type:"resume"}):this.isReducedMotion&&!this.isHiddenByViewport&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame())}}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.wakeCallback=null,this.unsubscribeGuard?.(),this.unsubscribeGuard=null,this.unbindThemeWatchers(),this.touchBurstTimer&&(window.clearTimeout(this.touchBurstTimer),this.touchBurstTimer=0),this.touchLeaveTimer&&(window.clearTimeout(this.touchLeaveTimer),this.touchLeaveTimer=0),this.hasTouchListener&&(this.container.removeEventListener("touchstart",this.handleTouchStart),this.container.removeEventListener("touchmove",this.handleTouchMove),this.container.removeEventListener("touchend",this.handleTouchEnd),this.container.removeEventListener("touchcancel",this.handleTouchEnd),this.hasTouchListener=!1),this.hasScrollColorListener&&(window.removeEventListener("scroll",this.handleScrollColorEvent),this.hasScrollColorListener=!1),this.scrollColorRaf&&(cancelAnimationFrame(this.scrollColorRaf),this.scrollColorRaf=0),this.isBodyMount&&(this.container.style.minHeight=this.origBodyMinHeight),B.instances.delete(this),this.syncInteractiveAttr(),this.resetFrameTracking(),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.visibilityObserver?.disconnect(),this.visibilityObserver=null,this.reducedMotionQuery&&(this.reducedMotionQuery.removeEventListener("change",this.handleReducedMotionChange),this.reducedMotionQuery=null),this.dprMediaQuery&&(this.dprMediaQuery.removeEventListener("change",this.handleDprChange),this.dprMediaQuery=null),typeof document<"u"&&document.removeEventListener("visibilitychange",this.handleDocVisibility),this.hasPointerListener&&(this.container.removeEventListener("pointerenter",this.handlePointerEnter),this.container.removeEventListener("pointermove",this.handlePointerMove),this.container.removeEventListener("pointerleave",this.handlePointerLeave),this.container.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp),this.hasPointerListener=!1),this.hasScrollListener&&(window.removeEventListener("scroll",this.handleScroll),this.hasScrollListener=!1),this.canvas.removeEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.removeEventListener("webglcontextrestored",this.handleContextRestored,!1),this.isOffscreen&&this.worker&&(this.worker.postMessage({type:"destroy"}),this.worker=null),this.releaseMainThreadContext(!1),this.markContextReleased(),k.releaseVec2(this.mouse),k.releaseVec2(this.targetMouse),k.releaseVec2(this.mouseVel),this.customUniforms.clear(),this.textureUrls.clear(),this.textureUnits.clear(),this.loadedImages.clear(),this.textureLoadTokens.clear(),B.reclaimBudgetForWaiting())}resolveTextureUrl(e){let t=e.trim();if(!t)return"";if(/^(data:|blob:)/i.test(t)||typeof window>"u")return t;try{return new URL(t,window.location.href).href}catch{return t}}destroyMainTextures(){if(!this.gl||this.mainTextures.size===0){this.mainTextures.clear();return}let e=this.gl;this.mainTextures.forEach(t=>{e.deleteTexture(t.tex)}),this.mainTextures.clear()}bindMainTextures(e,t){this.mainTextures.size!==0&&this.mainTextures.forEach((i,r)=>{let o=F.getUniformLocation(e,t,r);o&&(e.activeTexture(e.TEXTURE0+i.unit),e.bindTexture(e.TEXTURE_2D,i.tex),e.uniform1i(o,i.unit))})}uploadImageTexture(e,t,i,r){if(this.isDestroyed)return;let o=this.textureUnits.get(e);o===void 0&&(o=this.nextTextureUnit++,this.textureUnits.set(e,o));let n=`${e}Size`,l=`${e}Ready`;if(this.customUniforms.set(n,[i,r]),this.customUniforms.set(l,1),this.isOffscreen&&this.worker&&typeof createImageBitmap=="function"){createImageBitmap(t).then(a=>{if(this.isDestroyed||!this.isOffscreen||!this.worker){a.close();return}this.worker.postMessage({type:"texture",name:e,unit:o,bitmap:a,width:i,height:r},[a]),this.boostInteraction(600),this.wakeCallback?.()}).catch(()=>{});return}if(this.gl&&!this.isContextLost){let a=this.gl,u=this.mainTextures.get(e)?.tex??null;u||(u=a.createTexture()),u&&(a.activeTexture(a.TEXTURE0+o),a.bindTexture(a.TEXTURE_2D,u),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,t),a.bindTexture(a.TEXTURE_2D,null),this.mainTextures.set(e,{unit:o,tex:u}),this.pushUniformBatch({[n]:[i,r],[l]:1}),this.boostInteraction(600),this.wakeCallback?.(),!this.isPaused&&!this.isHiddenByViewport&&this.drawMainThreadFrame())}}reuploadLoadedTextures(){this.loadedImages.forEach((e,t)=>{this.uploadImageTexture(t,e.img,e.width,e.height)})}clearTextureSlot(e){if(this.textureUrls.delete(e),this.loadedImages.delete(e),this.textureLoadTokens.set(e,(this.textureLoadTokens.get(e)??0)+1),this.customUniforms.set(`${e}Ready`,0),this.isOffscreen&&this.worker)this.worker.postMessage({type:"clearTexture",name:e});else if(this.gl&&!this.isContextLost){let t=this.mainTextures.get(e);t&&(this.gl.deleteTexture(t.tex),this.mainTextures.delete(e)),this.pushUniformBatch({[`${e}Ready`]:0})}}syncTexturesFromOptions(e){if(!(!e||typeof window>"u"||typeof Image>"u"))for(let[t,i]of Object.entries(e)){let r=i?this.resolveTextureUrl(i):"",o=this.textureUrls.get(t)??"";if(!r){o?this.clearTextureSlot(t):this.customUniforms.set(`${t}Ready`,0);continue}if(r===o)continue;this.textureUrls.set(t,r),this.customUniforms.has(`${t}Ready`)||this.customUniforms.set(`${t}Ready`,0);let n=(this.textureLoadTokens.get(t)??0)+1;this.textureLoadTokens.set(t,n);let l=new Image;if(!/^(data:|blob:)/i.test(r))try{new URL(r,window.location.href).origin!==window.location.origin&&(l.crossOrigin="anonymous")}catch{}l.decoding="async",l.onload=()=>{if(this.isDestroyed||this.textureLoadTokens.get(t)!==n)return;let a=l.naturalWidth||l.width||1,c=l.naturalHeight||l.height||1;this.loadedImages.set(t,{url:r,img:l,width:a,height:c}),this.uploadImageTexture(t,l,a,c)},l.onerror=()=>{this.isDestroyed||this.textureLoadTokens.get(t)!==n||console.warn(`[FluxFX] Failed to load texture "${t}" from: ${r}`)},l.src=r}}};B._activeContexts=0,B._maxContexts=We(),B.instances=new Set,B.recycledMainContexts=[];var G=B;var fe=class{constructor(){this.plugins=new Map;this.activeByElement=new WeakMap;this.activeSet=new Set;this.visibilityObserver=null;this.visibilityCallbacks=new WeakMap;this.removeTicker=null;this.removeVisibilitySub=null;this.hasResizeListener=!1;this.resizeRaf=0;this.handleViewportResize=()=>{this.resizeRaf||(this.resizeRaf=requestAnimationFrame(()=>{this.resizeRaf=0;let e=!1;this.activeSet.forEach(t=>{if(!this.hasDeviceConstraints(t.options))return;let i=this.isDeviceAllowed(t.options);i&&!t.instance?this.mountEntryInstance(t)&&(e=!0):!i&&t.instance&&(this.unmountEntryInstance(t),e=!0)}),e&&this.syncTickerState()}))}}isDeviceAllowed(e){if(typeof window>"u")return!0;let t=window.innerWidth||document.documentElement?.clientWidth||1024,i=typeof e.mobileBreakpoint=="number"&&e.mobileBreakpoint>0?e.mobileBreakpoint:768;if(e.disableOnMobile&&t<i||e.disableOnDesktop&&t>=i)return!1;let r=typeof e.device=="string"?e.device.trim().toLowerCase():"all";return!(r==="desktop"&&t<i||r==="mobile"&&t>=i||r==="tablet"&&(t<i||t>=1024)||typeof e.minWidth=="number"&&t<e.minWidth||typeof e.maxWidth=="number"&&t>e.maxWidth)}hasDeviceConstraints(e){return!!(e.device&&e.device!=="all"||e.disableOnMobile||e.disableOnDesktop||typeof e.minWidth=="number"||typeof e.maxWidth=="number")}mountEntryInstance(e){if(e.instance)return!0;try{let t=e.plugin.mount(e.el,e.options);return e.instance=t,e.faulted=!1,this.bindWake(e),this.attachEntryObserver(e),(!e.visible||N.isHidden)&&t.pause?.(),!0}catch(t){return e.faulted=!0,console.error(`[FluxFX] Failed to mount "${e.name}":`,t),!1}}unmountEntryInstance(e){if(e.unobserve?.(),e.unobserve=null,!!e.instance){try{e.instance.destroy()}catch(t){console.error(`[FluxFX] Device toggle cleanup error in "${e.name}":`,t)}e.instance=null,e.visible=!0}}attachEntryObserver(e){if(!(e.options.pauseWhenHidden??!0)||e.unobserve)return;let i=this.ensureObserver();if(!i)return;let r=this.visibilityCallbacks.get(e.el);r||(r=new Set,this.visibilityCallbacks.set(e.el,r),i.observe(e.el));let o=n=>{e.visible=n,e.instance&&(n&&!N.isHidden?e.instance.resume?.():e.instance.pause?.(),this.syncTickerState())};r.add(o),e.unobserve=()=>{r?.delete(o),r&&r.size===0&&(i.unobserve(e.el),this.visibilityCallbacks.delete(e.el))}}syncResizeWatcher(){if(typeof window>"u")return;let e=!1;this.activeSet.forEach(t=>{!e&&this.hasDeviceConstraints(t.options)&&(e=!0)}),e&&!this.hasResizeListener?(window.addEventListener("resize",this.handleViewportResize,{passive:!0}),this.hasResizeListener=!0):!e&&this.hasResizeListener&&(window.removeEventListener("resize",this.handleViewportResize),this.hasResizeListener=!1,this.resizeRaf&&(cancelAnimationFrame(this.resizeRaf),this.resizeRaf=0))}ensureObserver(){return typeof window>"u"||typeof IntersectionObserver>"u"?null:(this.visibilityObserver||(this.visibilityObserver=new IntersectionObserver(e=>{for(let t=0;t<e.length;t++){let i=e[t],r=this.visibilityCallbacks.get(i.target);r&&r.forEach(o=>o(i.isIntersecting))}},{rootMargin:"50px"})),this.visibilityObserver)}ensureVisibilitySub(){this.removeVisibilitySub||(this.removeVisibilitySub=N.onVisibilityChange(e=>{this.activeSet.forEach(t=>{t.faulted||!t.instance||(e?t.instance.pause?.():t.visible&&t.instance.resume?.())}),this.syncTickerState()}))}hasActiveTickWork(){let e=!1;return this.activeSet.forEach(t=>{e||!t.visible||t.faulted||!t.instance?.update||t.instance.isIdle?.()||(e=!0)}),e}syncTickerState(){this.hasActiveTickWork()?this.ensureTicker():this.removeTicker&&(this.removeTicker(),this.removeTicker=null)}ensureTicker(){this.removeTicker||(this.removeTicker=N.add((e,t)=>{let i=!1;this.activeSet.forEach(r=>{if(!(!r.visible||r.faulted||!r.instance?.update)&&!r.instance.isIdle?.()){try{r.instance.update(e,t)}catch(o){r.faulted=!0,console.error(`[FluxFX] Runtime error in "${r.name}" (auto-paused):`,o);return}r.instance.isIdle?.()||(i=!0)}}),i||this.syncTickerState()}))}cleanupEmptyEngine(){this.syncTickerState(),this.syncResizeWatcher(),this.activeSet.size===0&&this.removeVisibilitySub&&(this.removeVisibilitySub(),this.removeVisibilitySub=null)}bindWake(e){e.instance?.onWake?.(()=>{this.activeSet.has(e)&&this.syncTickerState()})}register(e){return this.plugins.set(e.name,e),this}has(e){return this.plugins.has(e)}setMaxWebGLContexts(e){G.setMaxActiveContexts(e)}getStats(){let e=0,t=0,i=!1,r=N.isHidden;this.activeSet.forEach(u=>{if(!u.instance){t++;return}u.visible&&e++;let d=u.instance.isIdle?.()??!1;r||!u.visible||u.faulted||d?t++:!u.instance.isWebGL&&u.instance.isIdle&&(i=!0)});let o=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,n=G.getRenderStats(),l=N.fps,a=N.frameTimeMs;!r&&n.activeRendering>0&&!i?(l=n.fps,a=n.frameTimeMs):r&&(l=0,a=0);let c=W.getSnapshot();return{mounted:this.activeSet.size,visible:e,pausedEffects:t,activeLoops:N.isRunning?1:0,registered:this.plugins.size,webglContexts:G.activeContexts,activeContexts:G.activeContexts,maxWebGLContexts:G.maxActiveContexts,suspendedContexts:G.suspendedContexts,fps:l,frameTimeMs:a,reducedMotion:o,protectionTier:c.tier,protectionLabel:c.label}}apply(e,t,i={}){let r=this.plugins.get(t);if(!r)return console.warn(`[FluxFX] Effect "${t}" is not registered.`),()=>{};let o=this.activeByElement.get(e);o||(o=new Map,this.activeByElement.set(e,o));let n=o.get(t);n&&n.destroy();let l=!1,a={el:e,name:t,plugin:r,instance:null,options:{...i},visible:!0,faulted:!1,unobserve:null,destroy:()=>{l||(l=!0,this.unmountEntryInstance(a),this.activeSet.delete(a),o?.delete(t),this.cleanupEmptyEngine())}};return this.isDeviceAllowed(a.options)&&!this.mountEntryInstance(a)?(o?.delete(t),()=>{}):(o.set(t,a),this.activeSet.add(a),this.ensureVisibilitySub(),this.syncResizeWatcher(),this.syncTickerState(),a.destroy)}update(e,t,i={}){let o=this.activeByElement.get(e)?.get(t);if(!o)return!1;o.options={...o.options,...i};let n=o.options;if(this.syncResizeWatcher(),!this.isDeviceAllowed(n))return this.unmountEntryInstance(o),this.syncTickerState(),!0;if(!o.instance){let a=this.mountEntryInstance(o);return this.syncTickerState(),a}if(o.instance.setOptions)try{return o.instance.setOptions(n),this.syncTickerState(),!0}catch(a){return console.error(`[FluxFX] Hot-update error in "${t}":`,a),!1}try{return o.instance.destroy(),o.instance=o.plugin.mount(e,n),o.faulted=!1,this.bindWake(o),(!o.visible||N.isHidden)&&o.instance.pause?.(),this.syncTickerState(),!0}catch(a){return o.faulted=!0,console.error(`[FluxFX] Fallback remount error in "${t}":`,a),this.syncTickerState(),!1}}scan(e=document){if(typeof document>"u")return;e.querySelectorAll("[data-fx]").forEach(i=>{let r=i.getAttribute("data-fx");if(!r)return;let o=r.trim().split(/\s+/).filter(Boolean),n=this.parseDatasetOptions(i),l=this.activeByElement.get(i);o.forEach(a=>{l?.has(a)||this.apply(i,a,n)})})}init(e){typeof document>"u"||(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.scan(e??document),{once:!0}):this.scan(e??document))}destroyAll(){let e=Array.from(this.activeSet);for(let t=0;t<e.length;t++)e[t].destroy()}parseDatasetOptions(e){let t={},i=new Set(["preserveBg","adaptToSurface","interactive","trackScroll","glare","offscreen","dynamicResolution","pauseWhenHidden","respectReducedMotion","ambient","clickReveal","focused","wrap","clickToFocus","disableOnMobile","disableOnDesktop"]),r=new Set(["colors","lightColors","darkColors","scrollColors"]);for(let[o,n]of Object.entries(e.dataset)){if(!o.startsWith("fx")||o==="fx"||n===void 0)continue;let l=o.slice(2),a=l.charAt(0).toLowerCase()+l.slice(1),c=n.trim(),u=c.toLowerCase();c===""&&i.has(a)||u==="true"?t[a]=!0:u==="false"?t[a]=!1:r.has(a)?t[a]=c.split(",").map(d=>d.trim()).filter(Boolean):c!==""&&!Number.isNaN(Number(c))?t[a]=Number(c):t[a]=c}return t}},he=new fe;function Lt(s){if(s==null)return!1;let e=String(s).trim().toLowerCase();if(!e)return!1;if(e==="transparent"||e==="none")return!0;let t=e.match(/^rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+(?:\s*,\s*([\d.]+))?\s*\)$/);return t&&t[1]!==void 0?parseFloat(t[1])<=.001:!1}function Xe(s){let e=s.replace("#","").trim(),t=e.length===3?e.split("").map(n=>n+n).join(""):e;if(t.length!==6)return!0;let i=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,o=parseInt(t.slice(4,6),16)/255;return .2126*i+.7152*r+.0722*o>.45}function ze(s,e){if(Array.isArray(s.colors)&&s.colors.length>0){let o=s.colors.filter(Boolean);if(o.length===1){let c=D(o[0],e[0]);return[c,c,c]}if(o.length===2){let c=D(o[0],e[0]),u=D(o[1],e[1]);return[c,u,u]}let n=D(o[0],e[0]),l=D(o[1]??n,e[1]),a=D(o[2]??l,e[2]);return[n,l,a]}if(typeof s.colors=="string"){let o=s.colors.split(",").map(n=>n.trim()).filter(Boolean);if(o.length===1){let n=D(o[0],e[0]);return[n,n,n]}if(o.length===2){let n=D(o[0],e[0]),l=D(o[1],e[1]);return[n,l,l]}if(o.length>2)return[D(o[0],e[0]),D(o[1],e[1]),D(o[2],e[2])]}if(s.color1===void 0&&s.color2===void 0&&s.color3===void 0)return e;let t=D(s.color1,e[0]),i=s.color2!==void 0?D(s.color2,t):t,r=s.color3!==void 0?D(s.color3,i):i;return[t,i,r]}function I(s,e){let t=Lt(s.bgColor),i=!t&&s.bgColor!==void 0&&String(s.bgColor).trim()!=="",r=i?D(s.bgColor,e):e,o=k.hexToVec3Into(r,k.scratchVec3);return{uBgColor:[o[0],o[1],o[2]],uHasBgColor:i?1:0,uTransparentBg:t?1:0,bgHex:r,hasBgColor:i,transparentBg:t}}function Ft(s){return s==="high"?.65:s==="low"?.35:.5}function O(s){return{name:s.name,mount(e,t){let i=t.quality??"medium",r=new G(e,{fragmentShader:s.fragmentShader,vertexShader:s.vertexShader,feedbackShader:s.feedbackShader,feedbackScale:s.feedbackShader?Ft(i):void 0,feedbackFloat:s.feedbackShader?s.feedbackFloat??!0:void 0,feedbackMaxDim:typeof t.feedbackMaxDim=="number"?t.feedbackMaxDim:void 0,speed:typeof t.speed=="number"?t.speed:1,quality:i,colors:ze(t,s.defaultColors),uniforms:s.resolveUniforms?s.resolveUniforms(t):void 0,textures:s.resolveTextures?s.resolveTextures(t):void 0,theme:t.theme,lightColors:t.lightColors,darkColors:t.darkColors,scrollColors:t.scrollColors,trackScroll:t.trackScroll,layer:t.layer,preserveBg:t.preserveBg,adaptToSurface:t.adaptToSurface,overlayOpacity:t.overlayOpacity,interactive:t.interactive!==!1,dynamicResolution:t.dynamicResolution,minDpr:t.minDpr,maxDpr:t.maxDpr,offscreen:t.offscreen,pauseWhenHidden:t.pauseWhenHidden,respectReducedMotion:t.respectReducedMotion});return{isWebGL:!0,update(o,n){r.render(o,n)},setOptions(o){r.updateOptions({speed:typeof o.speed=="number"?o.speed:1,quality:o.quality,colors:ze(o,s.defaultColors),uniforms:s.resolveUniforms?s.resolveUniforms(o):void 0,textures:s.resolveTextures?s.resolveTextures(o):void 0,theme:o.theme,lightColors:o.lightColors,darkColors:o.darkColors,scrollColors:o.scrollColors,trackScroll:o.trackScroll,layer:o.layer,preserveBg:o.preserveBg,adaptToSurface:o.adaptToSurface,overlayOpacity:o.overlayOpacity,interactive:o.interactive!==!1,dynamicResolution:o.dynamicResolution,minDpr:o.minDpr,maxDpr:o.maxDpr,feedbackMaxDim:typeof o.feedbackMaxDim=="number"?o.feedbackMaxDim:void 0,respectReducedMotion:o.respectReducedMotion})},isIdle(){return r.isIdle},onWake(o){r.onWake(o)},pause(){r.pause()},resume(){r.resume()},destroy(){r.destroy()}}}}}var kt=`#version 300 es
859
+ `,pt=null;function vt(){if(typeof window>"u"||typeof Worker>"u"||typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"||!("transferControlToOffscreen"in HTMLCanvasElement.prototype))return!1;let r=typeof navigator<"u"?navigator.userAgent:"";return!(/iP(ad|hone|od)/i.test(r)||/^((?!chrome|android).)*safari/i.test(r))}function At(){if(!pt){let r=new Blob([yr],{type:"application/javascript"});pt=URL.createObjectURL(r)}return new Worker(pt)}var Bt=Je;var Xe={low:{max:1,min:.65,retinaMin:.85,fboMaxDim:512},medium:{max:2,min:.75,retinaMin:1,fboMaxDim:896},high:{max:2,min:1,retinaMin:1.25,fboMaxDim:1152}},Tr=new Float32Array([-1,-1,3,-1,-1,3]),Mr=12;function It(){if(typeof navigator>"u")return!1;let r=navigator.userAgent||"";return/Safari/i.test(r)&&!/Chrome|Chromium|Edg|CriOS|FxiOS|OPR/i.test(r)}function Ut(){if(typeof navigator>"u")return 8;let r=navigator.userAgent||"",e=/Mobi|Android|iPhone|iPad|iPod/i.test(r);return It()||e?6:8}function Ze(){return typeof performance<"u"?performance.now():Date.now()}var gt=30,bt=60,Ne=1800;function nt(r,e){return 1-Math.exp(-r*e)}var ie=class ie{constructor(e,t){this.resizeObserver=null;this.visibilityObserver=null;this.reducedMotionQuery=null;this.dprMediaQuery=null;this.worker=null;this.isOffscreen=!1;this.gl=null;this.programEntry=null;this.feedbackProgramEntry=null;this.vao=null;this.vbo=null;this.dynamicRes=null;this.lastRenderNow=0;this.lastDrawNow=0;this.lastTargetFps=0;this.prevFrameDrew=!1;this.avgDrawDeltaMs=0;this.boostUntil=0;this.reportedFps=0;this.reportedFrameTimeMs=0;this.elapsedSec=0;this.lastDeltaSec=.01667;this.currentSpeed=1;this.targetSpeed=1;this.needsResize=!1;this.pingPong=null;this.fboW=1;this.fboH=1;this.fboFormat=0;this.fboType=0;this.readIdx=0;this.writeIdx=1;this.customUniforms=new Map;this.textureUrls=new Map;this.textureUnits=new Map;this.loadedImages=new Map;this.mainTextures=new Map;this.textureLoadTokens=new Map;this.nextTextureUnit=1;this.mouse=J.acquireVec2(.5,.5);this.targetMouse=J.acquireVec2(.5,.5);this.mouseVel=J.acquireVec2(0,0);this.mouseDown=0;this.mouseActive=0;this.targetMouseActive=0;this.isPointerInside=!1;this.scroll=0;this.targetScroll=0;this.scrollVel=0;this.hasScrollListener=!1;this.width=1;this.height=1;this.isPaused=!1;this.isHiddenByViewport=!1;this.isContextLost=!1;this.isReducedMotion=!1;this.isDestroyed=!1;this.wakeCallback=null;this.ambientFps=gt;this.activeFps=bt;this.protectionTier=Te.tier;this.isSurvivalSuspended=!1;this.unsubscribeGuard=null;this.isBudgetSuspended=!1;this.lastActiveAt=Ze();this.hasDocVisibilityListener=!1;this.hasPointerListener=!1;this.countedContext=!1;this.isBodyMount=!1;this.origBodyMinHeight="";this.themeMode="auto";this.resolvedDarkTheme=!0;this.currentTheme=1;this.themeTweenRaf=0;this.colorSchemeQuery=null;this.themeMutationObserver=null;this.basePaletteRgb=[];this.activePaletteRgb=[];this.scrollStopsRgb=[];this.lastScrollColorT=-1;this.hasScrollColorListener=!1;this.scrollColorRaf=0;this.hasTouchListener=!1;this.touchBurstTimer=0;this.touchLeaveTimer=0;this.layerMode="background";this.adaptToSurface=!1;this.rawBasePaletteRgb=[];this.lastSurfaceEl=null;this.lastSurfaceKey="";this.lastSurfaceCheckAt=0;this.isSurfaceAdapted=!1;this.handleThemeChange=()=>{if(this.isDestroyed)return;let e=this.detectDarkTheme(this.themeMode);e!==this.resolvedDarkTheme&&(this.resolvedDarkTheme=e,this.startThemeTransition(e))};this.handleScrollColorEvent=()=>{this.isDestroyed||this.scrollStopsRgb.length<2||this.scrollColorRaf||(this.scrollColorRaf=requestAnimationFrame(()=>{if(this.scrollColorRaf=0,this.isDestroyed||this.scrollStopsRgb.length<2)return;let e=this.computeScrollProgress();this.updateScrollColorShift(e)}))};this.handleTouchStart=e=>{if(!this.interactive||this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;let t=e.touches[0];if(!t)return;if(this.isShadowedByChildInteractive(t.target)){this.isPointerInside&&this.handlePointerLeave();return}let o=this.getLocalTouchCoords(t);if(!o)return;this.touchLeaveTimer&&(window.clearTimeout(this.touchLeaveTimer),this.touchLeaveTimer=0),this.touchBurstTimer&&(window.clearTimeout(this.touchBurstTimer),this.touchBurstTimer=0);let[i,s]=o;this.inspectSurfaceFromTarget(t.target,!0),this.isPointerInside=!0,this.targetMouseActive=1,this.mouseDown=1,this.boostInteraction(Ne),this.isOffscreen&&this.worker?(this.worker.postMessage({type:"mouseEnter",x:i,y:s}),this.worker.postMessage({type:"mouseDown",down:!0})):(this.mouse[0]=i,this.mouse[1]=s,this.targetMouse[0]=i,this.targetMouse[1]=s,this.mouseVel[0]=0,this.mouseVel[1]=0),this.touchBurstTimer=window.setTimeout(()=>{this.touchBurstTimer=0,!this.isDestroyed&&(this.mouseDown=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!1}))},160)};this.handleTouchMove=e=>{if(!this.interactive||this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;let t=e.touches[0];if(!t)return;if(this.isShadowedByChildInteractive(t.target)){this.isPointerInside&&this.handlePointerLeave();return}let o=this.getLocalTouchCoords(t);if(!o)return;let[i,s]=o;this.inspectSurfaceFromTarget(t.target),this.boostInteraction(Ne),this.targetMouseActive=1,this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouse",x:i,y:s}):(this.targetMouse[0]=i,this.targetMouse[1]=s)};this.handleTouchEnd=()=>{this.isDestroyed||(this.mouseDown=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!1}),this.touchLeaveTimer&&window.clearTimeout(this.touchLeaveTimer),this.touchLeaveTimer=window.setTimeout(()=>{this.touchLeaveTimer=0,this.isDestroyed||this.handlePointerLeave()},550))};this.handleContextLost=e=>{e.preventDefault(),this.isContextLost=!0,this.resetFrameTracking(),this.gl&&j.disposeContext(this.gl),this.programEntry=null,this.feedbackProgramEntry=null,this.pingPong=null,this.mainTextures.clear(),this.vao=null,this.vbo=null,this.wakeCallback?.()};this.handleContextRestored=()=>{if(!(this.isDestroyed||!this.gl))try{this.isContextLost=!1,this.initMainThreadPipeline(this.gl),this.reuploadLoadedTextures(),this.drawMainThreadFrame(),this.wakeCallback?.()}catch(e){console.error("[FluxFX] Failed to restore WebGL2 context:",e)}};this.handleProtectionTierChange=e=>{this.isDestroyed||this.protectionTier===e||(this.protectionTier=e,this.applyProtectionState(),this.isDestroyed||this.pushUniformBatch({uQuality:this.computeEffectiveQuality()}))};this.handleDprChange=()=>{this.isDestroyed||(this.syncDprBounds(),this.watchDevicePixelRatio())};this.handleReducedMotionChange=e=>{this.applyReducedMotionState(this.respectReducedMotion&&e.matches)};this.handlePointerEnter=e=>{if(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;if(this.isShadowedByChildInteractive(e.target)){this.isPointerInside&&this.handlePointerLeave();return}let t=this.getLocalPointerCoords(e);if(!t)return;let[o,i]=t;this.isPointerInside=!0,this.targetMouseActive=1,this.boostInteraction(Ne),this.protectionTier>=3&&this.applyProtectionState(),this.lastActiveAt=Ze(),this.isBudgetSuspended&&!this.isPaused&&this.restoreContextFromBudget(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouseEnter",x:o,y:i}):(this.mouse[0]=o,this.mouse[1]=i,this.targetMouse[0]=o,this.targetMouse[1]=i,this.mouseVel[0]=0,this.mouseVel[1]=0)};this.handlePointerMove=e=>{if(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;if(this.isShadowedByChildInteractive(e.target)){this.isPointerInside&&this.handlePointerLeave();return}let t=this.getLocalPointerCoords(e);if(!t){this.isPointerInside&&this.handlePointerLeave();return}let[o,i]=t;if(!this.isPointerInside){this.handlePointerEnter(e),this.inspectSurfaceFromTarget(e.target,!0);return}this.inspectSurfaceFromTarget(e.target),this.boostInteraction(Ne),this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouse",x:o,y:i}):(this.targetMouse[0]=o,this.targetMouse[1]=i)};this.handlePointerLeave=()=>{!this.isPointerInside&&this.targetMouseActive===0||(this.isPointerInside=!1,this.targetMouseActive=0,this.lastSurfaceEl=null,this.lastSurfaceKey="",this.isSurfaceAdapted&&(this.isSurfaceAdapted=!1,this.startPaletteTween(this.basePaletteRgb,240)),this.mouseDown=0,this.mouseVel[0]=0,this.mouseVel[1]=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseLeave"}),this.protectionTier>=3&&this.applyProtectionState())};this.handlePointerDown=e=>{if(!(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)){if(this.isShadowedByChildInteractive(e.target)){this.isPointerInside&&this.handlePointerLeave();return}this.isPointerInside||this.handlePointerEnter(e),this.mouseDown=1,this.boostInteraction(Ne),this.protectionTier>=3&&this.applyProtectionState(),this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!0})}};this.handlePointerUp=()=>{this.mouseDown!==0&&(this.mouseDown=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!1}),this.protectionTier>=3&&this.applyProtectionState())};this.handleScroll=()=>{if(!this.trackScroll||this.isDestroyed)return;let e=this.computeScrollProgress();this.boostInteraction(1200),this.isOffscreen&&this.worker?this.worker.postMessage({type:"scroll",progress:e}):(this.targetScroll=e,this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport&&(this.scroll=e,this.scrollVel=0,this.drawMainThreadFrame()))};this.handleDocVisibility=()=>{!this.isOffscreen||!this.worker||(document.hidden?(this.resetFrameTracking(),this.worker.postMessage({type:"pause"})):!this.isPaused&&!this.isHiddenByViewport&&this.worker.postMessage({type:"resume"}))};this.container=e,this.options={...t},this.interactive=t.interactive??!0,this.respectReducedMotion=t.respectReducedMotion??!0,this.trackScroll=t.trackScroll??!1,this.feedbackScale=t.feedbackScale??.5,this.feedbackFloat=t.feedbackFloat??!0,ie.instances.add(this);let o=t.quality??"medium",i=Xe[o]??Xe.medium;this.baseFeedbackMaxDim=t.feedbackMaxDim??i.fboMaxDim;let s=this.resolveTierConfig();this.ambientFps=s.ambientFps,this.activeFps=s.activeFps,this.feedbackMaxDim=s.feedbackMaxDim,this.isSurvivalSuspended=s.suspended,typeof window<"u"&&typeof window.matchMedia=="function"&&(this.reducedMotionQuery=window.matchMedia("(prefers-reduced-motion: reduce)"),this.isReducedMotion=this.respectReducedMotion&&this.reducedMotionQuery.matches),this.isBodyMount=typeof document<"u"&&this.container===document.body,window.getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.style.isolation="isolate",this.isBodyMount&&(this.origBodyMinHeight=this.container.style.minHeight,this.container.style.minHeight||(this.container.style.minHeight="100dvh")),this.canvas=document.createElement("canvas"),this.canvas.setAttribute("data-fluxfx-canvas","true"),this.canvas.style.position=this.isBodyMount?"fixed":"absolute",this.canvas.style.inset="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.zIndex="-1",this.canvas.style.pointerEvents="none",this.canvas.style.display="block",this.container.prepend(this.canvas),this.layerMode=t.layer??"background",this.adaptToSurface=t.adaptToSurface??!1,this.applyCanvasLayerStyle(),this.themeMode=t.theme??"auto",this.resolvedDarkTheme=this.detectDarkTheme(this.themeMode),this.currentTheme=this.resolvedDarkTheme?1:0;let l=this.container.getBoundingClientRect();if(this.width=Math.max(1,Math.floor(l.width)),this.height=Math.max(1,Math.floor(l.height)),this.trackScroll){let v=this.computeScrollProgress();this.scroll=v,this.targetScroll=v}let{minDpr:a,maxDpr:u}=this.resolveDprBounds(),c=t.dynamicResolution??!0,f=t.offscreen??!0;this.seedUniformsFromOptions(t,!0);let m=typeof window<"u"&&window.innerHeight||0,p=typeof window<"u"&&window.innerWidth||0,h=(t.pauseWhenHidden??!0)&&m>0&&(l.bottom<-50||l.top>m+50||l.right<-50||l.left>p+50);h&&(this.isHiddenByViewport=!0),ie.ensureContextBudget(this,h)?f&&vt()?this.initOffscreenMode(t,a,u,c):this.initMainThreadMode(t,a,u,c):(this.isBudgetSuspended=!0,this.applyBudgetFallbackStyle()),this.bindObservers(t.pauseWhenHidden??!0),this.unsubscribeGuard=Te.onTierChange(this.handleProtectionTierChange),this.syncTexturesFromOptions(t.textures)}static acquireRecycledMainContext(){for(;this.recycledMainContexts.length>0;){let e=this.recycledMainContexts.pop();if(!e.gl.isContextLost())return e}return null}static recycleMainContext(e,t){let o=Math.max(this._maxContexts,Ut());return this.recycledMainContexts.length>=o?!1:(this.recycledMainContexts.push({canvas:e,gl:t}),!0)}static get activeContexts(){return this._activeContexts}static get maxActiveContexts(){return this._maxContexts}static get suspendedContexts(){let e=0;return this.instances.forEach(t=>{!t.isDestroyed&&t.isBudgetSuspended&&e++}),e}static setMaxActiveContexts(e){let t=Math.max(1,Math.floor(e));t!==this._maxContexts&&(this._maxContexts=t,this.enforceContextBudget(),this.reclaimBudgetForWaiting())}static pickEvictionVictim(e,t){let o=null,i=null;return this.instances.forEach(s=>{s===e||s.isDestroyed||s.isBudgetSuspended||!s.countedContext||(s.isHiddenByViewport||s.isPaused?(!o||s.lastActiveAt<o.lastActiveAt)&&(o=s):t&&!s.isPointerInside&&s.mouseDown===0&&(!i||s.lastActiveAt<i.lastActiveAt)&&(i=s))}),o??i}static ensureContextBudget(e,t){if(this._activeContexts<this._maxContexts)return!0;if(t)return!1;let o=this.pickEvictionVictim(e,!0);return o?(o.suspendContextForBudget(),this._activeContexts<this._maxContexts):!1}static enforceContextBudget(){for(;this._activeContexts>this._maxContexts;){let e=this.pickEvictionVictim(null,!0);if(!e)break;e.suspendContextForBudget()}}static reclaimBudgetForWaiting(){for(;this._activeContexts<this._maxContexts;){let e=null;if(this.instances.forEach(t=>{t.isDestroyed||!t.isBudgetSuspended||t.isPaused||t.isHiddenByViewport||(!e||t.lastActiveAt>e.lastActiveAt)&&(e=t)}),!e||!e.restoreContextFromBudget())break}}static getRenderStats(){let e=0,t=0,o=0;return this.instances.forEach(i=>{i.isDestroyed||i.isPaused||i.isHiddenByViewport||i.isReducedMotion||i.isContextLost||i.isSurvivalSuspended||i.reportedFps>0&&(e++,i.reportedFps>t&&(t=i.reportedFps,o=i.reportedFrameTimeMs))}),{activeRendering:e,fps:t,frameTimeMs:o}}boostInteraction(e=Ne){let t=performance.now()+e;t>this.boostUntil&&(this.boostUntil=t)}resetFrameTracking(){this.lastRenderNow=0,this.lastDrawNow=0,this.lastTargetFps=0,this.prevFrameDrew=!1,this.avgDrawDeltaMs=0,this.reportedFps=0,this.reportedFrameTimeMs=0}resolveTierConfig(){let e=this.baseFeedbackMaxDim;return this.protectionTier===1?{ambientFps:gt,activeFps:bt,feedbackMaxDim:Math.max(256,Math.round(e*.75)),suspended:!1}:this.protectionTier===2?{ambientFps:20,activeFps:30,feedbackMaxDim:Math.max(256,Math.round(e*.55)),suspended:!1}:this.protectionTier>=3?{ambientFps:15,activeFps:30,feedbackMaxDim:Math.max(256,Math.round(e*.5)),suspended:!this.isPointerInside&&this.mouseDown===0}:{ambientFps:gt,activeFps:bt,feedbackMaxDim:e,suspended:!1}}resolveDprBounds(){let e=this.options.quality??"medium",t=Xe[e]??Xe.medium,o=typeof window<"u"&&window.devicePixelRatio||1,i=o>=1.5,s=this.options.maxDpr??Math.min(o,t.max),n=i?t.retinaMin:t.min,l=this.options.minDpr??Math.min(n,s);if(this.protectionTier===1){let a=Math.max(.65,Number((s*.75).toFixed(2)));return{minDpr:Math.min(l,a),maxDpr:a}}if(this.protectionTier>=2){let a=Math.max(.55,Math.min(l,Number((s*.6).toFixed(2))));return{minDpr:a,maxDpr:a}}return{minDpr:l,maxDpr:s}}computeScrollProgress(){if(typeof window>"u")return 0;let e=this.container.getBoundingClientRect(),t=window.innerHeight||1,o=t+e.height;return o<=0?0:Math.min(1,Math.max(0,(t-e.top)/o))}markContextActive(){this.countedContext||(this.countedContext=!0,ie._activeContexts++,ie._activeContexts>Mr&&console.warn(`[FluxFX] ${ie._activeContexts} active WebGL contexts detected. Browsers typically cap contexts around 8\u201316; consider limiting simultaneous WebGL backgrounds.`))}markContextReleased(){this.countedContext&&(this.countedContext=!1,ie._activeContexts=Math.max(0,ie._activeContexts-1))}uniformVec3Css(e,t,o=1){let i=this.customUniforms.get(e),s=t[0],n=t[1],l=t[2];return i&&typeof i!="number"&&i.length>=3&&(s=Math.round(Math.min(1,Math.max(0,i[0]))*255),n=Math.round(Math.min(1,Math.max(0,i[1]))*255),l=Math.round(Math.min(1,Math.max(0,i[2]??0))*255)),o<1?`rgba(${s}, ${n}, ${l}, ${o})`:`rgb(${s}, ${n}, ${l})`}applyBudgetFallbackStyle(){if(this.isDestroyed)return;let e=this.customUniforms.get("uTransparentBg"),t=typeof e=="number"&&e>.5,o=this.customUniforms.get("uBgColor"),i=o&&typeof o!="number"&&o.length>=3&&o[0]+o[1]+(o[2]??0)>.003,s=this.uniformVec3Css("uColor1",[99,102,241],t?.38:.45),n=this.uniformVec3Css("uColor2",[6,182,212],t?.32:.38),l=this.uniformVec3Css("uColor3",[244,63,94],t?.22:.28),a=t?"transparent":i?this.uniformVec3Css("uBgColor",[6,8,16],1):"#070a14";this.canvas.style.background=`radial-gradient(circle at 22% 28%, ${s}, transparent 60%), radial-gradient(circle at 78% 72%, ${n}, transparent 62%), radial-gradient(circle at 55% 45%, ${l}, transparent 68%), ${a}`}syncDocVisibilityListener(){typeof document>"u"||(this.isOffscreen&&!this.hasDocVisibilityListener?(document.addEventListener("visibilitychange",this.handleDocVisibility),this.hasDocVisibilityListener=!0):!this.isOffscreen&&this.hasDocVisibilityListener&&(document.removeEventListener("visibilitychange",this.handleDocVisibility),this.hasDocVisibilityListener=!1))}releaseMainThreadContext(e){if(!this.gl){e||this.canvas.remove();return}let t=this.gl;if(t.isContextLost())this.pingPong=null,this.mainTextures.clear(),j.disposeContext(t),e||this.canvas.remove();else{this.destroyPingPongMain(),this.destroyMainTextures(),this.vbo&&t.deleteBuffer(this.vbo),this.vao&&t.deleteVertexArray(this.vao),j.disposeContext(t),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),t.useProgram(null),t.viewport(0,0,1,1),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.canvas.width=1,this.canvas.height=1;let i=this.canvas;if(e){let s=this.canvas.cloneNode(!1);this.canvas.replaceWith(s),this.canvas=s}else this.canvas.remove();!ie.recycleMainContext(i,t)&&!It()&&t.getExtension("WEBGL_lose_context")?.loseContext()}this.gl=null}suspendContextForBudget(){this.isDestroyed||this.isBudgetSuspended||(this.isBudgetSuspended=!0,this.resetFrameTracking(),this.canvas.removeEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.removeEventListener("webglcontextrestored",this.handleContextRestored,!1),this.isOffscreen&&this.worker&&(this.worker.postMessage({type:"destroy"}),this.worker=null),this.isOffscreen=!1,this.syncDocVisibilityListener(),this.releaseMainThreadContext(!0),this.programEntry=null,this.feedbackProgramEntry=null,this.vao=null,this.vbo=null,this.dynamicRes=null,this.isContextLost=!1,this.markContextReleased(),this.applyBudgetFallbackStyle(),this.wakeCallback?.())}restoreContextFromBudget(){if(this.isDestroyed||!this.isBudgetSuspended||!ie.ensureContextBudget(this,!1))return!1;let e=this.canvas.cloneNode(!1);e.style.background="",this.canvas.replaceWith(e),this.canvas=e;let t=this.container.getBoundingClientRect();this.width=Math.max(1,Math.floor(t.width)),this.height=Math.max(1,Math.floor(t.height));let{minDpr:o,maxDpr:i}=this.resolveDprBounds(),s=this.options.dynamicResolution??!0,n=this.options.offscreen??!0;return this.isBudgetSuspended=!1,this.isContextLost=!1,this.lastActiveAt=Ze(),n&&vt()?this.initOffscreenMode(this.options,o,i,s):this.initMainThreadMode(this.options,o,i,s),this.reuploadLoadedTextures(),this.syncDocVisibilityListener(),this.wakeCallback?.(),this.countedContext}computeEffectiveQuality(){let e=this.options.quality??"medium",t=e==="high"?1:e==="low"?0:.5;return this.protectionTier>=2?t=0:this.protectionTier===1&&(t=Math.min(t,.5)),t}shouldPreserveBg(){return typeof this.options.preserveBg=="boolean"?this.options.preserveBg:this.layerMode==="overlay"}applyCanvasLayerStyle(){if(this.layerMode==="overlay"){this.canvas.style.zIndex="10";let e=typeof this.options.overlayOpacity=="number"?Math.max(.05,Math.min(1,this.options.overlayOpacity)):.78;this.canvas.style.opacity=String(e)}else this.canvas.style.zIndex="-1",this.canvas.style.opacity="1"}startPaletteTween(e,t=220){if(e.length===0)return;this.themeTweenRaf&&(cancelAnimationFrame(this.themeTweenRaf),this.themeTweenRaf=0);let o=this.toTriplet(this.activePaletteRgb.length>0?this.activePaletteRgb:this.basePaletteRgb),i=this.toTriplet(e);if(this.isReducedMotion||typeof requestAnimationFrame!="function"){this.activePaletteRgb=i,this.pushUniformBatch({uColor1:i[0],uColor2:i[1],uColor3:i[2]});return}let s=performance.now();this.boostInteraction(420);let n=l=>{if(this.isDestroyed){this.themeTweenRaf=0;return}let a=Math.min(1,(l-s)/t),u=a<.5?2*a*a:1-Math.pow(-2*a+2,2)/2,c=(h,v)=>[h[0]+(v[0]-h[0])*u,h[1]+(v[1]-h[1])*u,h[2]+(v[2]-h[2])*u],f=c(o[0],i[0]),m=c(o[1],i[1]),p=c(o[2],i[2]);this.activePaletteRgb=[f,m,p],this.pushUniformBatch({uColor1:f,uColor2:m,uColor3:p}),a<1?this.themeTweenRaf=requestAnimationFrame(n):this.themeTweenRaf=0};this.themeTweenRaf=requestAnimationFrame(n)}inspectSurfaceFromTarget(e,t=!1){if(!this.adaptToSurface||this.isDestroyed)return;let o=e instanceof HTMLElement?e:null,i=performance.now();if(!t&&o===this.lastSurfaceEl&&i-this.lastSurfaceCheckAt<180)return;this.lastSurfaceEl=o,this.lastSurfaceCheckAt=i;let s=Pt(o,this.container);if(!s){this.isSurfaceAdapted&&(this.isSurfaceAdapted=!1,this.lastSurfaceKey="",this.startPaletteTween(this.basePaletteRgb,220));return}let n=`${Math.round(s[0]*255)},${Math.round(s[1]*255)},${Math.round(s[2]*255)}`;if(!t&&n===this.lastSurfaceKey)return;this.lastSurfaceKey=n;let l=this.rawBasePaletteRgb.length>0?this.rawBasePaletteRgb:this.basePaletteRgb;if(l.length===0)return;let a=Dt(l,[s[0],s[1],s[2]]);this.isSurfaceAdapted=!0,this.startPaletteTween(a,220)}parseColorList(e){if(!e)return[];let t=Array.isArray(e)?e:String(e).split(",").map(s=>s.trim()).filter(Boolean);if(t.length===0)return[];let o=te(t[0],"#6366f1"),i=[];for(let s=0;s<t.length;s++){let n=te(t[s],o),l=J.hexToVec3Into(n,J.scratchVec3);i.push([l[0],l[1],l[2]])}return i}parseScrollStops(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let o=0;o<e.length;o++){let i=e[o],s=Array.isArray(i)?i[0]:i;if(typeof s=="string"&&s.trim()){let n=te(s,"#6366f1"),l=J.hexToVec3Into(n,J.scratchVec3);t.push([l[0],l[1],l[2]])}}return t}detectDarkTheme(e){return e==="dark"?!0:e==="light"?!1:kt(this.container)}resolveTargetPalette(e){let t=e?this.parseColorList(this.options.darkColors):this.parseColorList(this.options.lightColors);if(t.length>0)return t;let o=this.parseColorList(this.options.colors);return o.length>0?st(o,e):this.basePaletteRgb}toTriplet(e){let t=e[0]??[.39,.4,.95],o=e[1]??t,i=e[2]??o;return[[t[0],t[1],t[2]],[o[0],o[1],o[2]],[i[0],i[1],i[2]]]}pushUniformBatch(e){if(!this.isDestroyed){for(let[t,o]of Object.entries(e))this.customUniforms.set(t,o);if(this.isBudgetSuspended){this.applyBudgetFallbackStyle();return}this.isOffscreen&&this.worker?this.worker.postMessage({type:"uniformsBatch",uniforms:e}):this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport&&this.drawMainThreadFrame()}}startThemeTransition(e){this.themeTweenRaf&&(cancelAnimationFrame(this.themeTweenRaf),this.themeTweenRaf=0);let t=e?1:0,o=this.resolveTargetPalette(e);o.length>0&&(this.basePaletteRgb=o);let i=this.currentTheme,s=this.toTriplet(this.activePaletteRgb.length>0?this.activePaletteRgb:this.basePaletteRgb),n=this.toTriplet(this.basePaletteRgb);if(this.isReducedMotion||typeof requestAnimationFrame!="function"){this.currentTheme=t,this.activePaletteRgb=n,this.pushUniformBatch({uTheme:t,uColor1:n[0],uColor2:n[1],uColor3:n[2]});return}let l=performance.now(),a=280;this.boostInteraction(500);let u=c=>{if(this.isDestroyed){this.themeTweenRaf=0;return}let f=Math.min(1,(c-l)/a),m=f<.5?2*f*f:1-Math.pow(-2*f+2,2)/2;this.currentTheme=i+(t-i)*m;let p=(x,y)=>[x[0]+(y[0]-x[0])*m,x[1]+(y[1]-x[1])*m,x[2]+(y[2]-x[2])*m],h=p(s[0],n[0]),v=p(s[1],n[1]),g=p(s[2],n[2]);this.activePaletteRgb=[h,v,g],this.pushUniformBatch({uTheme:this.currentTheme,uColor1:h,uColor2:v,uColor3:g}),f<1?this.themeTweenRaf=requestAnimationFrame(u):(this.themeTweenRaf=0,this.scrollStopsRgb.length>=2&&(this.lastScrollColorT=-1,this.updateScrollColorShift(this.computeScrollProgress())))};this.themeTweenRaf=requestAnimationFrame(u)}bindThemeWatchers(){if(this.unbindThemeWatchers(),!(typeof window>"u"||typeof document>"u")&&(typeof window.matchMedia=="function"&&(this.colorSchemeQuery=window.matchMedia("(prefers-color-scheme: dark)"),typeof this.colorSchemeQuery.addEventListener=="function"&&this.colorSchemeQuery.addEventListener("change",this.handleThemeChange)),typeof MutationObserver<"u")){this.themeMutationObserver=new MutationObserver(this.handleThemeChange);let e=["class","data-theme","data-mode","data-bs-theme","style"];this.themeMutationObserver.observe(document.documentElement,{attributes:!0,attributeFilter:e}),document.body&&this.themeMutationObserver.observe(document.body,{attributes:!0,attributeFilter:e}),this.container!==document.body&&this.container!==document.documentElement&&this.themeMutationObserver.observe(this.container,{attributes:!0,attributeFilter:e})}}unbindThemeWatchers(){this.themeTweenRaf&&(cancelAnimationFrame(this.themeTweenRaf),this.themeTweenRaf=0),this.colorSchemeQuery&&typeof this.colorSchemeQuery.removeEventListener=="function"&&this.colorSchemeQuery.removeEventListener("change",this.handleThemeChange),this.colorSchemeQuery=null,this.themeMutationObserver?.disconnect(),this.themeMutationObserver=null}updateScrollColorShift(e){if(this.scrollStopsRgb.length<2)return;let t=Math.min(1,Math.max(0,e));if(Math.abs(t-this.lastScrollColorT)<.002)return;this.lastScrollColorT=t;let o=st(this.scrollStopsRgb,this.resolvedDarkTheme),i=o.length-1,s=t*i,n=Math.min(i-1,Math.floor(s)),l=s-n,a=o[n],u=o[n+1],c=o[Math.min(o.length-1,n+2)]??a,f=[a[0]+(u[0]-a[0])*l,a[1]+(u[1]-a[1])*l,a[2]+(u[2]-a[2])*l],m=[u[0]+(c[0]-u[0])*l,u[1]+(c[1]-u[1])*l,u[2]+(c[2]-u[2])*l],p=this.basePaletteRgb[2]??c;this.activePaletteRgb=[f,m,p],this.pushUniformBatch({uColor1:f,uColor2:m,uColor3:p})}syncScrollColorListener(){if(typeof window>"u")return;let e=this.scrollStopsRgb.length>=2;e&&!this.hasScrollColorListener?(window.addEventListener("scroll",this.handleScrollColorEvent,{passive:!0}),this.hasScrollColorListener=!0,this.lastScrollColorT=-1,this.updateScrollColorShift(this.computeScrollProgress())):!e&&this.hasScrollColorListener&&(window.removeEventListener("scroll",this.handleScrollColorEvent),this.hasScrollColorListener=!1,this.scrollColorRaf&&(cancelAnimationFrame(this.scrollColorRaf),this.scrollColorRaf=0))}getLocalTouchCoords(e){let t=this.container.getBoundingClientRect();if(t.width<=0||t.height<=0)return null;let o=(e.clientX-t.left)/t.width,i=1-(e.clientY-t.top)/t.height;return o<0||o>1||i<0||i>1?null:[o,i]}syncTouchListener(){typeof window>"u"||(this.interactive&&!this.hasTouchListener?(this.container.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),this.container.addEventListener("touchmove",this.handleTouchMove,{passive:!0}),this.container.addEventListener("touchend",this.handleTouchEnd,{passive:!0}),this.container.addEventListener("touchcancel",this.handleTouchEnd,{passive:!0}),this.hasTouchListener=!0):!this.interactive&&this.hasTouchListener&&(this.container.removeEventListener("touchstart",this.handleTouchStart),this.container.removeEventListener("touchmove",this.handleTouchMove),this.container.removeEventListener("touchend",this.handleTouchEnd),this.container.removeEventListener("touchcancel",this.handleTouchEnd),this.hasTouchListener=!1))}seedUniformsFromOptions(e,t=!1){let o={};if(typeof e.speed=="number"?(this.targetSpeed=e.speed,t&&(this.currentSpeed=e.speed),this.customUniforms.set("uSpeed",e.speed),o.uSpeed=e.speed):this.customUniforms.has("uSpeed")||(this.targetSpeed=1,this.currentSpeed=1,this.customUniforms.set("uSpeed",1),o.uSpeed=1),t||e.quality!==void 0){let l=this.computeEffectiveQuality();this.customUniforms.set("uQuality",l),o.uQuality=l}e.scrollColors!==void 0&&(this.scrollStopsRgb=this.parseScrollStops(e.scrollColors),this.lastScrollColorT=-1);let i=this.resolvedDarkTheme;e.theme!==void 0&&(this.themeMode=e.theme);let s=this.detectDarkTheme(this.themeMode);if(this.resolvedDarkTheme=s,t&&(this.currentTheme=s?1:0,this.customUniforms.set("uTheme",this.currentTheme),o.uTheme=this.currentTheme),t||e.colors!==void 0||e.lightColors!==void 0||e.darkColors!==void 0||e.theme!==void 0||e.scrollColors!==void 0){let l=this.parseColorList(this.options.colors);l.length>0&&(this.rawBasePaletteRgb=l);let a=this.resolveTargetPalette(s);if(a.length>0)if(this.basePaletteRgb=a,this.rawBasePaletteRgb.length===0&&(this.rawBasePaletteRgb=a),!t&&s!==i)this.startThemeTransition(s);else{let[u,c,f]=this.toTriplet(a);this.activePaletteRgb=[u,c,f],this.customUniforms.set("uColor1",u),this.customUniforms.set("uColor2",c),this.customUniforms.set("uColor3",f),o.uColor1=u,o.uColor2=c,o.uColor3=f,t||(this.currentTheme=s?1:0,this.customUniforms.set("uTheme",this.currentTheme),o.uTheme=this.currentTheme)}}if(e.uniforms)for(let[l,a]of Object.entries(e.uniforms))this.customUniforms.set(l,a),o[l]=typeof a=="number"?a:Array.from(a);return this.shouldPreserveBg()&&(this.customUniforms.set("uTransparentBg",1),o.uTransparentBg=1),o}fallbackToMainThread(e,t,o,i){if(this.isDestroyed)return;this.worker&&(this.worker.terminate(),this.worker=null),this.isOffscreen=!1,this.resetFrameTracking(),this.markContextReleased();let s=this.canvas.cloneNode(!1);this.canvas.replaceWith(s),this.canvas=s,this.initMainThreadMode(e,t,o,i)}initOffscreenMode(e,t,o,i){try{let s=At(),n=this.canvas.transferControlToOffscreen();this.worker=s,this.isOffscreen=!0,this.markContextActive(),s.onmessage=a=>{if(a.data?.type==="error")this.fallbackToMainThread(e,t,o,i);else if(a.data?.type==="stats"){this.reportedFps=typeof a.data.fps=="number"?a.data.fps:0,this.reportedFrameTimeMs=typeof a.data.frameTimeMs=="number"?a.data.frameTimeMs:0;let u=typeof a.data.targetFps=="number"?a.data.targetFps:0;this.reportedFrameTimeMs>0&&u>0&&Te.recordGpuFrame(this.reportedFrameTimeMs,u,performance.now())}else a.data?.type==="needTextures"&&this.reuploadLoadedTextures()},s.onerror=()=>{this.fallbackToMainThread(e,t,o,i)};let l={};this.customUniforms.forEach((a,u)=>{l[u]=typeof a=="number"?a:Array.from(a)}),s.postMessage({type:"init",canvas:n,width:this.width,height:this.height,minDpr:t,maxDpr:o,dynamicRes:i,reducedMotion:this.isReducedMotion,vertexShader:e.vertexShader??Bt,fragmentShader:e.fragmentShader,feedbackShader:e.feedbackShader??null,feedbackScale:this.feedbackScale,feedbackMaxDim:this.feedbackMaxDim,feedbackFloat:this.feedbackFloat,initialScroll:this.scroll,ambientFps:this.ambientFps,activeFps:this.activeFps,survivalPaused:this.isSurvivalSuspended,uniforms:l},[n])}catch{this.isOffscreen=!1,this.markContextReleased(),this.initMainThreadMode(e,t,o,i)}}computeFboDimsMain(e,t){let o=Math.max(1,Math.floor(e*this.feedbackScale)),i=Math.max(1,Math.floor(t*this.feedbackScale)),s=Math.max(o,i);if(s>this.feedbackMaxDim){let n=this.feedbackMaxDim/s;o=Math.max(1,Math.floor(o*n)),i=Math.max(1,Math.floor(i*n))}return[o,i]}destroyPingPongMain(){if(!this.pingPong||!this.gl){this.pingPong=null;return}for(let e=0;e<2;e++)this.gl.deleteFramebuffer(this.pingPong[e].fbo),this.gl.deleteTexture(this.pingPong[e].tex);this.pingPong=null}createPingPongMain(e){if(this.destroyPingPongMain(),!this.options.feedbackShader||this.isContextLost)return;let[t,o]=this.computeFboDimsMain(this.canvas.width,this.canvas.height);this.fboW=t,this.fboH=o;let i=e.RGBA8,s=e.UNSIGNED_BYTE;this.feedbackFloat&&(e.getExtension("EXT_color_buffer_float")||e.getExtension("EXT_color_buffer_half_float"))&&(i=e.RGBA16F,s=e.HALF_FLOAT);let l=(u,c)=>{let f=[];for(let m=0;m<2;m++){let p=e.createTexture(),h=e.createFramebuffer();if(!p||!h)return p&&e.deleteTexture(p),h&&e.deleteFramebuffer(h),f.forEach(v=>{e.deleteFramebuffer(v.fbo),e.deleteTexture(v.tex)}),null;if(e.bindTexture(e.TEXTURE_2D,p),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,u,this.fboW,this.fboH,0,e.RGBA,c,null),e.bindFramebuffer(e.FRAMEBUFFER,h),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,p,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return e.deleteFramebuffer(h),e.deleteTexture(p),f.forEach(v=>{e.deleteFramebuffer(v.fbo),e.deleteTexture(v.tex)}),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),null;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),f.push({fbo:h,tex:p})}return e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),[f[0],f[1]]},a=l(i,s);!a&&i!==e.RGBA8&&(i=e.RGBA8,s=e.UNSIGNED_BYTE,a=l(i,s)),this.fboFormat=i,this.fboType=s,this.pingPong=a,this.readIdx=0,this.writeIdx=1}resizePingPongMain(){if(!this.pingPong||!this.gl||this.isContextLost)return;let[e,t]=this.computeFboDimsMain(this.canvas.width,this.canvas.height);if(e===this.fboW&&t===this.fboH)return;let o=this.gl,i=this.fboW,s=this.fboH,n=this.pingPong[this.readIdx],l=[];for(let a=0;a<2;a++){let u=o.createTexture(),c=o.createFramebuffer();o.bindTexture(o.TEXTURE_2D,u),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texImage2D(o.TEXTURE_2D,0,this.fboFormat,e,t,0,o.RGBA,this.fboType,null),o.bindFramebuffer(o.FRAMEBUFFER,c),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,u,0),l.push({fbo:c,tex:u})}o.bindFramebuffer(o.READ_FRAMEBUFFER,n.fbo),o.bindFramebuffer(o.DRAW_FRAMEBUFFER,l[0].fbo),o.blitFramebuffer(0,0,i,s,0,0,e,t,o.COLOR_BUFFER_BIT,o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,null),o.bindFramebuffer(o.DRAW_FRAMEBUFFER,null),o.bindTexture(o.TEXTURE_2D,null);for(let a=0;a<2;a++)o.deleteFramebuffer(this.pingPong[a].fbo),o.deleteTexture(this.pingPong[a].tex);this.pingPong=[l[0],l[1]],this.fboW=e,this.fboH=t,this.readIdx=0,this.writeIdx=1}initMainThreadPipeline(e){let t=this.options.vertexShader??Je;this.programEntry=j.getOrCreateProgram(e,this.options.fragmentShader,t),this.options.feedbackShader?this.feedbackProgramEntry=j.getOrCreateProgram(e,this.options.feedbackShader,t):this.feedbackProgramEntry=null,this.vao=e.createVertexArray(),e.bindVertexArray(this.vao),this.vbo=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vbo),e.bufferData(e.ARRAY_BUFFER,Tr,e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),this.needsResize=!1,this.applyCanvasSize(),this.options.feedbackShader&&this.createPingPongMain(e)}initMainThreadMode(e,t,o,i){let s=null,n=ie.acquireRecycledMainContext();if(n?(n.canvas.style.background="",this.canvas.replaceWith(n.canvas),this.canvas=n.canvas,s=n.gl):s=this.canvas.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1}),!s){console.warn("[FluxFX] WebGL2 is not supported on this device."),this.isBudgetSuspended=!0,this.applyBudgetFallbackStyle();return}this.gl=s,this.markContextActive(),this.canvas.addEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.addEventListener("webglcontextrestored",this.handleContextRestored,!1),this.dynamicRes=new ot({minScale:i?t:o,maxScale:o}),this.initMainThreadPipeline(s),this.reuploadLoadedTextures(),this.drawMainThreadFrame()}applyCanvasSize(){if(!this.gl||!this.dynamicRes||this.isContextLost)return;let e=this.dynamicRes.scale,t=Math.max(1,Math.round(this.width*e)),o=Math.max(1,Math.round(this.height*e));(this.canvas.width!==t||this.canvas.height!==o)&&(this.canvas.width=t,this.canvas.height=o,this.gl.viewport(0,0,t,o)),this.pingPong&&this.resizePingPongMain()}bindCommonUniformsMain(e,t,o,i){let s=j.getUniformLocation(e,t,"uTime");s&&e.uniform1f(s,this.elapsedSec);let n=j.getUniformLocation(e,t,"uDelta");n&&e.uniform1f(n,this.lastDeltaSec);let l=j.getUniformLocation(e,t,"uResolution");l&&e.uniform2f(l,o,i);let a=j.getUniformLocation(e,t,"uCanvasResolution");a&&e.uniform2f(a,this.canvas.width,this.canvas.height);let u=j.getUniformLocation(e,t,"uDpr");u&&this.dynamicRes&&e.uniform1f(u,this.dynamicRes.scale);let c=j.getUniformLocation(e,t,"uMouse");c&&e.uniform2f(c,this.mouse[0],this.mouse[1]);let f=j.getUniformLocation(e,t,"uMouseVel");f&&e.uniform2f(f,this.mouseVel[0],this.mouseVel[1]);let m=j.getUniformLocation(e,t,"uMouseDown");m&&e.uniform1f(m,this.mouseDown);let p=j.getUniformLocation(e,t,"uMouseActive");p&&e.uniform1f(p,this.mouseActive);let h=j.getUniformLocation(e,t,"uScroll");h&&e.uniform1f(h,this.scroll);let v=j.getUniformLocation(e,t,"uScrollVel");v&&e.uniform1f(v,this.scrollVel),this.customUniforms.forEach((g,x)=>{let y=j.getUniformLocation(e,t,x);y&&(x==="uSpeed"?e.uniform1f(y,this.currentSpeed):typeof g=="number"?e.uniform1f(y,g):g.length===2?e.uniform2f(y,g[0],g[1]):g.length===3?e.uniform3f(y,g[0],g[1],g[2]):g.length===4&&e.uniform4f(y,g[0],g[1],g[2],g[3]))})}drawMainThreadFrame(){if(!this.gl||!this.programEntry||this.isContextLost)return;let e=this.gl;if(e.bindVertexArray(this.vao),this.feedbackProgramEntry&&this.pingPong){e.bindFramebuffer(e.FRAMEBUFFER,this.pingPong[this.writeIdx].fbo),e.viewport(0,0,this.fboW,this.fboH),e.useProgram(this.feedbackProgramEntry.program),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.pingPong[this.readIdx].tex);let t=j.getUniformLocation(e,this.feedbackProgramEntry,"uPrevFrame");t&&e.uniform1i(t,0),this.bindMainTextures(e,this.feedbackProgramEntry),this.bindCommonUniformsMain(e,this.feedbackProgramEntry,this.fboW,this.fboH),e.drawArrays(e.TRIANGLES,0,3);let o=this.readIdx;this.readIdx=this.writeIdx,this.writeIdx=o,e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,this.canvas.width,this.canvas.height)}if(e.useProgram(this.programEntry.program),this.pingPong){e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.pingPong[this.readIdx].tex);let t=j.getUniformLocation(e,this.programEntry,"uFeedback");t&&e.uniform1i(t,0);let o=j.getUniformLocation(e,this.programEntry,"uPrevFrame");o&&e.uniform1i(o,0)}this.bindMainTextures(e,this.programEntry),this.bindCommonUniformsMain(e,this.programEntry,this.canvas.width,this.canvas.height),e.drawArrays(e.TRIANGLES,0,3)}render(e,t){if(this.isOffscreen||this.isPaused||this.isHiddenByViewport||this.isReducedMotion||this.isContextLost||this.isSurvivalSuspended||this.isBudgetSuspended||this.isDestroyed||!this.gl||!this.programEntry)return;let o=performance.now(),i=this.lastRenderNow?Math.min(o-this.lastRenderNow,100):16.67;this.lastRenderNow=o,this.prevFrameDrew&&(this.dynamicRes&&this.dynamicRes.recordFrame(i,o)&&(this.needsResize=!0),this.prevFrameDrew=!1);let n=o<this.boostUntil||this.mouseDown>.5?this.activeFps:this.ambientFps,l=1e3/n-2;if(this.lastDrawNow>0&&o-this.lastDrawNow<l)return;let a=this.lastDrawNow?o-this.lastDrawNow:1e3/n,u=Math.min(a,100);this.lastDrawNow=o,n!==this.lastTargetFps?(this.lastTargetFps=n,this.avgDrawDeltaMs=0):a>0&&a<500&&(this.avgDrawDeltaMs=this.avgDrawDeltaMs===0?a:this.avgDrawDeltaMs*.85+a*.15),this.avgDrawDeltaMs>0&&(this.reportedFps=Math.round(1e3/this.avgDrawDeltaMs),this.reportedFrameTimeMs=Math.round(this.avgDrawDeltaMs*100)/100),a>0&&a<500&&Te.recordGpuFrame(a,n,o);let c=Math.max(.001,Math.min(u*.001,.05));if(this.lastDeltaSec=c,this.currentSpeed+=(this.targetSpeed-this.currentSpeed)*nt(7.5,c),this.elapsedSec+=c*this.currentSpeed,this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.mouseActive+=(this.targetMouseActive-this.mouseActive)*nt(7,c),this.mouseActive<.001&&this.targetMouseActive===0&&(this.mouseActive=0),this.targetMouseActive>.5){let f=this.mouse[0],m=this.mouse[1],p=nt(13,c);this.mouse[0]+=(this.targetMouse[0]-this.mouse[0])*p,this.mouse[1]+=(this.targetMouse[1]-this.mouse[1])*p,this.mouseVel[0]=Math.max(-8,Math.min(8,(this.mouse[0]-f)/c)),this.mouseVel[1]=Math.max(-8,Math.min(8,(this.mouse[1]-m)/c))}else this.mouseVel[0]=0,this.mouseVel[1]=0;if(this.trackScroll){let f=this.scroll;this.scroll+=(this.targetScroll-this.scroll)*nt(9.5,c),this.scrollVel=Math.max(-6,Math.min(6,(this.scroll-f)/c))}this.drawMainThreadFrame(),this.prevFrameDrew=!0}applyProtectionState(){if(this.isDestroyed||this.isBudgetSuspended)return;let e=this.resolveTierConfig(),{minDpr:t,maxDpr:o}=this.resolveDprBounds(),s=this.options.dynamicResolution??!0?t:o,n=this.isSurvivalSuspended,l=this.feedbackMaxDim;this.ambientFps=e.ambientFps,this.activeFps=e.activeFps,this.feedbackMaxDim=e.feedbackMaxDim,this.isSurvivalSuspended=e.suspended,this.isSurvivalSuspended&&!n&&this.resetFrameTracking(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"protection",minDpr:s,maxDpr:o,feedbackMaxDim:this.feedbackMaxDim,ambientFps:this.ambientFps,activeFps:this.activeFps,suspended:this.isSurvivalSuspended}):((this.dynamicRes?.setBounds(s,o)??!1)||l!==this.feedbackMaxDim)&&(this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport?(this.needsResize=!1,this.applyCanvasSize(),this.drawMainThreadFrame()):this.needsResize=!0),n!==this.isSurvivalSuspended&&this.wakeCallback?.()}syncDprBounds(){this.applyProtectionState()}watchDevicePixelRatio(){if(this.dprMediaQuery&&(this.dprMediaQuery.removeEventListener("change",this.handleDprChange),this.dprMediaQuery=null),typeof window>"u"||typeof window.matchMedia!="function")return;let e=window.devicePixelRatio||1;this.dprMediaQuery=window.matchMedia(`(resolution: ${e}dppx)`),this.dprMediaQuery.addEventListener("change",this.handleDprChange)}updateOptions(e){if(this.isDestroyed)return;let t=this.options.quality;this.options={...this.options,...e},e.layer!==void 0&&(this.layerMode=e.layer),(e.layer!==void 0||e.overlayOpacity!==void 0)&&this.applyCanvasLayerStyle(),typeof e.adaptToSurface=="boolean"&&(this.adaptToSurface=e.adaptToSurface,!this.adaptToSurface&&this.isSurfaceAdapted&&(this.isSurfaceAdapted=!1,this.lastSurfaceEl=null,this.lastSurfaceKey="",this.startPaletteTween(this.basePaletteRgb,200)));let o=this.seedUniformsFromOptions(e,!1);if(e.preserveBg!==void 0||e.layer!==void 0){let s=this.shouldPreserveBg()?1:Number(this.customUniforms.get("uTransparentBg")??0);this.customUniforms.set("uTransparentBg",s),o.uTransparentBg=s}if(this.boostInteraction(1200),e.quality!==void 0&&e.quality!==t){let i=Xe[e.quality]??Xe.medium;this.baseFeedbackMaxDim=this.options.feedbackMaxDim??i.fboMaxDim}if(e.feedbackMaxDim!==void 0&&(this.baseFeedbackMaxDim=e.feedbackMaxDim),(e.quality!==void 0&&e.quality!==t||e.feedbackMaxDim!==void 0||e.minDpr!==void 0||e.maxDpr!==void 0||e.dynamicResolution!==void 0)&&this.syncDprBounds(),typeof e.interactive=="boolean"&&e.interactive!==this.interactive&&(this.interactive=e.interactive,this.syncPointerListener(),this.syncTouchListener()),typeof e.trackScroll=="boolean"&&e.trackScroll!==this.trackScroll&&(this.trackScroll=e.trackScroll,this.syncScrollListener()),e.scrollColors!==void 0&&this.syncScrollColorListener(),typeof e.respectReducedMotion=="boolean"){this.respectReducedMotion=e.respectReducedMotion;let i=this.reducedMotionQuery?.matches??!1;this.applyReducedMotionState(this.respectReducedMotion&&i)}if(this.isBudgetSuspended){this.applyBudgetFallbackStyle();return}this.isOffscreen&&this.worker?Object.keys(o).length>0&&this.worker.postMessage({type:"uniformsBatch",uniforms:o}):this.isReducedMotion&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame()),e.textures!==void 0&&this.syncTexturesFromOptions(e.textures)}applyReducedMotionState(e){this.isReducedMotion!==e&&(this.isReducedMotion=e,this.resetFrameTracking(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"reducedMotion",value:e}):e&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame()),this.wakeCallback?.())}getLocalPointerCoords(e){let t=this.container.getBoundingClientRect();if(t.width<=0||t.height<=0||e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)return null;let o=(e.clientX-t.left)/t.width,i=1-(e.clientY-t.top)/t.height;return[o,i]}syncInteractiveAttr(){if(this.interactive&&!this.isDestroyed){this.container.setAttribute("data-fluxfx-interactive","true");return}let e=!1;ie.instances.forEach(t=>{t!==this&&!t.isDestroyed&&t.interactive&&t.container===this.container&&(e=!0)}),e||this.container.removeAttribute("data-fluxfx-interactive")}isShadowedByChildInteractive(e){if(!(e instanceof Element))return!1;let t=e.closest('[data-fluxfx-interactive="true"]');return!!(t&&t!==this.container&&this.container.contains(t))}syncPointerListener(){this.syncInteractiveAttr(),this.interactive&&!this.hasPointerListener?(this.container.addEventListener("pointerenter",this.handlePointerEnter,{passive:!0}),this.container.addEventListener("pointermove",this.handlePointerMove,{passive:!0}),this.container.addEventListener("pointerleave",this.handlePointerLeave,{passive:!0}),this.container.addEventListener("pointerdown",this.handlePointerDown,{passive:!0}),window.addEventListener("pointerup",this.handlePointerUp,{passive:!0}),window.addEventListener("pointercancel",this.handlePointerUp,{passive:!0}),this.hasPointerListener=!0):!this.interactive&&this.hasPointerListener&&(this.container.removeEventListener("pointerenter",this.handlePointerEnter),this.container.removeEventListener("pointermove",this.handlePointerMove),this.container.removeEventListener("pointerleave",this.handlePointerLeave),this.container.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp),this.handlePointerLeave(),this.hasPointerListener=!1)}syncScrollListener(){this.trackScroll&&!this.hasScrollListener?(window.addEventListener("scroll",this.handleScroll,{passive:!0}),this.hasScrollListener=!0,this.handleScroll()):!this.trackScroll&&this.hasScrollListener&&(window.removeEventListener("scroll",this.handleScroll),this.hasScrollListener=!1)}bindObservers(e){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(t=>{let o=t[0];if(!o)return;let i=Math.max(1,Math.floor(o.contentRect.width)),s=Math.max(1,Math.floor(o.contentRect.height));i===this.width&&s===this.height||(this.width=i,this.height=s,this.boostInteraction(600),this.trackScroll&&this.handleScroll(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"resize",width:this.width,height:this.height}):this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport?(this.needsResize=!1,this.applyCanvasSize(),this.drawMainThreadFrame()):this.needsResize=!0)}),this.resizeObserver.observe(this.container)),e&&typeof IntersectionObserver<"u"&&(this.visibilityObserver=new IntersectionObserver(t=>{let o=t[0]?.isIntersecting??!0;if(this.isHiddenByViewport=!o,o){if(this.lastActiveAt=Ze(),this.isBudgetSuspended&&!this.isPaused){this.restoreContextFromBudget();return}}else this.handlePointerLeave(),this.resetFrameTracking();this.isOffscreen&&this.worker&&this.worker.postMessage({type:o&&!this.isPaused?"resume":"pause"}),this.wakeCallback?.()},{rootMargin:"50px"}),this.visibilityObserver.observe(this.container)),this.reducedMotionQuery&&this.reducedMotionQuery.addEventListener("change",this.handleReducedMotionChange),this.isOffscreen&&typeof document<"u"&&document.addEventListener("visibilitychange",this.handleDocVisibility),this.watchDevicePixelRatio(),this.bindThemeWatchers(),this.syncPointerListener(),this.syncTouchListener(),this.syncScrollListener(),this.syncScrollColorListener()}setUniform(e,t){if(!this.isDestroyed){if(this.customUniforms.set(e,t),e==="uSpeed"&&typeof t=="number"&&(this.targetSpeed=t),this.boostInteraction(1200),this.isBudgetSuspended){this.applyBudgetFallbackStyle();return}this.isOffscreen&&this.worker?this.worker.postMessage({type:"uniform",name:e,value:typeof t=="number"?t:Array.from(t)}):this.isReducedMotion&&this.drawMainThreadFrame()}}setColor(e,t){let o=te(t,"#ffffff"),i=J.hexToVec3Into(o,J.scratchVec3);this.setUniform(e,[i[0],i[1],i[2]])}get isIdle(){return this.isDestroyed||this.isPaused||this.isHiddenByViewport||this.isReducedMotion||this.isContextLost}onWake(e){this.wakeCallback=e}pause(){this.isPaused||this.isDestroyed||(this.isPaused=!0,this.resetFrameTracking(),this.handlePointerLeave(),this.isOffscreen&&this.worker&&this.worker.postMessage({type:"pause"}))}resume(){if(!(!this.isPaused||this.isDestroyed)){if(this.isPaused=!1,this.lastRenderNow=0,this.lastDrawNow=0,this.lastActiveAt=Ze(),this.isBudgetSuspended&&!this.isHiddenByViewport){this.restoreContextFromBudget();return}this.isOffscreen&&this.worker&&!this.isHiddenByViewport?this.worker.postMessage({type:"resume"}):this.isReducedMotion&&!this.isHiddenByViewport&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame())}}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.wakeCallback=null,this.unsubscribeGuard?.(),this.unsubscribeGuard=null,this.unbindThemeWatchers(),this.touchBurstTimer&&(window.clearTimeout(this.touchBurstTimer),this.touchBurstTimer=0),this.touchLeaveTimer&&(window.clearTimeout(this.touchLeaveTimer),this.touchLeaveTimer=0),this.hasTouchListener&&(this.container.removeEventListener("touchstart",this.handleTouchStart),this.container.removeEventListener("touchmove",this.handleTouchMove),this.container.removeEventListener("touchend",this.handleTouchEnd),this.container.removeEventListener("touchcancel",this.handleTouchEnd),this.hasTouchListener=!1),this.hasScrollColorListener&&(window.removeEventListener("scroll",this.handleScrollColorEvent),this.hasScrollColorListener=!1),this.scrollColorRaf&&(cancelAnimationFrame(this.scrollColorRaf),this.scrollColorRaf=0),this.isBodyMount&&(this.container.style.minHeight=this.origBodyMinHeight),ie.instances.delete(this),this.syncInteractiveAttr(),this.resetFrameTracking(),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.visibilityObserver?.disconnect(),this.visibilityObserver=null,this.reducedMotionQuery&&(this.reducedMotionQuery.removeEventListener("change",this.handleReducedMotionChange),this.reducedMotionQuery=null),this.dprMediaQuery&&(this.dprMediaQuery.removeEventListener("change",this.handleDprChange),this.dprMediaQuery=null),typeof document<"u"&&document.removeEventListener("visibilitychange",this.handleDocVisibility),this.hasPointerListener&&(this.container.removeEventListener("pointerenter",this.handlePointerEnter),this.container.removeEventListener("pointermove",this.handlePointerMove),this.container.removeEventListener("pointerleave",this.handlePointerLeave),this.container.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp),this.hasPointerListener=!1),this.hasScrollListener&&(window.removeEventListener("scroll",this.handleScroll),this.hasScrollListener=!1),this.canvas.removeEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.removeEventListener("webglcontextrestored",this.handleContextRestored,!1),this.isOffscreen&&this.worker&&(this.worker.postMessage({type:"destroy"}),this.worker=null),this.releaseMainThreadContext(!1),this.markContextReleased(),J.releaseVec2(this.mouse),J.releaseVec2(this.targetMouse),J.releaseVec2(this.mouseVel),this.customUniforms.clear(),this.textureUrls.clear(),this.textureUnits.clear(),this.loadedImages.clear(),this.textureLoadTokens.clear(),ie.reclaimBudgetForWaiting())}resolveTextureUrl(e){let t=e.trim();if(!t)return"";if(/^(data:|blob:)/i.test(t)||typeof window>"u")return t;try{return new URL(t,window.location.href).href}catch{return t}}destroyMainTextures(){if(!this.gl||this.mainTextures.size===0){this.mainTextures.clear();return}let e=this.gl;this.mainTextures.forEach(t=>{e.deleteTexture(t.tex)}),this.mainTextures.clear()}bindMainTextures(e,t){this.mainTextures.size!==0&&this.mainTextures.forEach((o,i)=>{let s=j.getUniformLocation(e,t,i);s&&(e.activeTexture(e.TEXTURE0+o.unit),e.bindTexture(e.TEXTURE_2D,o.tex),e.uniform1i(s,o.unit))})}uploadImageTexture(e,t,o,i){if(this.isDestroyed)return;let s=this.textureUnits.get(e);s===void 0&&(s=this.nextTextureUnit++,this.textureUnits.set(e,s));let n=`${e}Size`,l=`${e}Ready`;if(this.customUniforms.set(n,[o,i]),this.customUniforms.set(l,1),this.isOffscreen&&this.worker&&typeof createImageBitmap=="function"){createImageBitmap(t).then(a=>{if(this.isDestroyed||!this.isOffscreen||!this.worker){a.close();return}this.worker.postMessage({type:"texture",name:e,unit:s,bitmap:a,width:o,height:i},[a]),this.boostInteraction(600),this.wakeCallback?.()}).catch(()=>{});return}if(this.gl&&!this.isContextLost){let a=this.gl,c=this.mainTextures.get(e)?.tex??null;c||(c=a.createTexture()),c&&(a.activeTexture(a.TEXTURE0+s),a.bindTexture(a.TEXTURE_2D,c),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,t),a.bindTexture(a.TEXTURE_2D,null),this.mainTextures.set(e,{unit:s,tex:c}),this.pushUniformBatch({[n]:[o,i],[l]:1}),this.boostInteraction(600),this.wakeCallback?.(),!this.isPaused&&!this.isHiddenByViewport&&this.drawMainThreadFrame())}}reuploadLoadedTextures(){this.loadedImages.forEach((e,t)=>{this.uploadImageTexture(t,e.img,e.width,e.height)})}clearTextureSlot(e){if(this.textureUrls.delete(e),this.loadedImages.delete(e),this.textureLoadTokens.set(e,(this.textureLoadTokens.get(e)??0)+1),this.customUniforms.set(`${e}Ready`,0),this.isOffscreen&&this.worker)this.worker.postMessage({type:"clearTexture",name:e});else if(this.gl&&!this.isContextLost){let t=this.mainTextures.get(e);t&&(this.gl.deleteTexture(t.tex),this.mainTextures.delete(e)),this.pushUniformBatch({[`${e}Ready`]:0})}}syncTexturesFromOptions(e){if(!(!e||typeof window>"u"||typeof Image>"u"))for(let[t,o]of Object.entries(e)){let i=o?this.resolveTextureUrl(o):"",s=this.textureUrls.get(t)??"";if(!i){s?this.clearTextureSlot(t):this.customUniforms.set(`${t}Ready`,0);continue}if(i===s)continue;this.textureUrls.set(t,i),this.customUniforms.has(`${t}Ready`)||this.customUniforms.set(`${t}Ready`,0);let n=(this.textureLoadTokens.get(t)??0)+1;this.textureLoadTokens.set(t,n);let l=new Image;if(!/^(data:|blob:)/i.test(i))try{new URL(i,window.location.href).origin!==window.location.origin&&(l.crossOrigin="anonymous")}catch{}l.decoding="async",l.onload=()=>{if(this.isDestroyed||this.textureLoadTokens.get(t)!==n)return;let a=l.naturalWidth||l.width||1,u=l.naturalHeight||l.height||1;this.loadedImages.set(t,{url:i,img:l,width:a,height:u}),this.uploadImageTexture(t,l,a,u)},l.onerror=()=>{this.isDestroyed||this.textureLoadTokens.get(t)!==n||console.warn(`[FluxFX] Failed to load texture "${t}" from: ${i}`)},l.src=i}}};ie._activeContexts=0,ie._maxContexts=Ut(),ie.instances=new Set,ie.recycledMainContexts=[];var Me=ie;var at=class{constructor(){this.plugins=new Map;this.activeByElement=new WeakMap;this.activeSet=new Set;this.visibilityObserver=null;this.visibilityCallbacks=new WeakMap;this.removeTicker=null;this.removeVisibilitySub=null;this.hasResizeListener=!1;this.resizeRaf=0;this.handleViewportResize=()=>{this.resizeRaf||(this.resizeRaf=requestAnimationFrame(()=>{this.resizeRaf=0;let e=!1;this.activeSet.forEach(t=>{if(!this.hasDeviceConstraints(t.options))return;let o=this.isDeviceAllowed(t.options);o&&!t.instance?this.mountEntryInstance(t)&&(e=!0):!o&&t.instance&&(this.unmountEntryInstance(t),e=!0)}),e&&this.syncTickerState()}))}}isDeviceAllowed(e){if(typeof window>"u")return!0;let t=window.innerWidth||document.documentElement?.clientWidth||1024,o=typeof e.mobileBreakpoint=="number"&&e.mobileBreakpoint>0?e.mobileBreakpoint:768;if(e.disableOnMobile&&t<o||e.disableOnDesktop&&t>=o)return!1;let i=typeof e.device=="string"?e.device.trim().toLowerCase():"all";return!(i==="desktop"&&t<o||i==="mobile"&&t>=o||i==="tablet"&&(t<o||t>=1024)||typeof e.minWidth=="number"&&t<e.minWidth||typeof e.maxWidth=="number"&&t>e.maxWidth)}hasDeviceConstraints(e){return!!(e.device&&e.device!=="all"||e.disableOnMobile||e.disableOnDesktop||typeof e.minWidth=="number"||typeof e.maxWidth=="number")}mountEntryInstance(e){if(e.instance)return!0;try{let t=e.plugin.mount(e.el,e.options);return e.instance=t,e.faulted=!1,this.bindWake(e),this.attachEntryObserver(e),(!e.visible||Se.isHidden)&&t.pause?.(),!0}catch(t){return e.faulted=!0,console.error(`[FluxFX] Failed to mount "${e.name}":`,t),!1}}unmountEntryInstance(e){if(e.unobserve?.(),e.unobserve=null,!!e.instance){try{e.instance.destroy()}catch(t){console.error(`[FluxFX] Device toggle cleanup error in "${e.name}":`,t)}e.instance=null,e.visible=!0}}attachEntryObserver(e){if(!(e.options.pauseWhenHidden??!0)||e.unobserve)return;let o=this.ensureObserver();if(!o)return;let i=this.visibilityCallbacks.get(e.el);i||(i=new Set,this.visibilityCallbacks.set(e.el,i),o.observe(e.el));let s=n=>{e.visible=n,e.instance&&(n&&!Se.isHidden?e.instance.resume?.():e.instance.pause?.(),this.syncTickerState())};i.add(s),e.unobserve=()=>{i?.delete(s),i&&i.size===0&&(o.unobserve(e.el),this.visibilityCallbacks.delete(e.el))}}syncResizeWatcher(){if(typeof window>"u")return;let e=!1;this.activeSet.forEach(t=>{!e&&this.hasDeviceConstraints(t.options)&&(e=!0)}),e&&!this.hasResizeListener?(window.addEventListener("resize",this.handleViewportResize,{passive:!0}),this.hasResizeListener=!0):!e&&this.hasResizeListener&&(window.removeEventListener("resize",this.handleViewportResize),this.hasResizeListener=!1,this.resizeRaf&&(cancelAnimationFrame(this.resizeRaf),this.resizeRaf=0))}ensureObserver(){return typeof window>"u"||typeof IntersectionObserver>"u"?null:(this.visibilityObserver||(this.visibilityObserver=new IntersectionObserver(e=>{for(let t=0;t<e.length;t++){let o=e[t],i=this.visibilityCallbacks.get(o.target);i&&i.forEach(s=>s(o.isIntersecting))}},{rootMargin:"50px"})),this.visibilityObserver)}ensureVisibilitySub(){this.removeVisibilitySub||(this.removeVisibilitySub=Se.onVisibilityChange(e=>{this.activeSet.forEach(t=>{t.faulted||!t.instance||(e?t.instance.pause?.():t.visible&&t.instance.resume?.())}),this.syncTickerState()}))}hasActiveTickWork(){let e=!1;return this.activeSet.forEach(t=>{e||!t.visible||t.faulted||!t.instance?.update||t.instance.isIdle?.()||(e=!0)}),e}syncTickerState(){this.hasActiveTickWork()?this.ensureTicker():this.removeTicker&&(this.removeTicker(),this.removeTicker=null)}ensureTicker(){this.removeTicker||(this.removeTicker=Se.add((e,t)=>{let o=!1;this.activeSet.forEach(i=>{if(!(!i.visible||i.faulted||!i.instance?.update)&&!i.instance.isIdle?.()){try{i.instance.update(e,t)}catch(s){i.faulted=!0,console.error(`[FluxFX] Runtime error in "${i.name}" (auto-paused):`,s);return}i.instance.isIdle?.()||(o=!0)}}),o||this.syncTickerState()}))}cleanupEmptyEngine(){this.syncTickerState(),this.syncResizeWatcher(),this.activeSet.size===0&&this.removeVisibilitySub&&(this.removeVisibilitySub(),this.removeVisibilitySub=null)}bindWake(e){e.instance?.onWake?.(()=>{this.activeSet.has(e)&&this.syncTickerState()})}register(e){return this.plugins.set(e.name,e),this}has(e){return this.plugins.has(e)}setMaxWebGLContexts(e){Me.setMaxActiveContexts(e)}getStats(){let e=0,t=0,o=!1,i=Se.isHidden;this.activeSet.forEach(c=>{if(!c.instance){t++;return}c.visible&&e++;let f=c.instance.isIdle?.()??!1;i||!c.visible||c.faulted||f?t++:!c.instance.isWebGL&&c.instance.isIdle&&(o=!0)});let s=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,n=Me.getRenderStats(),l=Se.fps,a=Se.frameTimeMs;!i&&n.activeRendering>0&&!o?(l=n.fps,a=n.frameTimeMs):i&&(l=0,a=0);let u=Te.getSnapshot();return{mounted:this.activeSet.size,visible:e,pausedEffects:t,activeLoops:Se.isRunning?1:0,registered:this.plugins.size,webglContexts:Me.activeContexts,activeContexts:Me.activeContexts,maxWebGLContexts:Me.maxActiveContexts,suspendedContexts:Me.suspendedContexts,fps:l,frameTimeMs:a,reducedMotion:s,protectionTier:u.tier,protectionLabel:u.label}}apply(e,t,o={}){let i=this.plugins.get(t);if(!i)return console.warn(`[FluxFX] Effect "${t}" is not registered.`),()=>{};let s=this.activeByElement.get(e);s||(s=new Map,this.activeByElement.set(e,s));let n=s.get(t);n&&n.destroy();let l=!1,a={el:e,name:t,plugin:i,instance:null,options:{...o},visible:!0,faulted:!1,unobserve:null,destroy:()=>{l||(l=!0,this.unmountEntryInstance(a),this.activeSet.delete(a),s?.delete(t),this.cleanupEmptyEngine())}};return this.isDeviceAllowed(a.options)&&!this.mountEntryInstance(a)?(s?.delete(t),()=>{}):(s.set(t,a),this.activeSet.add(a),this.ensureVisibilitySub(),this.syncResizeWatcher(),this.syncTickerState(),a.destroy)}update(e,t,o={}){let s=this.activeByElement.get(e)?.get(t);if(!s)return!1;s.options={...s.options,...o};let n=s.options;if(this.syncResizeWatcher(),!this.isDeviceAllowed(n))return this.unmountEntryInstance(s),this.syncTickerState(),!0;if(!s.instance){let a=this.mountEntryInstance(s);return this.syncTickerState(),a}if(s.instance.setOptions)try{return s.instance.setOptions(n),this.syncTickerState(),!0}catch(a){return console.error(`[FluxFX] Hot-update error in "${t}":`,a),!1}try{return s.instance.destroy(),s.instance=s.plugin.mount(e,n),s.faulted=!1,this.bindWake(s),(!s.visible||Se.isHidden)&&s.instance.pause?.(),this.syncTickerState(),!0}catch(a){return s.faulted=!0,console.error(`[FluxFX] Fallback remount error in "${t}":`,a),this.syncTickerState(),!1}}scan(e=document){if(typeof document>"u")return;e.querySelectorAll("[data-fx]").forEach(o=>{let i=o.getAttribute("data-fx");if(!i)return;let s=i.trim().split(/\s+/).filter(Boolean),n=this.parseDatasetOptions(o),l=this.activeByElement.get(o);s.forEach(a=>{l?.has(a)||this.apply(o,a,n)})})}init(e){typeof document>"u"||(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.scan(e??document),{once:!0}):this.scan(e??document))}destroyAll(){let e=Array.from(this.activeSet);for(let t=0;t<e.length;t++)e[t].destroy()}parseDatasetOptions(e){let t={},o=new Set(["preserveBg","adaptToSurface","interactive","trackScroll","glare","offscreen","dynamicResolution","pauseWhenHidden","respectReducedMotion","ambient","clickReveal","focused","wrap","clickToFocus","disableOnMobile","disableOnDesktop","clamp","invert","returnToIdle","once","crossfade"]),i=new Set(["colors","lightColors","darkColors","scrollColors","frames"]);for(let[s,n]of Object.entries(e.dataset)){if(!s.startsWith("fx")||s==="fx"||n===void 0)continue;let l=s.slice(2),a=l.charAt(0).toLowerCase()+l.slice(1),u=n.trim(),c=u.toLowerCase();u===""&&o.has(a)||c==="true"?t[a]=!0:c==="false"?t[a]=!1:i.has(a)?t[a]=u.split(",").map(f=>f.trim()).filter(Boolean):u!==""&&!Number.isNaN(Number(u))?t[a]=Number(u):t[a]=u}return t}},lt=new at;function wr(r){if(r==null)return!1;let e=String(r).trim().toLowerCase();if(!e)return!1;if(e==="transparent"||e==="none")return!0;let t=e.match(/^rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+(?:\s*,\s*([\d.]+))?\s*\)$/);return t&&t[1]!==void 0?parseFloat(t[1])<=.001:!1}function _t(r){let e=r.replace("#","").trim(),t=e.length===3?e.split("").map(n=>n+n).join(""):e;if(t.length!==6)return!0;let o=parseInt(t.slice(0,2),16)/255,i=parseInt(t.slice(2,4),16)/255,s=parseInt(t.slice(4,6),16)/255;return .2126*o+.7152*i+.0722*s>.45}function Ot(r,e){if(Array.isArray(r.colors)&&r.colors.length>0){let s=r.colors.filter(Boolean);if(s.length===1){let u=te(s[0],e[0]);return[u,u,u]}if(s.length===2){let u=te(s[0],e[0]),c=te(s[1],e[1]);return[u,c,c]}let n=te(s[0],e[0]),l=te(s[1]??n,e[1]),a=te(s[2]??l,e[2]);return[n,l,a]}if(typeof r.colors=="string"){let s=r.colors.split(",").map(n=>n.trim()).filter(Boolean);if(s.length===1){let n=te(s[0],e[0]);return[n,n,n]}if(s.length===2){let n=te(s[0],e[0]),l=te(s[1],e[1]);return[n,l,l]}if(s.length>2)return[te(s[0],e[0]),te(s[1],e[1]),te(s[2],e[2])]}if(r.color1===void 0&&r.color2===void 0&&r.color3===void 0)return e;let t=te(r.color1,e[0]),o=r.color2!==void 0?te(r.color2,t):t,i=r.color3!==void 0?te(r.color3,o):o;return[t,o,i]}function ae(r,e){let t=wr(r.bgColor),o=!t&&r.bgColor!==void 0&&String(r.bgColor).trim()!=="",i=o?te(r.bgColor,e):e,s=J.hexToVec3Into(i,J.scratchVec3);return{uBgColor:[s[0],s[1],s[2]],uHasBgColor:o?1:0,uTransparentBg:t?1:0,bgHex:i,hasBgColor:o,transparentBg:t}}function Cr(r){return r==="high"?.65:r==="low"?.35:.5}function le(r){return{name:r.name,mount(e,t){let o=t.quality??"medium",i=new Me(e,{fragmentShader:r.fragmentShader,vertexShader:r.vertexShader,feedbackShader:r.feedbackShader,feedbackScale:r.feedbackShader?Cr(o):void 0,feedbackFloat:r.feedbackShader?r.feedbackFloat??!0:void 0,feedbackMaxDim:typeof t.feedbackMaxDim=="number"?t.feedbackMaxDim:void 0,speed:typeof t.speed=="number"?t.speed:1,quality:o,colors:Ot(t,r.defaultColors),uniforms:r.resolveUniforms?r.resolveUniforms(t):void 0,textures:r.resolveTextures?r.resolveTextures(t):void 0,theme:t.theme,lightColors:t.lightColors,darkColors:t.darkColors,scrollColors:t.scrollColors,trackScroll:t.trackScroll,layer:t.layer,preserveBg:t.preserveBg,adaptToSurface:t.adaptToSurface,overlayOpacity:t.overlayOpacity,interactive:t.interactive!==!1,dynamicResolution:t.dynamicResolution,minDpr:t.minDpr,maxDpr:t.maxDpr,offscreen:t.offscreen,pauseWhenHidden:t.pauseWhenHidden,respectReducedMotion:t.respectReducedMotion});return{isWebGL:!0,update(s,n){i.render(s,n)},setOptions(s){i.updateOptions({speed:typeof s.speed=="number"?s.speed:1,quality:s.quality,colors:Ot(s,r.defaultColors),uniforms:r.resolveUniforms?r.resolveUniforms(s):void 0,textures:r.resolveTextures?r.resolveTextures(s):void 0,theme:s.theme,lightColors:s.lightColors,darkColors:s.darkColors,scrollColors:s.scrollColors,trackScroll:s.trackScroll,layer:s.layer,preserveBg:s.preserveBg,adaptToSurface:s.adaptToSurface,overlayOpacity:s.overlayOpacity,interactive:s.interactive!==!1,dynamicResolution:s.dynamicResolution,minDpr:s.minDpr,maxDpr:s.maxDpr,feedbackMaxDim:typeof s.feedbackMaxDim=="number"?s.feedbackMaxDim:void 0,respectReducedMotion:s.respectReducedMotion})},isIdle(){return i.isIdle},onWake(s){i.onWake(s)},pause(){i.pause()},resume(){i.resume()},destroy(){i.destroy()}}}}}var Sr=`#version 300 es
860
860
  precision highp float;
861
861
 
862
862
  in vec2 vUv;
@@ -973,7 +973,7 @@ void main() {
973
973
  lightCol = clamp(lightCol * lightVig + grain * 0.45, 0.0, 1.0);
974
974
 
975
975
  fragColor = vec4(mix(lightCol, darkCol, darkAmt), 1.0);
976
- }`,Ne=O({name:"aurora",fragmentShader:kt,defaultColors:["#4f46e5","#06b6d4","#ec4899"],resolveUniforms(s){let e=I(s,"#080a17");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg}}});var Dt=`#version 300 es
976
+ }`,Ht=le({name:"aurora",fragmentShader:Sr,defaultColors:["#4f46e5","#06b6d4","#ec4899"],resolveUniforms(r){let e=ae(r,"#080a17");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg}}});var Er=`#version 300 es
977
977
  precision highp float;
978
978
 
979
979
  in vec2 vUv;
@@ -1054,7 +1054,7 @@ void main() {
1054
1054
  lightCol = clamp(lightCol, 0.0, 1.0);
1055
1055
 
1056
1056
  fragColor = vec4(mix(lightCol, darkCol, darkAmt), 1.0);
1057
- }`,Qe=O({name:"liquid-metal",fragmentShader:Dt,defaultColors:["#18181b","#94a3b8","#38bdf8"],resolveUniforms(s){let e=I(s,"#0f172a");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg}}});var Pt=`#version 300 es
1057
+ }`,Vt=le({name:"liquid-metal",fragmentShader:Er,defaultColors:["#18181b","#94a3b8","#38bdf8"],resolveUniforms(r){let e=ae(r,"#0f172a");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg}}});var Rr=`#version 300 es
1058
1058
  precision highp float;
1059
1059
 
1060
1060
  in vec2 vUv;
@@ -1155,7 +1155,7 @@ void main() {
1155
1155
  dye = clamp(dye, vec2(0.0), vec2(1.0));
1156
1156
 
1157
1157
  fragColor = vec4(encodedVel, dye);
1158
- }`,At=`#version 300 es
1158
+ }`,Lr=`#version 300 es
1159
1159
  precision highp float;
1160
1160
 
1161
1161
  in vec2 vUv;
@@ -1236,7 +1236,7 @@ void main() {
1236
1236
  } else {
1237
1237
  fragColor = vec4(opaqueCol, 1.0);
1238
1238
  }
1239
- }`,qe=O({name:"fluid",fragmentShader:At,feedbackShader:Pt,feedbackFloat:!0,defaultColors:["#6366f1","#06b6d4","#f43f5e"],resolveUniforms(s){let e=I(s,"#060810");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uDissipation:typeof s.dissipation=="number"?s.dissipation:.975,uRadius:typeof s.radius=="number"?s.radius:.0045,uSwirl:typeof s.swirl=="number"?s.swirl:1.4}}});var Bt=`#version 300 es
1239
+ }`,Wt=le({name:"fluid",fragmentShader:Lr,feedbackShader:Rr,feedbackFloat:!0,defaultColors:["#6366f1","#06b6d4","#f43f5e"],resolveUniforms(r){let e=ae(r,"#060810");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uDissipation:typeof r.dissipation=="number"?r.dissipation:.975,uRadius:typeof r.radius=="number"?r.radius:.0045,uSwirl:typeof r.swirl=="number"?r.swirl:1.4}}});var kr=`#version 300 es
1240
1240
  precision highp float;
1241
1241
 
1242
1242
  in vec2 vUv;
@@ -1332,7 +1332,7 @@ void main() {
1332
1332
  vec2 encVel = clamp(vel * 0.5 + 0.5, vec2(0.02), vec2(0.98));
1333
1333
 
1334
1334
  fragColor = vec4(encVel, ink);
1335
- }`,Ut=`#version 300 es
1335
+ }`,Fr=`#version 300 es
1336
1336
  precision highp float;
1337
1337
 
1338
1338
  in vec2 vUv;
@@ -1417,7 +1417,7 @@ void main() {
1417
1417
  lightCol = clamp(lightCol * lightVig + grain * 0.5, 0.0, 1.0);
1418
1418
 
1419
1419
  fragColor = vec4(mix(lightCol, darkCol, darkAmt), 1.0);
1420
- }`,$e=O({name:"ink",fragmentShader:Ut,feedbackShader:Bt,feedbackFloat:!0,defaultColors:["#1e1b4b","#0284c7","#e11d48"],resolveUniforms(s){let e=I(s,"#060810");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uDissipation:typeof s.dissipation=="number"?s.dissipation:.982,uRadius:typeof s.radius=="number"?s.radius:.004,uCurl:typeof s.curl=="number"?s.curl:1.75}}});var It=`#version 300 es
1420
+ }`,zt=le({name:"ink",fragmentShader:Fr,feedbackShader:kr,feedbackFloat:!0,defaultColors:["#1e1b4b","#0284c7","#e11d48"],resolveUniforms(r){let e=ae(r,"#060810");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uDissipation:typeof r.dissipation=="number"?r.dissipation:.982,uRadius:typeof r.radius=="number"?r.radius:.004,uCurl:typeof r.curl=="number"?r.curl:1.75}}});var Pr=`#version 300 es
1421
1421
  precision highp float;
1422
1422
 
1423
1423
  in vec2 vUv;
@@ -1523,7 +1523,7 @@ void main() {
1523
1523
  vec2 encVel = clamp(vel * 0.5 + 0.5, vec2(0.02), vec2(0.98));
1524
1524
 
1525
1525
  fragColor = vec4(encVel, ink);
1526
- }`,Ot=`#version 300 es
1526
+ }`,Dr=`#version 300 es
1527
1527
  precision highp float;
1528
1528
 
1529
1529
  in vec2 vUv;
@@ -1603,7 +1603,7 @@ void main() {
1603
1603
  } else {
1604
1604
  fragColor = vec4(opaqueCol, 1.0);
1605
1605
  }
1606
- }`,Ke=O({name:"aetheria",fragmentShader:Ot,feedbackShader:It,feedbackFloat:!0,defaultColors:["#1e3a5f","#2d3748","#0284c7"],resolveUniforms(s){let e=I(s,"#f5f3ee"),t=typeof s.lightMode=="number"||typeof s.lightMode=="boolean"||e.hasBgColor,i=Xe(e.bgHex)?1:0,r=typeof s.lightMode=="number"?s.lightMode:typeof s.lightMode=="boolean"?s.lightMode?1:0:i;return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uHasExplicitLightMode:t?1:0,uTransparentBg:e.uTransparentBg,uLightMode:r,uAbsorptionGain:typeof s.absorptionGain=="number"?s.absorptionGain:1.45,uDissipation:typeof s.dissipation=="number"?s.dissipation:.978,uRadius:typeof s.radius=="number"?s.radius:.0032,uCurl:typeof s.curl=="number"?s.curl:1.85}}});var _t=`#version 300 es
1606
+ }`,Gt=le({name:"aetheria",fragmentShader:Dr,feedbackShader:Pr,feedbackFloat:!0,defaultColors:["#1e3a5f","#2d3748","#0284c7"],resolveUniforms(r){let e=ae(r,"#f5f3ee"),t=typeof r.lightMode=="number"||typeof r.lightMode=="boolean"||e.hasBgColor,o=_t(e.bgHex)?1:0,i=typeof r.lightMode=="number"?r.lightMode:typeof r.lightMode=="boolean"?r.lightMode?1:0:o;return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uHasExplicitLightMode:t?1:0,uTransparentBg:e.uTransparentBg,uLightMode:i,uAbsorptionGain:typeof r.absorptionGain=="number"?r.absorptionGain:1.45,uDissipation:typeof r.dissipation=="number"?r.dissipation:.978,uRadius:typeof r.radius=="number"?r.radius:.0032,uCurl:typeof r.curl=="number"?r.curl:1.85}}});var Ar=`#version 300 es
1607
1607
  precision highp float;
1608
1608
 
1609
1609
  in vec2 vUv;
@@ -1826,7 +1826,7 @@ void main() {
1826
1826
  vec3 finalCol = mix(litCol, bgCol + auraCol * 0.25, fog * 0.45);
1827
1827
  float vig = 1.0 - dot(vUv - 0.5, vUv - 0.5) * mix(0.12, 0.55, darkAmt);
1828
1828
  fragColor = vec4(clamp(finalCol * vig, 0.0, 1.0), 1.0);
1829
- }`;function Vt(s){if(typeof s=="number")return s;let e=String(s??"prism").trim().toLowerCase();return e==="torus"?1:e==="orb"||e==="sphere"?2:0}var Ye=O({name:"prism-3d",fragmentShader:_t,defaultColors:["#6366f1","#06b6d4","#f472b6"],resolveUniforms(s){let e=I(s,"#070a16");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uShape:Vt(s.shape),uDepth:typeof s.depth=="number"?s.depth:1,uGloss:typeof s.gloss=="number"?s.gloss:1,uDistortion:typeof s.distortion=="number"?s.distortion:.35}}});var Ht=`#version 300 es
1829
+ }`;function Br(r){if(typeof r=="number")return r;let e=String(r??"prism").trim().toLowerCase();return e==="torus"?1:e==="orb"||e==="sphere"?2:0}var Xt=le({name:"prism-3d",fragmentShader:Ar,defaultColors:["#6366f1","#06b6d4","#f472b6"],resolveUniforms(r){let e=ae(r,"#070a16");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uShape:Br(r.shape),uDepth:typeof r.depth=="number"?r.depth:1,uGloss:typeof r.gloss=="number"?r.gloss:1,uDistortion:typeof r.distortion=="number"?r.distortion:.35}}});var Ur=`#version 300 es
1830
1830
  precision highp float;
1831
1831
 
1832
1832
  in vec2 vUv;
@@ -1925,7 +1925,7 @@ void main() {
1925
1925
  float freshEdge = clamp(mix(c.g * 0.88, brushVal, 0.45), 0.0, 1.0);
1926
1926
 
1927
1927
  fragColor = vec4(nextMask, freshEdge, 0.0, 1.0);
1928
- }`,Wt=`#version 300 es
1928
+ }`,Ir=`#version 300 es
1929
1929
  precision highp float;
1930
1930
 
1931
1931
  in vec2 vUv;
@@ -2078,7 +2078,7 @@ void main() {
2078
2078
  }
2079
2079
 
2080
2080
  fragColor = vec4(col * outAlpha, outAlpha);
2081
- }`;function Gt(s){return String(s??"cover").trim().toLowerCase()==="contain"?1:0}function zt(s){let e=String(s??"center").trim().toLowerCase();return e==="bottom"?[.5,0]:e==="top"?[.5,1]:[.5,.5]}function je(s){return typeof s=="string"?s.trim():""}function Je(s,e){if(typeof s=="boolean")return s?1:0;if(typeof s=="string"){let t=s.trim().toLowerCase();if(t==="true")return 1;if(t==="false")return 0}return typeof s=="number"?s>.5?1:0:e?1:0}var Ze=O({name:"brush-reveal",fragmentShader:Wt,feedbackShader:Ht,feedbackFloat:!0,defaultColors:["#ff6b2b","#ffd166","#ffffff"],resolveTextures(s){return{uBaseTex:je(s.baseImage??s.image),uRevealTex:je(s.revealImage)}},resolveUniforms(s){let e=I(s,"#000000");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uRadius:typeof s.radius=="number"?s.radius:.13,uSoftness:typeof s.softness=="number"?s.softness:.22,uEdgeNoise:typeof s.edgeNoise=="number"?s.edgeNoise:.38,uEdgeGlow:typeof s.edgeGlow=="number"?s.edgeGlow:.24,uDissipation:typeof s.dissipation=="number"?s.dissipation:.985,uFit:Gt(s.fit),uPosition:zt(s.position),uAmbient:Je(s.ambient,!1),uClickReveal:Je(s.clickReveal,!0)}}});var Xt=`#version 300 es
2081
+ }`;function Or(r){return String(r??"cover").trim().toLowerCase()==="contain"?1:0}function _r(r){let e=String(r??"center").trim().toLowerCase();return e==="bottom"?[.5,0]:e==="top"?[.5,1]:[.5,.5]}function Nt(r){return typeof r=="string"?r.trim():""}function Qt(r,e){if(typeof r=="boolean")return r?1:0;if(typeof r=="string"){let t=r.trim().toLowerCase();if(t==="true")return 1;if(t==="false")return 0}return typeof r=="number"?r>.5?1:0:e?1:0}var qt=le({name:"brush-reveal",fragmentShader:Ir,feedbackShader:Ur,feedbackFloat:!0,defaultColors:["#ff6b2b","#ffd166","#ffffff"],resolveTextures(r){return{uBaseTex:Nt(r.baseImage??r.image),uRevealTex:Nt(r.revealImage)}},resolveUniforms(r){let e=ae(r,"#000000");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uRadius:typeof r.radius=="number"?r.radius:.13,uSoftness:typeof r.softness=="number"?r.softness:.22,uEdgeNoise:typeof r.edgeNoise=="number"?r.edgeNoise:.38,uEdgeGlow:typeof r.edgeGlow=="number"?r.edgeGlow:.24,uDissipation:typeof r.dissipation=="number"?r.dissipation:.985,uFit:Or(r.fit),uPosition:_r(r.position),uAmbient:Qt(r.ambient,!1),uClickReveal:Qt(r.clickReveal,!0)}}});var Hr=`#version 300 es
2082
2082
  precision highp float;
2083
2083
 
2084
2084
  in vec2 vUv;
@@ -2158,4 +2158,4 @@ void main() {
2158
2158
  }
2159
2159
 
2160
2160
  fragColor = vec4(col, 1.0);
2161
- }`;function Nt(s){if(Array.isArray(s)&&s.length>=2){let t=Number(s[0]),i=Number(s[1]);if(!Number.isNaN(t)&&!Number.isNaN(i))return[t,i]}let e=String(s??"center").trim().toLowerCase();return e==="left"?[.34,.52]:e==="right"?[.66,.52]:[.5,.52]}var et=O({name:"spotlight",fragmentShader:Xt,defaultColors:["#14161a","#4b5563","#f8fafc"],resolveUniforms(s){let e=I(s,"#121316");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uSpotRadius:typeof s.spotRadius=="number"?s.spotRadius:.62,uSpotIntensity:typeof s.spotIntensity=="number"?s.spotIntensity:1,uSpotPosition:Nt(s.spotPosition)}}});var tt={name:"tilt-3d",mount(s,e){let t=typeof e.maxTilt=="number"?e.maxTilt:12,i=typeof e.scale=="number"?e.scale:1.03,r=typeof e.perspective=="number"?e.perspective:900,o=e.glare!==!1,n=e.respectReducedMotion??!0,l=s.style.transform,a=s.style.position,c=s.style.overflow,u=s.style.willChange,d=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,f=n&&(d?.matches??!1);f||(s.style.willChange="transform");let h=null;o&&(getComputedStyle(s).position==="static"&&(s.style.position="relative"),s.style.overflow="hidden",h=document.createElement("div"),Object.assign(h.style,{position:"absolute",inset:"0",pointerEvents:"none",borderRadius:"inherit",opacity:"0",transition:"opacity 0.25s ease",zIndex:"2"}),s.appendChild(h));let m=0,v=0,g=1,b=0,x=0,y=1,T=50,R=50,E=!1,S=!1,M=null,L=null,U=!0,_=()=>{U=!0},ee=()=>{let p=s.getBoundingClientRect();L={left:p.left,top:p.top,width:p.width,height:p.height},U=!1},q=p=>{let C=n&&p.matches;f!==C&&(f=C,f?(m=0,v=0,g=1,b=0,x=0,y=1,E=!1,h&&(h.style.opacity="0"),s.style.transform=l,s.style.willChange=u):(s.style.willChange="transform",U=!0),M?.())},$=()=>{U=!0},K=p=>{if(S||f||((U||!L)&&ee(),!L||L.width<=0||L.height<=0))return;let C=(p.clientX-L.left)/L.width,w=(p.clientY-L.top)/L.height;m=(.5-w)*t*2,v=(C-.5)*t*2,g=i,T=C*100,R=w*100,E=!0,h&&(h.style.opacity="1"),M?.()},Y=()=>{f||(m=0,v=0,g=1,h&&(h.style.opacity="0"),(Math.abs(b)>.01||Math.abs(x)>.01||Math.abs(y-1)>.001)&&(E=!0,S||M?.()))},j=null;return typeof ResizeObserver<"u"&&(j=new ResizeObserver(_),j.observe(s)),d&&typeof d.addEventListener=="function"&&d.addEventListener("change",q),s.addEventListener("pointerenter",$,{passive:!0}),s.addEventListener("pointermove",K,{passive:!0}),s.addEventListener("pointerleave",Y,{passive:!0}),window.addEventListener("resize",_,{passive:!0}),window.addEventListener("scroll",_,{passive:!0,capture:!0}),{update(p,C){if(!E||S||f)return;let w=1-Math.exp(-12*C);if(b+=(m-b)*w,x+=(v-x)*w,y+=(g-y)*w,h&&(h.style.background=`radial-gradient(circle at ${T.toFixed(1)}% ${R.toFixed(1)}%, rgba(255,255,255,0.22), transparent 60%)`),Math.abs(m-b)<.02&&Math.abs(v-x)<.02&&Math.abs(g-y)<.001){b=m,x=v,y=g,E=!1,s.style.transform=g===1&&m===0&&v===0?l:`perspective(${r}px) rotateX(${b.toFixed(2)}deg) rotateY(${x.toFixed(2)}deg) scale3d(${y.toFixed(3)}, ${y.toFixed(3)}, 1)`;return}s.style.transform=`perspective(${r}px) rotateX(${b.toFixed(2)}deg) rotateY(${x.toFixed(2)}deg) scale3d(${y.toFixed(3)}, ${y.toFixed(3)}, 1)`},isIdle(){return!E||S||f},onWake(p){M=p},pause(){S=!0},resume(){S=!1,U=!0,E&&!f&&M?.()},destroy(){M=null,E=!1,L=null,j?.disconnect(),j=null,d&&typeof d.removeEventListener=="function"&&d.removeEventListener("change",q),s.removeEventListener("pointerenter",$),s.removeEventListener("pointermove",K),s.removeEventListener("pointerleave",Y),window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0),h?.remove(),s.style.transform=l,s.style.position=a,s.style.overflow=c,s.style.willChange=u}}}};var it={name:"magnetic",mount(s,e){let t=typeof e.strength=="number"?e.strength:.35,i=e.respectReducedMotion??!0,r=s.style.transform,o=s.style.willChange,n=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,l=i&&(n?.matches??!1);l||(s.style.willChange="transform");let a=0,c=0,u=0,d=0,f=!1,h=!1,m=null,v=null,g=!0,b=()=>{g=!0},x=()=>{let M=s.getBoundingClientRect();v={left:M.left-u,top:M.top-d,width:M.width,height:M.height},g=!1},y=M=>{let L=i&&M.matches;l!==L&&(l=L,l?(a=0,c=0,u=0,d=0,f=!1,s.style.transform=r,s.style.willChange=o):(s.style.willChange="transform",g=!0),m?.())},T=()=>{g=!0},R=M=>{if(h||l||((g||!v)&&x(),!v||v.width<=0||v.height<=0))return;let L=v.left+v.width*.5,U=v.top+v.height*.5;a=(M.clientX-L)*t,c=(M.clientY-U)*t,f=!0,m?.()},E=()=>{l||(a=0,c=0,(Math.abs(u)>.01||Math.abs(d)>.01)&&(f=!0,h||m?.()))},S=null;return typeof ResizeObserver<"u"&&(S=new ResizeObserver(b),S.observe(s)),n&&typeof n.addEventListener=="function"&&n.addEventListener("change",y),s.addEventListener("pointerenter",T,{passive:!0}),s.addEventListener("pointermove",R,{passive:!0}),s.addEventListener("pointerleave",E,{passive:!0}),window.addEventListener("resize",b,{passive:!0}),window.addEventListener("scroll",b,{passive:!0,capture:!0}),{update(M,L){if(!f||h||l)return;let U=1-Math.exp(-10*L);if(u+=(a-u)*U,d+=(c-d)*U,Math.abs(a-u)<.05&&Math.abs(c-d)<.05){u=a,d=c,f=!1,s.style.transform=a===0&&c===0?r:`translate3d(${u.toFixed(2)}px, ${d.toFixed(2)}px, 0)`;return}s.style.transform=`translate3d(${u.toFixed(2)}px, ${d.toFixed(2)}px, 0)`},isIdle(){return!f||h||l},onWake(M){m=M},pause(){h=!0},resume(){h=!1,g=!0,f&&!l&&m?.()},destroy(){m=null,f=!1,v=null,S?.disconnect(),S=null,n&&typeof n.removeEventListener=="function"&&n.removeEventListener("change",y),s.removeEventListener("pointerenter",T),s.removeEventListener("pointermove",R),s.removeEventListener("pointerleave",E),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),s.style.transform=r,s.style.willChange=o}}}};function Q(s,e,t){return Math.min(t,Math.max(e,s))}function Z(s,e){return typeof s=="number"&&!Number.isNaN(s)?s:e}function we(s,e){if(typeof s=="boolean")return s;if(typeof s=="string"){let t=s.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}return e}function Qt(s){return s===!1?0:s===!0||s===void 0?18:typeof s=="number"&&!Number.isNaN(s)?s:18}function rt(s,e){let t=Math.round(Z(s.activeIndex,0));return{activeIndex:e>0?Q(t,0,e-1):0,focused:we(s.focused,!1),wrap:we(s.wrap,!0),clickToFocus:we(s.clickToFocus,!0),spread:Z(s.spread,25),depthScale:Q(Z(s.depthScale,.22),.05,.45),curve:Z(s.curve,10),parallax:Qt(s.parallax),focusOffsetX:Z(s.focusOffsetX,-15),focusScale:Q(Z(s.focusScale,1.07),.8,1.4),perspective:Z(s.perspective,1100),respectReducedMotion:s.respectReducedMotion??!0,onChange:typeof s.onChange=="function"?s.onChange:void 0}}function st(s){let e=Array.from(s.querySelectorAll("[data-fx-slide]"));return e.length>0?e:Array.from(s.children).filter(t=>t instanceof HTMLElement&&!t.hasAttribute("data-fluxfx-canvas"))}function me(s,e,t,i){let r=s-e;if(i&&t>2){let o=t/2;for(;r>o;)r-=t;for(;r<-o;)r+=t}return r}var ot={name:"depth-carousel",mount(s,e){let t=s.style.position,i=s.style.perspective,r=s.style.transformStyle;typeof window<"u"&&getComputedStyle(s).position==="static"&&(s.style.position="relative");let o=st(s),n=new Map,l=()=>{o=st(s);for(let p of o)n.has(p)||n.set(p,{el:p,transform:p.style.transform,opacity:p.style.opacity,zIndex:p.style.zIndex,filter:p.style.filter,pointerEvents:p.style.pointerEvents,willChange:p.style.willChange})};l();let a=rt(e,o.length);s.style.perspective=`${a.perspective}px`,s.style.transformStyle="preserve-3d";let c=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,u=a.respectReducedMotion&&(c?.matches??!1),d=a.activeIndex,f=a.activeIndex,h=a.focused?1:0,m=a.focused?1:0,v=0,g=0,b=0,x=0,y=!0,T=!1,R=null,E=null,S=null,M=!1,L=(p=!1)=>{(p||u)&&(d=f,h=m,v=b,g=x);let C=o.length;if(C!==0)for(let w=0;w<C;w++){let A=o[w],X=me(w,d,C,a.wrap),V=Math.abs(X),J=X*a.spread,se=Math.max(.45,1-V*a.depthScale),pe=-V*160,at=Q(-X*a.curve,-32,32),Ee=V>2.35?0:Math.max(.18,1-V*.32),ve=V<.5,nt=ve?a.focusOffsetX:J*1.45,lt=ve?a.focusScale:se*.85,ct=ve?1:0,ut=J+(nt-J)*h,dt=se+(lt-se)*h,ft=pe*(1-h*.5),ht=at*(1-h),Se=Ee+(ct-Ee)*h,Le=Math.max(.25,1-V*.25),mt=v*a.parallax*Le,pt=g*(a.parallax*.55)*Le,vt=Math.max(1,20-Math.round(V*4)),Fe=V>1.2&&h<.5?Math.min(2.5,(V-1.2)*1.5):0;u||(A.style.willChange="transform, opacity"),A.style.zIndex=String(vt),A.style.opacity=Se.toFixed(3),A.style.pointerEvents=Se<.08?"none":"auto",A.style.filter=Fe>.1?`blur(${Fe.toFixed(2)}px)`:"",A.style.transform=`translate3d(calc(${ut.toFixed(2)}% + ${mt.toFixed(2)}px), ${pt.toFixed(2)}px, ${ft.toFixed(1)}px) rotateY(${ht.toFixed(2)}deg) scale(${dt.toFixed(4)})`;let ke=w===Math.round(f)?"true":"false";A.getAttribute("data-fx-active")!==ke&&A.setAttribute("data-fx-active",ke)}},U=()=>{let p=Q(Math.round(f),0,Math.max(0,o.length-1)),C=o[p]??null;a.onChange?.({index:p,focused:m>.5,element:C}),s.dispatchEvent(new CustomEvent("fluxfx:change",{bubbles:!0,detail:{index:p,focused:m>.5,element:C}}))},_=(p,C)=>{let w=o.length;if(w===0)return;let A=p;a.wrap?A=(p%w+w)%w:A=Q(p,0,w-1);let X=f,V=m;if(a.wrap&&w>2){let J=me(A,d,w,!0);f=d+J,f=A}else f=A;typeof C=="boolean"&&(m=C?1:0),(f!==X||m!==V)&&U(),y=!0,u?(L(!0),y=!1):T||R?.()},ee=p=>{if(T||u)return;let C=s.getBoundingClientRect();C.width<=0||C.height<=0||(b=Q(((p.clientX-C.left)/C.width-.5)*2,-1,1),x=Q(((p.clientY-C.top)/C.height-.5)*2,-1,1),E!==null&&S===p.pointerId&&Math.abs(p.clientX-E)>22&&(M=!0),y=!0,R?.())},q=()=>{u||(b=0,x=0,y=!0,T||R?.())},$=p=>{T||p.button!==0||(E=p.clientX,S=p.pointerId,M=!1)},K=p=>{if(E===null||S!==p.pointerId)return;let C=p.clientX-E;if(E=null,S=null,Math.abs(C)>48&&m<.5){let w=C<0?1:-1;_(f+w)}},Y=p=>{if(T)return;if(M){M=!1;return}let C=p.target;if(C){if(C.closest("[data-fx-prev]")){_(f-1,!1);return}if(C.closest("[data-fx-next]")){_(f+1,!1);return}for(let w=0;w<o.length;w++)if(o[w]===C||o[w].contains(C)){w!==Math.round(f)?_(w,!1):a.clickToFocus&&_(w,m<.5);return}}},j=p=>{u=a.respectReducedMotion&&p.matches,u&&(L(!0),y=!1),R?.()};return c&&typeof c.addEventListener=="function"&&c.addEventListener("change",j),s.addEventListener("pointermove",ee,{passive:!0}),s.addEventListener("pointerleave",q,{passive:!0}),s.addEventListener("pointerdown",$,{passive:!0}),window.addEventListener("pointerup",K,{passive:!0}),s.addEventListener("click",Y),L(!0),y=!1,{update(p,C){if(!y||T||u)return;let w=Math.min(C,.05),A=1-Math.exp(-10.5*w),X=1-Math.exp(-8*w),V=me(f,d,o.length,a.wrap);d+=V*A,a.wrap&&o.length>0&&(d=(d%o.length+o.length)%o.length),h+=(m-h)*A,v+=(b-v)*X,g+=(x-g)*X,L(!1);let J=Math.abs(me(f,d,o.length,a.wrap))<.002,se=Math.abs(m-h)<.003,pe=Math.abs(b-v)<.003&&Math.abs(x-g)<.003;J&&se&&pe&&(L(!0),y=!1)},setOptions(p){l();let C=a;a=rt(p,o.length),a.perspective!==C.perspective&&(s.style.perspective=`${a.perspective}px`);let w=p.focused!==void 0?a.focused:m>.5,A=p.activeIndex!==void 0?a.activeIndex:f,X=Math.round(A)!==Math.round(f)||w!==m>.5;f=A,m=w?1:0,X&&U(),y=!0,u?(L(!0),y=!1):T||R?.()},isIdle(){return!y||T||u},onWake(p){R=p},pause(){T=!0},resume(){T=!1,y&&!u&&R?.()},destroy(){R=null,y=!1,c&&typeof c.removeEventListener=="function"&&c.removeEventListener("change",j),s.removeEventListener("pointermove",ee),s.removeEventListener("pointerleave",q),s.removeEventListener("pointerdown",$),window.removeEventListener("pointerup",K),s.removeEventListener("click",Y),n.forEach(p=>{p.el.style.transform=p.transform,p.el.style.opacity=p.opacity,p.el.style.zIndex=p.zIndex,p.el.style.filter=p.filter,p.el.style.pointerEvents=p.pointerEvents,p.el.style.willChange=p.willChange,p.el.removeAttribute("data-fx-active")}),n.clear(),s.style.position=t,s.style.perspective=i,s.style.transformStyle=r}}}};he.register(Ne).register(Qe).register(qe).register($e).register(Ke).register(Ye).register(Ze).register(et).register(tt).register(it).register(ot);var Re=he;typeof window<"u"&&(window.FluxFX=he);function H(s,e={},t=!1){let i=(0,P.useRef)(null),r=Array.isArray(s)?s.join(" "):s,o=JSON.stringify(e),n=(0,P.useRef)(o);n.current=o;let l=(0,P.useRef)(!1),a=(0,P.useRef)(null);return(0,P.useEffect)(()=>{if(t||typeof window>"u")return;let c=i.current;if(!c||!r.trim())return;let u=n.current,d=JSON.parse(u),h=r.trim().split(/\s+/).map(m=>Re.apply(c,m,d));return l.current=!0,a.current=u,()=>{l.current=!1,a.current=null,h.forEach(m=>m())}},[r,t]),(0,P.useEffect)(()=>{if(!l.current||t||typeof window>"u"||a.current===o)return;let c=i.current;if(!c||!r.trim())return;let u=JSON.parse(o);r.trim().split(/\s+/).forEach(f=>{Re.update(c,f,u)}),a.current=o},[o,r,t]),i}function z(s){let{device:e,minWidth:t,maxWidth:i,disableOnMobile:r,disableOnDesktop:o,mobileBreakpoint:n,...l}=s;return{deviceOpts:{device:e,minWidth:t,maxWidth:i,disableOnMobile:r,disableOnDesktop:o,mobileBreakpoint:n},domRest:l}}function qt({as:s="section",speed:e=1,quality:t="medium",colors:i=["#4f46e5","#06b6d4","#ec4899"],bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,interactive:m=!0,respectReducedMotion:v=!0,disabled:g=!1,children:b,...x}){let{deviceOpts:y,domRest:T}=z(x),R=H("aurora",{speed:e,quality:t,colors:i,bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,interactive:m,respectReducedMotion:v,...y},g);return P.default.createElement(s,{ref:R,...T},b)}function $t({as:s="section",speed:e=1,quality:t="medium",colors:i=["#0f172a","#94a3b8","#38bdf8"],bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,interactive:m=!0,respectReducedMotion:v=!0,disabled:g=!1,children:b,...x}){let{deviceOpts:y,domRest:T}=z(x),R=H("liquid-metal",{speed:e,quality:t,colors:i,bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,interactive:m,respectReducedMotion:v,...y},g);return P.default.createElement(s,{ref:R,...T},b)}function Kt({as:s="section",speed:e=1,quality:t="medium",colors:i=["#6366f1","#06b6d4","#f43f5e"],bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,dissipation:m=.975,radius:v=.0045,swirl:g=1.4,interactive:b=!0,respectReducedMotion:x=!0,disabled:y=!1,children:T,...R}){let{deviceOpts:E,domRest:S}=z(R),M=H("fluid",{speed:e,quality:t,colors:i,bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,dissipation:m,radius:v,swirl:g,interactive:b,respectReducedMotion:x,...E},y);return P.default.createElement(s,{ref:M,...S},T)}function Yt({as:s="div",maxTilt:e=12,scale:t=1.03,perspective:i=900,glare:r=!0,respectReducedMotion:o=!0,disabled:n=!1,children:l,...a}){let{deviceOpts:c,domRest:u}=z(a),d=H("tilt-3d",{maxTilt:e,scale:t,perspective:i,glare:r,respectReducedMotion:o,...c},n);return P.default.createElement(s,{ref:d,...u},l)}function jt({as:s="div",strength:e=.35,respectReducedMotion:t=!0,disabled:i=!1,style:r,children:o,...n}){let{deviceOpts:l,domRest:a}=z(n),c=H("magnetic",{strength:e,respectReducedMotion:t,...l},i);return P.default.createElement(s,{ref:c,style:{display:"inline-block",...r},...a},o)}function Jt({as:s="section",speed:e=1,quality:t="medium",colors:i=["#1e1b4b","#0284c7","#e11d48"],bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,dissipation:m=.982,radius:v=.004,curl:g=1.75,interactive:b=!0,respectReducedMotion:x=!0,disabled:y=!1,children:T,...R}){let{deviceOpts:E,domRest:S}=z(R),M=H("ink",{speed:e,quality:t,colors:i,bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,dissipation:m,radius:v,curl:g,interactive:b,respectReducedMotion:x,...E},y);return P.default.createElement(s,{ref:M,...S},T)}function Zt({as:s="section",speed:e=1,quality:t="medium",colors:i=["#1e3a5f","#2d3748","#0284c7"],bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,lightMode:m,absorptionGain:v=1.45,dissipation:g=.978,radius:b=.0032,curl:x=1.85,interactive:y=!0,respectReducedMotion:T=!0,disabled:R=!1,children:E,...S}){let{deviceOpts:M,domRest:L}=z(S),U=H("aetheria",{speed:e,quality:t,colors:i,bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,lightMode:m,absorptionGain:v,dissipation:g,radius:b,curl:x,interactive:y,respectReducedMotion:T,...M},R);return P.default.createElement(s,{ref:U,...L},E)}function ei({as:s="section",speed:e=1,quality:t="medium",colors:i=["#6366f1","#06b6d4","#f472b6"],bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,shape:m="prism",depth:v=1,gloss:g=1,distortion:b=.35,interactive:x=!0,respectReducedMotion:y=!0,disabled:T=!1,children:R,...E}){let{deviceOpts:S,domRest:M}=z(E),L=H("prism-3d",{speed:e,quality:t,colors:i,bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,shape:m,depth:v,gloss:g,distortion:b,interactive:x,respectReducedMotion:y,...S},T);return P.default.createElement(s,{ref:L,...M},R)}function ti({as:s="section",baseImage:e,revealImage:t,speed:i=1,quality:r="medium",colors:o=["#ff6b2b","#ffd166","#ffffff"],bgColor:n="transparent",theme:l,lightColors:a,darkColors:c,scrollColors:u,trackScroll:d,layer:f,preserveBg:h,adaptToSurface:m,overlayOpacity:v,radius:g=.13,softness:b=.22,edgeNoise:x=.38,edgeGlow:y=.24,dissipation:T=.985,fit:R="cover",position:E="center",ambient:S=!1,clickReveal:M=!0,interactive:L=!0,respectReducedMotion:U=!0,disabled:_=!1,children:ee,...q}){let{deviceOpts:$,domRest:K}=z(q),Y=H("brush-reveal",{baseImage:e,revealImage:t,speed:i,quality:r,colors:o,bgColor:n,theme:l,lightColors:a,darkColors:c,scrollColors:u,trackScroll:d,layer:f,preserveBg:h,adaptToSurface:m,overlayOpacity:v,radius:g,softness:b,edgeNoise:x,edgeGlow:y,dissipation:T,fit:R,position:E,ambient:S,clickReveal:M,interactive:L,respectReducedMotion:U,...$},_);return P.default.createElement(s,{ref:Y,...K},ee)}function ii({as:s="section",speed:e=1,quality:t="medium",colors:i=["#14161a","#4b5563","#f8fafc"],bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,spotRadius:m=.62,spotIntensity:v=1,spotPosition:g="center",interactive:b=!0,respectReducedMotion:x=!0,disabled:y=!1,children:T,...R}){let{deviceOpts:E,domRest:S}=z(R),M=H("spotlight",{speed:e,quality:t,colors:i,bgColor:r,theme:o,lightColors:n,darkColors:l,scrollColors:a,trackScroll:c,layer:u,preserveBg:d,adaptToSurface:f,overlayOpacity:h,spotRadius:m,spotIntensity:v,spotPosition:g,interactive:b,respectReducedMotion:x,...E},y);return P.default.createElement(s,{ref:M,...S},T)}function ri({as:s="div",activeIndex:e=0,focused:t=!1,wrap:i=!0,clickToFocus:r=!0,spread:o=25,depthScale:n=.22,curve:l=10,parallax:a=18,focusOffsetX:c=-15,focusScale:u=1.07,perspective:d=1100,respectReducedMotion:f=!0,disabled:h=!1,onSlideChange:m,children:v,...g}){let{deviceOpts:b,domRest:x}=z(g),y=(0,P.useRef)(m);y.current=m;let T=H("depth-carousel",{activeIndex:e,focused:t,wrap:i,clickToFocus:r,spread:o,depthScale:n,curve:l,parallax:a,focusOffsetX:c,focusScale:u,perspective:d,respectReducedMotion:f,...b},h);return(0,P.useEffect)(()=>{let R=T.current;if(!R)return;let E=S=>{let M=S;y.current?.(M.detail)};return R.addEventListener("fluxfx:change",E),()=>R.removeEventListener("fluxfx:change",E)},[T]),P.default.createElement(s,{ref:T,...x},v)}0&&(module.exports={Aetheria,Aurora,BrushReveal,DepthCarousel,Fluid,Ink,LiquidMetal,Magnetic,Prism3D,Spotlight,TiltCard,useFX});
2161
+ }`;function Vr(r){if(Array.isArray(r)&&r.length>=2){let t=Number(r[0]),o=Number(r[1]);if(!Number.isNaN(t)&&!Number.isNaN(o))return[t,o]}let e=String(r??"center").trim().toLowerCase();return e==="left"?[.34,.52]:e==="right"?[.66,.52]:[.5,.52]}var $t=le({name:"spotlight",fragmentShader:Hr,defaultColors:["#14161a","#4b5563","#f8fafc"],resolveUniforms(r){let e=ae(r,"#121316");return{uBgColor:e.uBgColor,uHasBgColor:e.uHasBgColor,uTransparentBg:e.uTransparentBg,uSpotRadius:typeof r.spotRadius=="number"?r.spotRadius:.62,uSpotIntensity:typeof r.spotIntensity=="number"?r.spotIntensity:1,uSpotPosition:Vr(r.spotPosition)}}});var Yt={name:"tilt-3d",mount(r,e){let t=typeof e.maxTilt=="number"?e.maxTilt:12,o=typeof e.scale=="number"?e.scale:1.03,i=typeof e.perspective=="number"?e.perspective:900,s=e.glare!==!1,n=e.respectReducedMotion??!0,l=r.style.transform,a=r.style.position,u=r.style.overflow,c=r.style.willChange,f=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,m=n&&(f?.matches??!1);m||(r.style.willChange="transform");let p=null;s&&(getComputedStyle(r).position==="static"&&(r.style.position="relative"),r.style.overflow="hidden",p=document.createElement("div"),Object.assign(p.style,{position:"absolute",inset:"0",pointerEvents:"none",borderRadius:"inherit",opacity:"0",transition:"opacity 0.25s ease",zIndex:"2"}),r.appendChild(p));let h=0,v=0,g=1,x=0,y=0,M=1,S=50,k=50,B=!1,D=!1,F=null,C=null,U=!0,O=()=>{U=!0},G=()=>{let d=r.getBoundingClientRect();C={left:d.left,top:d.top,width:d.width,height:d.height},U=!1},V=d=>{let b=n&&d.matches;m!==b&&(m=b,m?(h=0,v=0,g=1,x=0,y=0,M=1,B=!1,p&&(p.style.opacity="0"),r.style.transform=l,r.style.willChange=c):(r.style.willChange="transform",U=!0),F?.())},Q=()=>{U=!0},Y=d=>{if(D||m||((U||!C)&&G(),!C||C.width<=0||C.height<=0))return;let b=(d.clientX-C.left)/C.width,T=(d.clientY-C.top)/C.height;h=(.5-T)*t*2,v=(b-.5)*t*2,g=o,S=b*100,k=T*100,B=!0,p&&(p.style.opacity="1"),F?.()},E=()=>{m||(h=0,v=0,g=1,p&&(p.style.opacity="0"),(Math.abs(x)>.01||Math.abs(y)>.01||Math.abs(M-1)>.001)&&(B=!0,D||F?.()))},P=null;return typeof ResizeObserver<"u"&&(P=new ResizeObserver(O),P.observe(r)),f&&typeof f.addEventListener=="function"&&f.addEventListener("change",V),r.addEventListener("pointerenter",Q,{passive:!0}),r.addEventListener("pointermove",Y,{passive:!0}),r.addEventListener("pointerleave",E,{passive:!0}),window.addEventListener("resize",O,{passive:!0}),window.addEventListener("scroll",O,{passive:!0,capture:!0}),{update(d,b){if(!B||D||m)return;let T=1-Math.exp(-12*b);if(x+=(h-x)*T,y+=(v-y)*T,M+=(g-M)*T,p&&(p.style.background=`radial-gradient(circle at ${S.toFixed(1)}% ${k.toFixed(1)}%, rgba(255,255,255,0.22), transparent 60%)`),Math.abs(h-x)<.02&&Math.abs(v-y)<.02&&Math.abs(g-M)<.001){x=h,y=v,M=g,B=!1,r.style.transform=g===1&&h===0&&v===0?l:`perspective(${i}px) rotateX(${x.toFixed(2)}deg) rotateY(${y.toFixed(2)}deg) scale3d(${M.toFixed(3)}, ${M.toFixed(3)}, 1)`;return}r.style.transform=`perspective(${i}px) rotateX(${x.toFixed(2)}deg) rotateY(${y.toFixed(2)}deg) scale3d(${M.toFixed(3)}, ${M.toFixed(3)}, 1)`},isIdle(){return!B||D||m},onWake(d){F=d},pause(){D=!0},resume(){D=!1,U=!0,B&&!m&&F?.()},destroy(){F=null,B=!1,C=null,P?.disconnect(),P=null,f&&typeof f.removeEventListener=="function"&&f.removeEventListener("change",V),r.removeEventListener("pointerenter",Q),r.removeEventListener("pointermove",Y),r.removeEventListener("pointerleave",E),window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0),p?.remove(),r.style.transform=l,r.style.position=a,r.style.overflow=u,r.style.willChange=c}}}};var Kt={name:"magnetic",mount(r,e){let t=typeof e.strength=="number"?e.strength:.35,o=e.respectReducedMotion??!0,i=r.style.transform,s=r.style.willChange,n=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,l=o&&(n?.matches??!1);l||(r.style.willChange="transform");let a=0,u=0,c=0,f=0,m=!1,p=!1,h=null,v=null,g=!0,x=()=>{g=!0},y=()=>{let F=r.getBoundingClientRect();v={left:F.left-c,top:F.top-f,width:F.width,height:F.height},g=!1},M=F=>{let C=o&&F.matches;l!==C&&(l=C,l?(a=0,u=0,c=0,f=0,m=!1,r.style.transform=i,r.style.willChange=s):(r.style.willChange="transform",g=!0),h?.())},S=()=>{g=!0},k=F=>{if(p||l||((g||!v)&&y(),!v||v.width<=0||v.height<=0))return;let C=v.left+v.width*.5,U=v.top+v.height*.5;a=(F.clientX-C)*t,u=(F.clientY-U)*t,m=!0,h?.()},B=()=>{l||(a=0,u=0,(Math.abs(c)>.01||Math.abs(f)>.01)&&(m=!0,p||h?.()))},D=null;return typeof ResizeObserver<"u"&&(D=new ResizeObserver(x),D.observe(r)),n&&typeof n.addEventListener=="function"&&n.addEventListener("change",M),r.addEventListener("pointerenter",S,{passive:!0}),r.addEventListener("pointermove",k,{passive:!0}),r.addEventListener("pointerleave",B,{passive:!0}),window.addEventListener("resize",x,{passive:!0}),window.addEventListener("scroll",x,{passive:!0,capture:!0}),{update(F,C){if(!m||p||l)return;let U=1-Math.exp(-10*C);if(c+=(a-c)*U,f+=(u-f)*U,Math.abs(a-c)<.05&&Math.abs(u-f)<.05){c=a,f=u,m=!1,r.style.transform=a===0&&u===0?i:`translate3d(${c.toFixed(2)}px, ${f.toFixed(2)}px, 0)`;return}r.style.transform=`translate3d(${c.toFixed(2)}px, ${f.toFixed(2)}px, 0)`},isIdle(){return!m||p||l},onWake(F){h=F},pause(){p=!0},resume(){p=!1,g=!0,m&&!l&&h?.()},destroy(){h=null,m=!1,v=null,D?.disconnect(),D=null,n&&typeof n.removeEventListener=="function"&&n.removeEventListener("change",M),r.removeEventListener("pointerenter",S),r.removeEventListener("pointermove",k),r.removeEventListener("pointerleave",B),window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0),r.style.transform=i,r.style.willChange=s}}}};function Ae(r,e,t){return Math.min(t,Math.max(e,r))}function _e(r,e){return typeof r=="number"&&!Number.isNaN(r)?r:e}function xt(r,e){if(typeof r=="boolean")return r;if(typeof r=="string"){let t=r.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}return e}function Wr(r){return r===!1?0:r===!0||r===void 0?18:typeof r=="number"&&!Number.isNaN(r)?r:18}function jt(r,e){let t=Math.round(_e(r.activeIndex,0));return{activeIndex:e>0?Ae(t,0,e-1):0,focused:xt(r.focused,!1),wrap:xt(r.wrap,!0),clickToFocus:xt(r.clickToFocus,!0),spread:_e(r.spread,25),depthScale:Ae(_e(r.depthScale,.22),.05,.45),curve:_e(r.curve,10),parallax:Wr(r.parallax),focusOffsetX:_e(r.focusOffsetX,-15),focusScale:Ae(_e(r.focusScale,1.07),.8,1.4),perspective:_e(r.perspective,1100),respectReducedMotion:r.respectReducedMotion??!0,onChange:typeof r.onChange=="function"?r.onChange:void 0}}function Jt(r){let e=Array.from(r.querySelectorAll("[data-fx-slide]"));return e.length>0?e:Array.from(r.children).filter(t=>t instanceof HTMLElement&&!t.hasAttribute("data-fluxfx-canvas"))}function ct(r,e,t,o){let i=r-e;if(o&&t>2){let s=t/2;for(;i>s;)i-=t;for(;i<-s;)i+=t}return i}var Zt={name:"depth-carousel",mount(r,e){let t=r.style.position,o=r.style.perspective,i=r.style.transformStyle;typeof window<"u"&&getComputedStyle(r).position==="static"&&(r.style.position="relative");let s=Jt(r),n=new Map,l=()=>{s=Jt(r);for(let d of s)n.has(d)||n.set(d,{el:d,transform:d.style.transform,opacity:d.style.opacity,zIndex:d.style.zIndex,filter:d.style.filter,pointerEvents:d.style.pointerEvents,willChange:d.style.willChange})};l();let a=jt(e,s.length);r.style.perspective=`${a.perspective}px`,r.style.transformStyle="preserve-3d";let u=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,c=a.respectReducedMotion&&(u?.matches??!1),f=a.activeIndex,m=a.activeIndex,p=a.focused?1:0,h=a.focused?1:0,v=0,g=0,x=0,y=0,M=!0,S=!1,k=null,B=null,D=null,F=!1,C=(d=!1)=>{(d||c)&&(f=m,p=h,v=x,g=y);let b=s.length;if(b!==0)for(let T=0;T<b;T++){let R=s[T],A=ct(T,f,b,a.wrap),_=Math.abs(A),K=A*a.spread,oe=Math.max(.45,1-_*a.depthScale),he=-_*160,Le=Ae(-A*a.curve,-32,32),we=_>2.35?0:Math.max(.18,1-_*.32),se=_<.5,$e=se?a.focusOffsetX:K*1.45,et=se?a.focusScale:oe*.85,Be=se?1:0,He=K+($e-K)*p,Ue=oe+(et-oe)*p,Ve=he*(1-p*.5),Ce=Le*(1-p),Ye=we+(Be-we)*p,Ke=Math.max(.25,1-_*.25),tt=v*a.parallax*Ke,We=g*(a.parallax*.55)*Ke,wt=Math.max(1,20-Math.round(_*4)),ke=_>1.2&&p<.5?Math.min(2.5,(_-1.2)*1.5):0;c||(R.style.willChange="transform, opacity"),R.style.zIndex=String(wt),R.style.opacity=Ye.toFixed(3),R.style.pointerEvents=Ye<.08?"none":"auto",R.style.filter=ke>.1?`blur(${ke.toFixed(2)}px)`:"",R.style.transform=`translate3d(calc(${He.toFixed(2)}% + ${tt.toFixed(2)}px), ${We.toFixed(2)}px, ${Ve.toFixed(1)}px) rotateY(${Ce.toFixed(2)}deg) scale(${Ue.toFixed(4)})`;let L=T===Math.round(m)?"true":"false";R.getAttribute("data-fx-active")!==L&&R.setAttribute("data-fx-active",L)}},U=()=>{let d=Ae(Math.round(m),0,Math.max(0,s.length-1)),b=s[d]??null;a.onChange?.({index:d,focused:h>.5,element:b}),r.dispatchEvent(new CustomEvent("fluxfx:change",{bubbles:!0,detail:{index:d,focused:h>.5,element:b}}))},O=(d,b)=>{let T=s.length;if(T===0)return;let R=d;a.wrap?R=(d%T+T)%T:R=Ae(d,0,T-1);let A=m,_=h;if(a.wrap&&T>2){let K=ct(R,f,T,!0);m=f+K,m=R}else m=R;typeof b=="boolean"&&(h=b?1:0),(m!==A||h!==_)&&U(),M=!0,c?(C(!0),M=!1):S||k?.()},G=d=>{if(S||c)return;let b=r.getBoundingClientRect();b.width<=0||b.height<=0||(x=Ae(((d.clientX-b.left)/b.width-.5)*2,-1,1),y=Ae(((d.clientY-b.top)/b.height-.5)*2,-1,1),B!==null&&D===d.pointerId&&Math.abs(d.clientX-B)>22&&(F=!0),M=!0,k?.())},V=()=>{c||(x=0,y=0,M=!0,S||k?.())},Q=d=>{S||d.button!==0||(B=d.clientX,D=d.pointerId,F=!1)},Y=d=>{if(B===null||D!==d.pointerId)return;let b=d.clientX-B;if(B=null,D=null,Math.abs(b)>48&&h<.5){let T=b<0?1:-1;O(m+T)}},E=d=>{if(S)return;if(F){F=!1;return}let b=d.target;if(b){if(b.closest("[data-fx-prev]")){O(m-1,!1);return}if(b.closest("[data-fx-next]")){O(m+1,!1);return}for(let T=0;T<s.length;T++)if(s[T]===b||s[T].contains(b)){T!==Math.round(m)?O(T,!1):a.clickToFocus&&O(T,h<.5);return}}},P=d=>{c=a.respectReducedMotion&&d.matches,c&&(C(!0),M=!1),k?.()};return u&&typeof u.addEventListener=="function"&&u.addEventListener("change",P),r.addEventListener("pointermove",G,{passive:!0}),r.addEventListener("pointerleave",V,{passive:!0}),r.addEventListener("pointerdown",Q,{passive:!0}),window.addEventListener("pointerup",Y,{passive:!0}),r.addEventListener("click",E),C(!0),M=!1,{update(d,b){if(!M||S||c)return;let T=Math.min(b,.05),R=1-Math.exp(-10.5*T),A=1-Math.exp(-8*T),_=ct(m,f,s.length,a.wrap);f+=_*R,a.wrap&&s.length>0&&(f=(f%s.length+s.length)%s.length),p+=(h-p)*R,v+=(x-v)*A,g+=(y-g)*A,C(!1);let K=Math.abs(ct(m,f,s.length,a.wrap))<.002,oe=Math.abs(h-p)<.003,he=Math.abs(x-v)<.003&&Math.abs(y-g)<.003;K&&oe&&he&&(C(!0),M=!1)},setOptions(d){l();let b=a;a=jt(d,s.length),a.perspective!==b.perspective&&(r.style.perspective=`${a.perspective}px`);let T=d.focused!==void 0?a.focused:h>.5,R=d.activeIndex!==void 0?a.activeIndex:m,A=Math.round(R)!==Math.round(m)||T!==h>.5;m=R,h=T?1:0,A&&U(),M=!0,c?(C(!0),M=!1):S||k?.()},isIdle(){return!M||S||c},onWake(d){k=d},pause(){S=!0},resume(){S=!1,M&&!c&&k?.()},destroy(){k=null,M=!1,u&&typeof u.removeEventListener=="function"&&u.removeEventListener("change",P),r.removeEventListener("pointermove",G),r.removeEventListener("pointerleave",V),r.removeEventListener("pointerdown",Q),window.removeEventListener("pointerup",Y),r.removeEventListener("click",E),n.forEach(d=>{d.el.style.transform=d.transform,d.el.style.opacity=d.opacity,d.el.style.zIndex=d.zIndex,d.el.style.filter=d.filter,d.el.style.pointerEvents=d.pointerEvents,d.el.style.willChange=d.willChange,d.el.removeAttribute("data-fx-active")}),n.clear(),r.style.position=t,r.style.perspective=o,r.style.transformStyle=i}}}};function fe(r){return Math.min(1,Math.max(0,r))}function xe(r,e,t){return Math.min(t,Math.max(e,r))}function de(r,e){return typeof r=="number"&&!Number.isNaN(r)?r:e}function ut(r,e){if(typeof r=="boolean")return r;if(typeof r=="string"){let t=r.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}return e}function ge(r,e=""){return typeof r=="string"?r.trim():e}function zr(r){return Array.isArray(r)?r.filter(e=>typeof e=="string"&&e.trim().length>0).map(e=>e.trim()):typeof r=="string"&&r.trim().length>0?r.split(",").map(e=>e.trim()).filter(Boolean):[]}function Gr(r){let e=r.trim().replace(/^#/,"");if(e.length===3){let t=parseInt(e[0]+e[0],16),o=parseInt(e[1]+e[1],16),i=parseInt(e[2]+e[2],16);return[t,o,i].some(Number.isNaN)?null:[t,o,i]}if(e.length===6){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),i=parseInt(e.slice(4,6),16);return[t,o,i].some(Number.isNaN)?null:[t,o,i]}return null}function er(r){let e=ge(r.trigger,"cursor").toLowerCase(),t=e==="scroll"||e==="both"?e:"cursor",o=ge(r.axis,"x").toLowerCase(),i=o==="y"||o==="xy"?o:"x",s=ge(r.mode,"auto").toLowerCase(),n=s==="atlas"||s==="video"||s==="sprite"?s:"auto",a=ge(r.trackTarget,"window").toLowerCase()==="element"?"element":"window",c=ge(r.fit,"contain").toLowerCase()==="cover"?"cover":"contain",f=ge(r.position,"center").toLowerCase(),m=f==="top"||f==="bottom"?f:"center",p=Math.max(1,Math.round(de(r.cols,1))),h=Math.max(1,Math.round(de(r.rows,1))),v=p*h>1?p*h:48;return{videoSrc:ge(r.videoSrc)||ge(r.src),spriteSrc:ge(r.spriteSrc),frames:zr(r.frames),poster:ge(r.poster),cols:p,rows:h,frameCount:xe(Math.round(de(r.frameCount,v)),2,180),mode:n,trigger:t,axis:i,trackTarget:a,sensitivity:xe(de(r.sensitivity,1),.1,4),damping:xe(de(r.damping,10),1,40),idlePosition:fe(de(r.idlePosition,.5)),idleTimeout:Math.max(0,de(r.idleTimeout,0)),returnToIdle:ut(r.returnToIdle,!0),invert:ut(r.invert,!1),clamp:ut(r.clamp,!0),fit:c,position:m,startOffset:Math.max(0,de(r.startOffset,0)),endOffset:Math.max(0,de(r.endOffset,0)),chromaKey:ge(r.chromaKey),chromaTolerance:xe(de(r.chromaTolerance,.22),.01,.65),chromaSoftness:xe(de(r.chromaSoftness,.12),0,.45),crossfade:ut(r.crossfade,!1),targetFps:xe(Math.round(de(r.targetFps,0)),0,120),tileInset:xe(de(r.tileInset,.016),0,.08),maxCacheWidth:xe(Math.round(de(r.maxCacheWidth,720)),160,1920),blendMode:ge(r.blendMode,"normal")||"normal",respectReducedMotion:r.respectReducedMotion??!0,onProgress:typeof r.onProgress=="function"?r.onProgress:void 0}}function be(r,e,t,o,i,s,n,l,a=0,u=0,c=t,f=o){if(c<=0||f<=0||i<=0||s<=0)return;let m=n==="cover"?Math.max(i/c,s/f):Math.min(i/c,s/f),p=c*m,h=f*m,v=(i-p)*.5,g=(s-h)*.5;l==="top"?g=0:l==="bottom"&&(g=s-h),r.drawImage(e,a,u,c,f,v,g,p,h)}function Xr(r,e,t,o,i,s){if(!o)return;let n=r.getImageData(0,0,e,t),l=n.data,a=null;if(o.toLowerCase()==="auto"?a=[l[0],l[1],l[2]]:a=Gr(o),!a)return;let[u,c,f]=a,m=c>u+28&&c>f+28,p=f>u+28&&f>c+28,h=441.67295593,v=i*h,g=Math.max(4,s*h);for(let x=0;x<l.length;x+=4){let y=l[x+3];if(y===0)continue;let M=l[x],S=l[x+1],k=l[x+2],B=M-u,D=S-c,F=k-f,C=Math.sqrt(B*B+D*D+F*F);if(m){let U=Math.max(M,k),O=S-U;if(O>0){let Q=fe(O/Math.max(18,c*.25));S=Math.round(S-O*(.68+.32*Q)),l[x+1]=S}let G=h*(1-fe(O/Math.max(40,c*.68))),V=O>12?Math.min(C,G*.92+C*.25):C+65;if(V<=v)l[x+3]=0;else if(V<v+g){let Q=(V-v)/g,Y=Q*Q*(3-2*Q);l[x+3]=Math.round(y*Y)}}else if(p){let U=Math.max(M,S),O=k-U;O>0&&(l[x+2]=Math.round(k-O*.72));let G=h*(1-fe(O/Math.max(40,f*.68))),V=O>12?Math.min(C,G*.92+C*.25):C+65;if(V<=v)l[x+3]=0;else if(V<v+g){let Q=(V-v)/g,Y=Q*Q*(3-2*Q);l[x+3]=Math.round(y*Y)}}else if(C<=v)l[x+3]=0;else if(C<v+g){let U=(C-v)/g,O=U*U*(3-2*U);l[x+3]=Math.round(y*O)}}r.putImageData(n,0,0)}var tr={name:"motion-scrub",mount(r,e){let t=r.style.position,o=r.style.overflow;typeof window<"u"&&getComputedStyle(r).position==="static"&&(r.style.position="relative"),r.style.overflow=r.style.overflow||"hidden";let i=er(e),s=document.createElement("canvas");s.setAttribute("data-fluxfx-scrub-canvas","true"),Object.assign(s.style,{position:"absolute",inset:"0",width:"100%",height:"100%",display:"block",pointerEvents:"none",zIndex:"0",mixBlendMode:i.blendMode});let n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.preload="auto",n.setAttribute("aria-hidden","true"),Object.assign(n.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"0",display:"none",mixBlendMode:i.blendMode}),r.prepend(n),r.prepend(s);let l=s.getContext("2d",{alpha:!0}),a=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,u=i.respectReducedMotion&&(a?.matches??!1),c=i.idlePosition,f=i.idlePosition,m=i.idlePosition,p=i.idlePosition,h=i.idlePosition,v=i.idlePosition,g=.5,x=.5,y=!1,M=!1,S=!1,k=null,B=null,D=0,F="atlas",C=[],U=null,O=null,G=!1,V=-1,Q=0,Y=!1,E=null,P=0,d=0,b=0,T=()=>{B!==null&&(window.clearTimeout(B),B=null)},R=()=>{T(),!(!i.returnToIdle||i.idleTimeout<=0||i.trigger==="scroll")&&(B=window.setTimeout(()=>{B=null,!(S||u)&&(f=i.idlePosition,p=i.idlePosition,v=i.idlePosition,y=!0,M||k?.())},i.idleTimeout))},A=()=>{for(let L=0;L<C.length;L++){let w=C[L];if(w&&"close"in w&&typeof w.close=="function")try{w.close()}catch{}}C=[],U=null,G=!1,V=-1},_=()=>{let L=r.getBoundingClientRect(),w=Math.min(window.devicePixelRatio||1,2),I=Math.max(1,Math.round(L.width*w)),W=Math.max(1,Math.round(L.height*w));(I!==d||W!==b)&&(d=I,b=W,s.width=I,s.height=W,V=-1)},K=L=>{if(C[L])return C[L];for(let w=1;w<C.length;w++){if(L-w>=0&&C[L-w])return C[L-w];if(L+w<C.length&&C[L+w])return C[L+w]}return null},oe=L=>{let w=Math.max(.05,L),I=Math.min(i.startOffset,w-.05),W=Math.max(I+.05,w-i.endOffset);return{start:I,span:Math.max(.05,W-I)}},he=L=>{if(!P||n.readyState<1)return;let{start:w,span:I}=oe(P),W=xe(w+L*I,0,Math.max(0,P-.001));if(Y){E=W;return}if(!(Math.abs(n.currentTime-W)<.008))if(Y=!0,typeof n.fastSeek=="function")try{n.fastSeek(W)}catch{n.currentTime=W}else n.currentTime=W},Le=()=>{if(Y=!1,F==="video"&&l&&s.style.display!=="none"&&n.videoWidth>0&&(_(),l.clearRect(0,0,d,b),be(l,n,n.videoWidth,n.videoHeight,d,b,i.fit,i.position)),E!==null&&F==="video"){let L=E;E=null,Math.abs(n.currentTime-L)>=.008&&(Y=!0,n.currentTime=L)}};n.addEventListener("seeked",Le);let we=(L,w,I)=>{let W={progress:L,frame:w,totalFrames:I,ready:G,mode:F};i.onProgress?.(W),r.dispatchEvent(new CustomEvent("fluxfx:scrub",{bubbles:!0,detail:W}))},se=(L,w=!1)=>{let I=fe(L);if(F==="video"){n.style.display!=="none"&&(n.style.objectFit=i.fit,n.style.objectPosition=i.position==="top"?"center top":i.position==="bottom"?"center bottom":"center center"),he(I);let Z=i.frameCount,q=Math.round(I*(Z-1));(w||q!==V)&&(V=q,we(I,q,Z));return}if(!l)return;if(_(),l.imageSmoothingEnabled=!0,l.imageSmoothingQuality="high",F==="sprite"&&C.length>0){if(i.axis==="xy"&&i.cols>1&&i.rows>1){let Ee=fe(m)*(i.cols-1),Fe=fe(h)*(i.rows-1),Re=Math.floor(Ee),Pe=Math.floor(Fe),ze=Math.min(i.cols-1,Re+1),De=Math.min(i.rows-1,Pe+1),Ie=Ee-Re,ue=Fe-Pe,Oe=Math.round(Fe)*i.cols+Math.round(Ee),ve=C[Oe]??K(Oe);if(!ve)return;let ye="width"in ve?ve.width:0,je="height"in ve?ve.height:0;l.clearRect(0,0,d,b),l.save();let nr=(m-.5)*d*.018,Ct=1.032+Math.abs(m-.5)*.012;if(l.translate(d*.5+nr,b),l.rotate((m-.5)*.022),l.scale(Ct,Ct),l.translate(-d*.5,-b),!i.crossfade)l.globalAlpha=1,be(l,ve,ye,je,d,b,i.fit,i.position);else{let lr=C[Pe*i.cols+Re]??ve,cr=C[Pe*i.cols+ze]??ve,ur=C[De*i.cols+Re]??ve,dr=C[De*i.cols+ze]??ve;l.globalAlpha=1,be(l,lr,ye,je,d,b,i.fit,i.position),ze!==Re&&Ie>.01&&(l.globalAlpha=Ie,be(l,cr,ye,je,d,b,i.fit,i.position)),De!==Pe&&ue>.01&&(l.globalAlpha=ue,be(l,ur,ye,je,d,b,i.fit,i.position)),ze!==Re&&De!==Pe&&Ie>.01&&ue>.01&&(l.globalAlpha=Ie*ue,be(l,dr,ye,je,d,b,i.fit,i.position))}l.restore();let ar=i.cols*i.rows;(w||Oe!==V)&&(V=Oe,we(I,Oe,ar));return}let q=Math.max(1,Math.min(i.frameCount,C.length)),ne=I*(q-1),re=Math.floor(ne),pe=Math.min(q-1,re+1),H=ne-re,$=Math.round(ne);if(!i.crossfade&&!w&&$===V)return;let N=C[$]??K($);if(!N)return;let z="width"in N?N.width:0,ee="height"in N?N.height:0;if(l.clearRect(0,0,d,b),!i.crossfade)l.globalAlpha=1,be(l,N,z,ee,d,b,i.fit,i.position);else{let Ee=C[re]??N,Fe=C[pe]??N;l.globalAlpha=1,be(l,Ee,z,ee,d,b,i.fit,i.position),pe!==re&&H>.01&&(l.globalAlpha=H,be(l,Fe,z,ee,d,b,i.fit,i.position))}(w||$!==V)&&(V=$,we(I,$,q));return}if(F==="sprite"&&U){let Z="naturalWidth"in U&&U.naturalWidth>0?U.naturalWidth:U.width,q="naturalHeight"in U&&U.naturalHeight>0?U.naturalHeight:U.height;if(Z<=0||q<=0)return;let ne=Z/i.cols,re=q/i.rows,pe=Math.max(1,Math.min(i.frameCount,i.cols*i.rows)),H=Math.round(I*(pe-1));if(!w&&H===V)return;let $=H%i.cols,N=Math.floor(H/i.cols),z=ne*i.tileInset,ee=re*i.tileInset;l.clearRect(0,0,d,b),be(l,U,Z,q,d,b,i.fit,i.position,$*ne+z,N*re+ee,ne-z*2,re-ee*2),V=H,we(I,H,pe);return}let W=C.length;if(W>0){let Z=Math.round(I*(W-1));if(!w&&Z===V)return;let q=K(Z);if(q){V=Z;let ne="width"in q?q.width:0,re="height"in q?q.height:0;l.clearRect(0,0,d,b),be(l,q,ne,re,d,b,i.fit,i.position),we(I,Z,W);return}}O&&O.complete&&O.naturalWidth>0&&(l.clearRect(0,0,d,b),be(l,O,O.naturalWidth,O.naturalHeight,d,b,i.fit,i.position))},$e=async(L,w,I,W=0,Z=0,q=w,ne=I)=>{if(q<=0||ne<=0)return null;let re=Math.min(1,i.maxCacheWidth/q),pe=Math.max(1,Math.round(q*re)),H=Math.max(1,Math.round(ne*re)),$=document.createElement("canvas");$.width=pe,$.height=H;let N=$.getContext("2d",{willReadFrequently:!!i.chromaKey});if(!N)return null;if(N.imageSmoothingEnabled=!0,N.imageSmoothingQuality="high",N.drawImage(L,W,Z,q,ne,0,0,pe,H),i.chromaKey&&Xr(N,pe,H,i.chromaKey,i.chromaTolerance,i.chromaSoftness),typeof createImageBitmap=="function")try{return await createImageBitmap($)}catch{return $}return $},et=async()=>{let L=++D;if(A(),s.style.mixBlendMode=i.blendMode,n.style.mixBlendMode=i.blendMode,s.style.display="block",n.style.display="none",i.poster){let H=new Image;H.crossOrigin="anonymous",H.onload=()=>{L!==D||S||(O=H,G||se(c,!0))},H.src=i.poster}if((i.mode==="sprite"||i.mode==="auto"&&i.spriteSrc)&&i.spriteSrc){F="sprite";let H=new Image;H.crossOrigin="anonymous",H.onload=async()=>{if(L!==D||S)return;let $=H.naturalWidth,N=H.naturalHeight,z=Math.max(1,Math.min(i.frameCount,i.cols*i.rows));if($>0&&N>0){let ee=$/i.cols,Ee=N/i.rows,Fe=ee*i.tileInset,Re=Ee*i.tileInset,Pe=Math.max(1,ee-Fe*2),ze=Math.max(1,Ee-Re*2);C=new Array(z).fill(null);let De=xe(Math.round(c*(z-1)),0,z-1),Ie=[De];for(let ue=0;ue<z;ue++)ue!==De&&Ie.push(ue);try{for(let ue of Ie){if(L!==D||S)return;let Oe=ue%i.cols,ve=Math.floor(ue/i.cols),ye=await $e(H,$,N,Oe*ee+Fe,ve*Ee+Re,Pe,ze);if(L!==D||S){ye&&"close"in ye&&typeof ye.close=="function"&&ye.close();return}C[ue]=ye,G=!0,ue===De&&se(c,!0)}}catch{U=H,G=!0}}else U=H,G=!0;L===D&&!S&&se(c,!0)},H.src=i.spriteSrc;return}if(i.frames.length>0&&!i.videoSrc){F="frames",C=new Array(i.frames.length).fill(null),await Promise.all(i.frames.map((H,$)=>new Promise(N=>{let z=new Image;z.crossOrigin="anonymous",z.onload=async()=>{if(L!==D||S){N();return}let ee=await $e(z,z.naturalWidth,z.naturalHeight);if(L!==D||S){ee&&"close"in ee&&typeof ee.close=="function"&&ee.close(),N();return}C[$]=ee,G=!0,$===Math.round(c*(i.frames.length-1))&&se(c,!0),N()},z.onerror=()=>N(),z.src=H}))),L===D&&!S&&se(c,!0);return}if(!i.videoSrc)return;let w=H=>new Promise($=>{let N=()=>{ee(),$(!0)},z=()=>{ee(),$(!1)},ee=()=>{n.removeEventListener("loadeddata",N),n.removeEventListener("error",z)};n.crossOrigin=H?"anonymous":"",H||n.removeAttribute("crossorigin"),n.addEventListener("loadeddata",N,{once:!0}),n.addEventListener("error",z,{once:!0}),n.src=i.videoSrc,n.load()}),I=await w(!0),W=I;if(I||(I=await w(!1),W=!1),!I||L!==D||S||(P=Number.isFinite(n.duration)?n.duration:0,!P||n.videoWidth<=0))return;if(i.mode==="video"||!W){F="video",s.style.display="none",n.style.display="block",G=!0,se(c,!0);return}F="atlas";let Z=i.frameCount;C=new Array(Z).fill(null);let{start:q,span:ne}=oe(P),re=xe(Math.round(c*(Z-1)),0,Z-1),pe=[re];for(let H=0;H<Z;H++)H!==re&&pe.push(H);for(let H of pe){if(L!==D||S)return;let $=xe(q+H/Math.max(1,Z-1)*ne,0,Math.max(0,P-.002));if(!await new Promise(z=>{let ee=()=>{n.removeEventListener("seeked",ee),z(!0)};n.addEventListener("seeked",ee,{once:!0}),n.currentTime=$})||L!==D||S)return;try{let z=await $e(n,n.videoWidth,n.videoHeight);if(L!==D||S){z&&"close"in z&&typeof z.close=="function"&&z.close();return}C[H]=z,G=!0,(H===re||H===Math.round(c*(Z-1)))&&se(c,!0)}catch{F="video",s.style.display="none",n.style.display="block",G=!0,se(c,!0);return}await new Promise(z=>setTimeout(z,0))}L===D&&!S&&(n.removeAttribute("src"),n.load(),se(c,!0))},Be=L=>{let w=(L-.5)*i.sensitivity+.5,I=i.invert?1-w:w;return i.clamp?fe(I):I},He=L=>{let w=i.idlePosition;i.trigger!=="scroll"&&(p=fe(Be(g)),v=fe(Be(x)));let I=.5;if(i.axis==="x"?I=g:i.axis==="y"?I=x:I=g*.65+x*.35,i.trigger==="cursor")w=Be(I);else if(i.trigger==="scroll"){let W=L??Ue();w=Be(W)}else{let W=L??Ue();w=Be(I*.5+W*.5)}return fe(w)},Ue=()=>{if(typeof window>"u")return .5;let L=r.getBoundingClientRect(),w=window.innerHeight||document.documentElement.clientHeight||800,I=w+L.height;return I<=0?.5:fe((w-L.top)/I)},Ve=L=>{if(M||u||i.trigger==="scroll")return;let w=r.getBoundingClientRect();if(i.trackTarget==="element"){if(w.width<=0||w.height<=0)return;g=(L.clientX-w.left)/w.width,x=(L.clientY-w.top)/w.height}else{let I=window.innerWidth||document.documentElement.clientWidth||1,W=window.innerHeight||document.documentElement.clientHeight||1,Z=w.width>0?w.left+w.width*.5:I*.5,q=w.height>0?w.top+w.height*.44:W*.5,ne=Math.max(220,I*.38),re=Math.max(180,W*.36);g=fe(.5+(L.clientX-Z)/(ne*2)),x=fe(.5+(L.clientY-q)/(re*2))}f=He(),y=!0,R(),k?.()},Ce=()=>{u||!i.returnToIdle||i.trigger==="scroll"||(T(),f=i.idlePosition,p=i.idlePosition,v=i.idlePosition,y=!0,M||k?.())},Ye=()=>{M||u||i.trigger==="cursor"||(f=He(Ue()),y=!0,k?.())},Ke=()=>{_(),se(c,!0)},tt=L=>{let w=i.respectReducedMotion&&L.matches;u!==w&&(u=w,u&&(T(),c=i.idlePosition,f=i.idlePosition,m=i.idlePosition,p=i.idlePosition,h=i.idlePosition,v=i.idlePosition,y=!1,se(c,!0)),k?.())},We=null;typeof ResizeObserver<"u"&&(We=new ResizeObserver(Ke),We.observe(r)),a&&typeof a.addEventListener=="function"&&a.addEventListener("change",tt);let ke=i.trackTarget==="element"?r:window;return ke.addEventListener("pointermove",Ve,{passive:!0}),i.trackTarget==="element"?r.addEventListener("pointerleave",Ce,{passive:!0}):document.addEventListener("pointerleave",Ce,{passive:!0}),window.addEventListener("scroll",Ye,{passive:!0}),(i.trigger==="scroll"||i.trigger==="both")&&(c=He(Ue()),f=c),et(),{update(L,w){if(!y||M||u)return;let I=1-Math.exp(-i.damping*w);if(c+=(f-c)*I,m+=(p-m)*I,h+=(v-h)*I,Math.abs(f-c)<8e-4&&Math.abs(p-m)<8e-4&&Math.abs(v-h)<8e-4&&(c=f,m=p,h=v,y=!1),i.targetFps>0&&y){let W=1/i.targetFps;if(L-Q<W*.92)return}Q=L,se(c)},setOptions(L){let w=i;i=er(L),s.style.mixBlendMode=i.blendMode,n.style.mixBlendMode=i.blendMode,w.trackTarget!==i.trackTarget&&(ke.removeEventListener("pointermove",Ve),r.removeEventListener("pointerleave",Ce),document.removeEventListener("pointerleave",Ce),ke=i.trackTarget==="element"?r:window,ke.addEventListener("pointermove",Ve,{passive:!0}),i.trackTarget==="element"?r.addEventListener("pointerleave",Ce,{passive:!0}):document.addEventListener("pointerleave",Ce,{passive:!0})),w.videoSrc!==i.videoSrc||w.spriteSrc!==i.spriteSrc||w.mode!==i.mode||w.frameCount!==i.frameCount||w.cols!==i.cols||w.rows!==i.rows||w.chromaKey!==i.chromaKey||w.chromaTolerance!==i.chromaTolerance||w.chromaSoftness!==i.chromaSoftness||w.tileInset!==i.tileInset||w.startOffset!==i.startOffset||w.endOffset!==i.endOffset||w.maxCacheWidth!==i.maxCacheWidth||w.frames.join("|")!==i.frames.join("|")?et():se(c,!0),(i.trigger==="scroll"||i.trigger==="both")&&(f=He(Ue()),y=!0),k?.()},resize:Ke,isIdle(){return!y||M||u},onWake(L){k=L},pause(){M=!0,T()},resume(){M=!1,y&&!u&&k?.()},destroy(){S=!0,D++,k=null,y=!1,T(),A(),We?.disconnect(),We=null,a&&typeof a.removeEventListener=="function"&&a.removeEventListener("change",tt),ke.removeEventListener("pointermove",Ve),r.removeEventListener("pointerleave",Ce),document.removeEventListener("pointerleave",Ce),window.removeEventListener("scroll",Ye),n.removeEventListener("seeked",Le),n.removeAttribute("src"),n.load(),n.remove(),s.remove(),r.style.position=t,r.style.overflow=o}}}};function Qe(r){return Math.min(1,Math.max(0,r))}function yt(r,e,t){return Math.min(t,Math.max(e,r))}function Tt(r,e){return typeof r=="number"&&!Number.isNaN(r)?r:e}function Nr(r,e){if(typeof r=="boolean")return r;if(typeof r=="string"){let t=r.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}return e}function rr(r){return{pathSelector:typeof r.pathSelector=="string"&&r.pathSelector.trim()?r.pathSelector.trim():"[data-fx-path], path",damping:yt(Tt(r.damping,10),1,40),offsetTop:yt(Tt(r.offsetTop,.72),.05,.98),offsetBottom:yt(Tt(r.offsetBottom,.35),.02,.95),once:Nr(r.once,!1),respectReducedMotion:r.respectReducedMotion??!0,onWaypoint:typeof r.onWaypoint=="function"?r.onWaypoint:void 0}}var Qr=0,ir={name:"scroll-path",mount(r,e){let t=rr(e),o=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,i=t.respectReducedMotion&&(o?.matches??!1),s=r.querySelector(t.pathSelector),n=s?.ownerSVGElement??null,l=Array.from(r.querySelectorAll("[data-fx-waypoint]")),a=s?s.style.strokeDasharray:"",u=s?s.style.strokeDashoffset:"",c=s?s.getAttribute("mask"):null,f=r.style.getPropertyValue("--fx-scroll-progress"),m=0,p=!1,h=null,v=null,g=null;(()=>{if(!s||typeof s.getTotalLength!="function")return;m=Math.max(1,s.getTotalLength());let E=s.getAttribute("stroke-dasharray")||(typeof window<"u"?getComputedStyle(s).strokeDasharray:"none");if(E&&E!=="none"&&E!=="0px"&&!E.startsWith(`${Math.round(m)}`)&&n){p=!0;let d="http://www.w3.org/2000/svg",b=n.querySelector("defs");b||(b=document.createElementNS(d,"defs"),n.prepend(b),g=b);let T=`fluxfx-scroll-mask-${++Qr}`,R=document.createElementNS(d,"mask");R.setAttribute("id",T),R.setAttribute("maskUnits","userSpaceOnUse");let A=s.cloneNode(!1);A.removeAttribute("id"),A.removeAttribute("data-fx-path"),A.removeAttribute("stroke-dasharray"),A.removeAttribute("stroke-dashoffset"),A.setAttribute("fill","none"),A.setAttribute("stroke","#ffffff");let _=parseFloat(s.getAttribute("stroke-width")||getComputedStyle(s).strokeWidth||"3");A.setAttribute("stroke-width",String(Math.max(4,_+6))),A.style.strokeDasharray=`${m}`,A.style.strokeDashoffset=`${m}`,R.appendChild(A),b.appendChild(R),s.setAttribute("mask",`url(#${T})`),v=R,h=A}else p=!1,s.style.strokeDasharray=`${m}`,s.style.strokeDashoffset=`${m}`})();let y=new WeakMap,M=0,S=0,k=!1,B=!1,D=null,F=()=>{if(typeof window>"u")return!1;let P=getComputedStyle(r).overflowY;return(P==="auto"||P==="scroll")&&r.scrollHeight>r.clientHeight+4},C=()=>{if(typeof window>"u")return 1;if(F()){let A=Math.max(1,r.scrollHeight-r.clientHeight);return Qe(r.scrollTop/A)}let E=r.getBoundingClientRect(),P=window.innerHeight||document.documentElement.clientHeight||800,d=P*t.offsetTop,b=P*t.offsetBottom,T=Math.max(1,E.height+(d-b)),R=d-E.top;return Qe(R/T)},U=E=>{let P=Qe(E);if(r.style.setProperty("--fx-scroll-progress",P.toFixed(4)),s&&m>0){let R=m*(1-P);p&&h?h.style.strokeDashoffset=R.toFixed(2):s.style.strokeDashoffset=R.toFixed(2)}let d=r.getBoundingClientRect(),b=F(),T=Math.max(1,b?r.scrollHeight:d.height);for(let R=0;R<l.length;R++){let A=l[R],_=A.getAttribute("data-fx-at"),K;if(_!==null&&!Number.isNaN(Number(_)))K=Qe(Number(_));else if(b)K=Qe((A.offsetTop-r.clientHeight*.35)/T);else{let Le=A.getBoundingClientRect();K=Qe((Le.top-d.top)/T)}let oe=y.get(A)??!1,he=P>=K||t.once&&oe;he!==oe&&(y.set(A,he),he?(A.setAttribute("data-fx-reached","true"),t.onWaypoint?.({element:A,index:R,progress:P}),A.dispatchEvent(new CustomEvent("fluxfx:waypoint",{bubbles:!0,detail:{element:A,index:R,progress:P}}))):t.once||A.removeAttribute("data-fx-reached"))}},O=()=>{S=i?1:C(),i?(M=1,k=!1,U(1)):(k=!0,D?.())},G=()=>{B||i||(S=C(),Math.abs(S-M)>5e-4&&(k=!0,D?.()))},V=()=>{s&&typeof s.getTotalLength=="function"&&(m=Math.max(1,s.getTotalLength()),p&&h?h.style.strokeDasharray=`${m}`:s.style.strokeDasharray=`${m}`),O()},Q=E=>{let P=t.respectReducedMotion&&E.matches;i!==P&&(i=P,O())},Y=null;return typeof ResizeObserver<"u"&&(Y=new ResizeObserver(V),Y.observe(r)),o&&typeof o.addEventListener=="function"&&o.addEventListener("change",Q),r.addEventListener("scroll",G,{passive:!0}),window.addEventListener("scroll",G,{passive:!0}),window.addEventListener("resize",V,{passive:!0}),M=i?1:C(),S=M,U(M),{update(E,P){if(!k||B||i)return;let d=1-Math.exp(-t.damping*P);M+=(S-M)*d,Math.abs(S-M)<8e-4&&(M=S,k=!1),U(M)},setOptions(E){t=rr(E),O()},resize:V,isIdle(){return!k||B||i},onWake(E){D=E},pause(){B=!0},resume(){B=!1,O()},destroy(){D=null,k=!1,Y?.disconnect(),Y=null,o&&typeof o.removeEventListener=="function"&&o.removeEventListener("change",Q),r.removeEventListener("scroll",G),window.removeEventListener("scroll",G),window.removeEventListener("resize",V),s&&(s.style.strokeDasharray=a,s.style.strokeDashoffset=u,c!==null?s.setAttribute("mask",c):s.removeAttribute("mask")),v?.remove(),g?.remove();for(let E of l)E.removeAttribute("data-fx-reached");f?r.style.setProperty("--fx-scroll-progress",f):r.style.removeProperty("--fx-scroll-progress")}}}};function qe(r,e,t){return Math.min(t,Math.max(e,r))}function qr(r){return qe(r,0,1)}function dt(r,e){return typeof r=="number"&&!Number.isNaN(r)?r:e}function or(r){return{cardSelector:typeof r.cardSelector=="string"&&r.cardSelector.trim()?r.cardSelector.trim():"[data-fx-stack-card]",tabSelector:typeof r.tabSelector=="string"&&r.tabSelector.trim()?r.tabSelector.trim():"[data-fx-stack-tab]",stickyTop:typeof r.stickyTop=="number"&&!Number.isNaN(r.stickyTop)?r.stickyTop:void 0,offsetStep:qe(dt(r.offsetStep,16),0,80),scaleStep:qe(dt(r.scaleStep,.045),0,.2),opacityStep:qe(dt(r.opacityStep,.08),0,.4),damping:qe(dt(r.damping,14),1,45),respectReducedMotion:r.respectReducedMotion??!0,onChange:typeof r.onChange=="function"?r.onChange:void 0}}function $r(r){return{position:r.style.position,top:r.style.top,zIndex:r.style.zIndex,transform:r.style.transform,transformOrigin:r.style.transformOrigin,opacity:r.style.opacity,willChange:r.style.willChange,transition:r.style.transition}}function Yr(r,e){r.style.position=e.position,r.style.top=e.top,r.style.zIndex=e.zIndex,r.style.transform=e.transform,r.style.transformOrigin=e.transformOrigin,r.style.opacity=e.opacity,r.style.willChange=e.willChange,r.style.transition=e.transition,delete r.dataset.stackDepth,delete r.dataset.active}var sr={name:"card-stack",mount(r,e){let t=or(e),o=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,i=t.respectReducedMotion&&(o?.matches??!1),s=r.querySelector("[data-fx-stack-nav]"),n=[],l=[],a=new Map,u=r.style.getPropertyValue("--fx-stack-active"),c=()=>{let E=Array.from(r.querySelectorAll(t.cardSelector)),P=E.length>0?E:Array.from(r.children).filter(d=>d instanceof HTMLElement&&!d.hasAttribute("data-fx-stack-nav"));for(let d of P)a.has(d)||a.set(d,$r(d));n=P,l=Array.from(r.querySelectorAll(t.tabSelector))};c();let f=()=>{if(typeof window>"u")return!1;let P=getComputedStyle(r).overflowY;return(P==="auto"||P==="scroll")&&r.scrollHeight>r.clientHeight+4},m=E=>{if(t.stickyTop!==void 0)return t.stickyTop;let P=s?s.offsetHeight+12:0;return E?12+P:92+P},p=[],h=[],v=n.map(()=>0),g=n.map(()=>0),x=-1,y=!1,M=!1,S=null,k=()=>{if(n.length===0)return;let E=f(),P=m(E);for(let T=0;T<n.length;T++)n[T].style.position="static",n[T].style.transform="none";let d=r.getBoundingClientRect(),b=E?r.scrollTop:0;p=new Array(n.length),h=new Array(n.length);for(let T=0;T<n.length;T++){let R=n[T],A=R.getBoundingClientRect();p[T]=A.top-d.top+b,h[T]=Math.max(120,A.height||R.offsetHeight||360)}for(let T=0;T<n.length;T++){let R=n[T];R.style.position="sticky",R.style.top=`${P}px`,R.style.zIndex=String(T+1),R.style.transformOrigin="center top",R.style.willChange="transform, opacity"}},B=E=>{if(E===x)return;x=E,r.style.setProperty("--fx-stack-active",String(E));for(let d=0;d<n.length;d++)n[d].dataset.active=d===E?"true":"false";for(let d=0;d<l.length;d++){let b=d===E;l[d].dataset.active=b?"true":"false",l[d].classList.toggle("is-active",b)}let P=n[E]??null;t.onChange?.({index:E,total:n.length,focused:!1,element:P}),r.dispatchEvent(new CustomEvent("fluxfx:stackchange",{bubbles:!0,detail:{index:E,total:n.length,element:P}}))},D=()=>{if(n.length===0)return;let E=f(),P=m(E),d=E?-r.scrollTop:r.getBoundingClientRect().top,b=new Array(n.length).fill(0),T=0;for(let R=1;R<n.length;R++){let A=d+p[R],_=Math.max(140,Math.min(h[R]*.85,460)),K=i?0:qr((P+_-A)/_);b[R]=K,A<=P+_*.55&&(T=R)}for(let R=0;R<n.length;R++){let A=0;for(let _=R+1;_<n.length;_++)A+=b[_];g[R]=A}B(T)},F=E=>{for(let P=0;P<n.length;P++){let d=i?0:E[P]??0,b=-d*t.offsetStep,T=Math.max(.55,1-d*t.scaleStep),R=Math.max(.25,1-d*t.opacityStep),A=n[P];A.style.transform=d<.001?"translate3d(0px, 0px, 0px) scale(1)":`translate3d(0px, ${b.toFixed(2)}px, 0px) scale(${T.toFixed(4)})`,A.style.opacity=R.toFixed(3),A.dataset.stackDepth=d.toFixed(3)}},C=()=>{k(),D(),v=g.slice(),F(v),y=!1},U=()=>{if(!M){if(D(),i){v=g.slice(),F(v);return}for(let E=0;E<g.length;E++)if(Math.abs((g[E]??0)-(v[E]??0))>5e-4){y=!0,S?.();break}}},O=()=>{k(),D(),y=!0,S?.()},G=E=>{let d=E.target?.closest(t.tabSelector);if(!d||!r.contains(d))return;let b=d.getAttribute("data-fx-stack-tab"),T=b!==null&&b!==""&&!Number.isNaN(Number(b))?Number(b):-1,R=T>=0?T:l.indexOf(d);if(R<0||R>=n.length)return;let A=f(),_=m(A);if(A){let K=Math.max(0,(p[R]??0)-_+2);r.scrollTo({top:K,behavior:i?"auto":"smooth"})}else{let K=r.getBoundingClientRect().top+window.scrollY,oe=Math.max(0,K+(p[R]??0)-_+2);window.scrollTo({top:oe,behavior:i?"auto":"smooth"})}},V=E=>{i=t.respectReducedMotion&&E.matches,C()};C();let Q=()=>{f()||U()};typeof window<"u"&&(window.addEventListener("scroll",Q,{passive:!0}),window.addEventListener("resize",O,{passive:!0})),r.addEventListener("scroll",U,{passive:!0}),r.addEventListener("click",G),o?.addEventListener("change",V);let Y=typeof ResizeObserver<"u"?new ResizeObserver(()=>O()):null;return Y?.observe(r),{onWake(E){S=E},isIdle(){return!y},pause(){M=!0},resume(){M=!1,U()},update(E,P){if(M||!y||i)return;let d=1-Math.exp(-t.damping*qe(P,.001,.05)),b=0;for(let T=0;T<g.length;T++){let R=g[T]??0,A=v[T]??0,_=Math.abs(R-A);_<5e-4?v[T]=R:(v[T]=A+(R-A)*d,_>b&&(b=_))}F(v),b<5e-4&&(y=!1)},updateOptions(E){t=or(E),i=t.respectReducedMotion&&(o?.matches??!1),c(),C()},destroy(){Y?.disconnect(),r.removeEventListener("scroll",U),r.removeEventListener("click",G),typeof window<"u"&&(window.removeEventListener("scroll",Q),window.removeEventListener("resize",O)),o?.removeEventListener("change",V),u?r.style.setProperty("--fx-stack-active",u):r.style.removeProperty("--fx-stack-active"),a.forEach((E,P)=>Yr(P,E));for(let E of l)delete E.dataset.active,E.classList.remove("is-active")}}}};lt.register(Ht).register(Vt).register(Wt).register(zt).register(Gt).register(Xt).register(qt).register($t).register(Yt).register(Kt).register(Zt).register(tr).register(ir).register(sr);var Mt=lt;typeof window<"u"&&(window.FluxFX=lt);function ce(r,e={},t=!1){let o=(0,X.useRef)(null),i=Array.isArray(r)?r.join(" "):r,s=JSON.stringify(e),n=(0,X.useRef)(s);n.current=s;let l=(0,X.useRef)(!1),a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{if(t||typeof window>"u")return;let u=o.current;if(!u||!i.trim())return;let c=n.current,f=JSON.parse(c),p=i.trim().split(/\s+/).map(h=>Mt.apply(u,h,f));return l.current=!0,a.current=c,()=>{l.current=!1,a.current=null,p.forEach(h=>h())}},[i,t]),(0,X.useEffect)(()=>{if(!l.current||t||typeof window>"u"||a.current===s)return;let u=o.current;if(!u||!i.trim())return;let c=JSON.parse(s);i.trim().split(/\s+/).forEach(m=>{Mt.update(u,m,c)}),a.current=s},[s,i,t]),o}function me(r){let{device:e,minWidth:t,maxWidth:o,disableOnMobile:i,disableOnDesktop:s,mobileBreakpoint:n,...l}=r;return{deviceOpts:{device:e,minWidth:t,maxWidth:o,disableOnMobile:i,disableOnDesktop:s,mobileBreakpoint:n},domRest:l}}function Kr({as:r="section",speed:e=1,quality:t="medium",colors:o=["#4f46e5","#06b6d4","#ec4899"],bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,interactive:h=!0,respectReducedMotion:v=!0,disabled:g=!1,children:x,...y}){let{deviceOpts:M,domRest:S}=me(y),k=ce("aurora",{speed:e,quality:t,colors:o,bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,interactive:h,respectReducedMotion:v,...M},g);return X.default.createElement(r,{ref:k,...S},x)}function jr({as:r="section",speed:e=1,quality:t="medium",colors:o=["#0f172a","#94a3b8","#38bdf8"],bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,interactive:h=!0,respectReducedMotion:v=!0,disabled:g=!1,children:x,...y}){let{deviceOpts:M,domRest:S}=me(y),k=ce("liquid-metal",{speed:e,quality:t,colors:o,bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,interactive:h,respectReducedMotion:v,...M},g);return X.default.createElement(r,{ref:k,...S},x)}function Jr({as:r="section",speed:e=1,quality:t="medium",colors:o=["#6366f1","#06b6d4","#f43f5e"],bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,dissipation:h=.975,radius:v=.0045,swirl:g=1.4,interactive:x=!0,respectReducedMotion:y=!0,disabled:M=!1,children:S,...k}){let{deviceOpts:B,domRest:D}=me(k),F=ce("fluid",{speed:e,quality:t,colors:o,bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,dissipation:h,radius:v,swirl:g,interactive:x,respectReducedMotion:y,...B},M);return X.default.createElement(r,{ref:F,...D},S)}function Zr({as:r="div",maxTilt:e=12,scale:t=1.03,perspective:o=900,glare:i=!0,respectReducedMotion:s=!0,disabled:n=!1,children:l,...a}){let{deviceOpts:u,domRest:c}=me(a),f=ce("tilt-3d",{maxTilt:e,scale:t,perspective:o,glare:i,respectReducedMotion:s,...u},n);return X.default.createElement(r,{ref:f,...c},l)}function ei({as:r="div",strength:e=.35,respectReducedMotion:t=!0,disabled:o=!1,style:i,children:s,...n}){let{deviceOpts:l,domRest:a}=me(n),u=ce("magnetic",{strength:e,respectReducedMotion:t,...l},o);return X.default.createElement(r,{ref:u,style:{display:"inline-block",...i},...a},s)}function ti({as:r="section",speed:e=1,quality:t="medium",colors:o=["#1e1b4b","#0284c7","#e11d48"],bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,dissipation:h=.982,radius:v=.004,curl:g=1.75,interactive:x=!0,respectReducedMotion:y=!0,disabled:M=!1,children:S,...k}){let{deviceOpts:B,domRest:D}=me(k),F=ce("ink",{speed:e,quality:t,colors:o,bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,dissipation:h,radius:v,curl:g,interactive:x,respectReducedMotion:y,...B},M);return X.default.createElement(r,{ref:F,...D},S)}function ri({as:r="section",speed:e=1,quality:t="medium",colors:o=["#1e3a5f","#2d3748","#0284c7"],bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,lightMode:h,absorptionGain:v=1.45,dissipation:g=.978,radius:x=.0032,curl:y=1.85,interactive:M=!0,respectReducedMotion:S=!0,disabled:k=!1,children:B,...D}){let{deviceOpts:F,domRest:C}=me(D),U=ce("aetheria",{speed:e,quality:t,colors:o,bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,lightMode:h,absorptionGain:v,dissipation:g,radius:x,curl:y,interactive:M,respectReducedMotion:S,...F},k);return X.default.createElement(r,{ref:U,...C},B)}function ii({as:r="section",speed:e=1,quality:t="medium",colors:o=["#6366f1","#06b6d4","#f472b6"],bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,shape:h="prism",depth:v=1,gloss:g=1,distortion:x=.35,interactive:y=!0,respectReducedMotion:M=!0,disabled:S=!1,children:k,...B}){let{deviceOpts:D,domRest:F}=me(B),C=ce("prism-3d",{speed:e,quality:t,colors:o,bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,shape:h,depth:v,gloss:g,distortion:x,interactive:y,respectReducedMotion:M,...D},S);return X.default.createElement(r,{ref:C,...F},k)}function oi({as:r="section",baseImage:e,revealImage:t,speed:o=1,quality:i="medium",colors:s=["#ff6b2b","#ffd166","#ffffff"],bgColor:n="transparent",theme:l,lightColors:a,darkColors:u,scrollColors:c,trackScroll:f,layer:m,preserveBg:p,adaptToSurface:h,overlayOpacity:v,radius:g=.13,softness:x=.22,edgeNoise:y=.38,edgeGlow:M=.24,dissipation:S=.985,fit:k="cover",position:B="center",ambient:D=!1,clickReveal:F=!0,interactive:C=!0,respectReducedMotion:U=!0,disabled:O=!1,children:G,...V}){let{deviceOpts:Q,domRest:Y}=me(V),E=ce("brush-reveal",{baseImage:e,revealImage:t,speed:o,quality:i,colors:s,bgColor:n,theme:l,lightColors:a,darkColors:u,scrollColors:c,trackScroll:f,layer:m,preserveBg:p,adaptToSurface:h,overlayOpacity:v,radius:g,softness:x,edgeNoise:y,edgeGlow:M,dissipation:S,fit:k,position:B,ambient:D,clickReveal:F,interactive:C,respectReducedMotion:U,...Q},O);return X.default.createElement(r,{ref:E,...Y},G)}function si({as:r="section",speed:e=1,quality:t="medium",colors:o=["#14161a","#4b5563","#f8fafc"],bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,spotRadius:h=.62,spotIntensity:v=1,spotPosition:g="center",interactive:x=!0,respectReducedMotion:y=!0,disabled:M=!1,children:S,...k}){let{deviceOpts:B,domRest:D}=me(k),F=ce("spotlight",{speed:e,quality:t,colors:o,bgColor:i,theme:s,lightColors:n,darkColors:l,scrollColors:a,trackScroll:u,layer:c,preserveBg:f,adaptToSurface:m,overlayOpacity:p,spotRadius:h,spotIntensity:v,spotPosition:g,interactive:x,respectReducedMotion:y,...B},M);return X.default.createElement(r,{ref:F,...D},S)}function ni({as:r="div",activeIndex:e=0,focused:t=!1,wrap:o=!0,clickToFocus:i=!0,spread:s=25,depthScale:n=.22,curve:l=10,parallax:a=18,focusOffsetX:u=-15,focusScale:c=1.07,perspective:f=1100,respectReducedMotion:m=!0,disabled:p=!1,onSlideChange:h,children:v,...g}){let{deviceOpts:x,domRest:y}=me(g),M=(0,X.useRef)(h);M.current=h;let S=ce("depth-carousel",{activeIndex:e,focused:t,wrap:o,clickToFocus:i,spread:s,depthScale:n,curve:l,parallax:a,focusOffsetX:u,focusScale:c,perspective:f,respectReducedMotion:m,...x},p);return(0,X.useEffect)(()=>{let k=S.current;if(!k)return;let B=D=>{let F=D;M.current?.(F.detail)};return k.addEventListener("fluxfx:change",B),()=>k.removeEventListener("fluxfx:change",B)},[S]),X.default.createElement(r,{ref:S,...y},v)}function ai({as:r="div",videoSrc:e,src:t,spriteSrc:o,frames:i,poster:s,cols:n=4,rows:l=4,frameCount:a,mode:u="auto",trigger:c="scroll",axis:f="y",trackTarget:m="window",sensitivity:p=1,damping:h=10,idlePosition:v=.5,idleTimeout:g=0,returnToIdle:x=!0,invert:y=!1,clamp:M=!0,fit:S="contain",position:k="center",startOffset:B=0,endOffset:D=1,chromaKey:F,chromaTolerance:C=.34,chromaSoftness:U=.14,crossfade:O=!0,targetFps:G=24,tileInset:V=0,maxCacheWidth:Q=540,blendMode:Y="normal",respectReducedMotion:E=!0,disabled:P=!1,onProgress:d,children:b,...T}){let{deviceOpts:R,domRest:A}=me(T),_=(0,X.useRef)(d);_.current=d;let K=ce("motion-scrub",{videoSrc:e,src:t,spriteSrc:o,frames:i,poster:s,cols:n,rows:l,frameCount:a,mode:u,trigger:c,axis:f,trackTarget:m,sensitivity:p,damping:h,idlePosition:v,idleTimeout:g,returnToIdle:x,invert:y,clamp:M,fit:S,position:k,startOffset:B,endOffset:D,chromaKey:F,chromaTolerance:C,chromaSoftness:U,crossfade:O,targetFps:G,tileInset:V,maxCacheWidth:Q,blendMode:Y,respectReducedMotion:E,...R},P);return(0,X.useEffect)(()=>{let oe=K.current;if(!oe)return;let he=Le=>{let we=Le;_.current?.(we.detail)};return oe.addEventListener("fluxfx:scrub",he),()=>oe.removeEventListener("fluxfx:scrub",he)},[K]),X.default.createElement(r,{ref:K,...A},b)}function li({as:r="section",pathSelector:e="[data-fx-path], path",damping:t=10,offsetTop:o=.72,offsetBottom:i=.35,once:s=!1,respectReducedMotion:n=!0,disabled:l=!1,onWaypoint:a,children:u,...c}){let{deviceOpts:f,domRest:m}=me(c),p=(0,X.useRef)(a);p.current=a;let h=ce("scroll-path",{pathSelector:e,damping:t,offsetTop:o,offsetBottom:i,once:s,respectReducedMotion:n,...f},l);return(0,X.useEffect)(()=>{let v=h.current;if(!v)return;let g=x=>{let y=x;p.current?.(y.detail)};return v.addEventListener("fluxfx:waypoint",g),()=>v.removeEventListener("fluxfx:waypoint",g)},[h]),X.default.createElement(r,{ref:h,...m},u)}function ci({as:r="section",cardSelector:e="[data-fx-stack-card]",tabSelector:t="[data-fx-stack-tab]",stickyTop:o,offsetStep:i=16,scaleStep:s=.045,opacityStep:n=.08,damping:l=14,respectReducedMotion:a=!0,disabled:u=!1,onChange:c,children:f,...m}){let{deviceOpts:p,domRest:h}=me(m),v=(0,X.useRef)(c);v.current=c;let g=ce("card-stack",{cardSelector:e,tabSelector:t,stickyTop:o,offsetStep:i,scaleStep:s,opacityStep:n,damping:l,respectReducedMotion:a,...p},u);return(0,X.useEffect)(()=>{let x=g.current;if(!x)return;let y=M=>{let S=M;v.current?.(S.detail)};return x.addEventListener("fluxfx:stackchange",y),()=>x.removeEventListener("fluxfx:stackchange",y)},[g]),X.default.createElement(r,{ref:g,...h},f)}0&&(module.exports={Aetheria,Aurora,BrushReveal,CardStack,DepthCarousel,Fluid,Ink,LiquidMetal,Magnetic,MotionScrub,Prism3D,ScrollPath,Spotlight,TiltCard,useFX});