@aberhamm/liquid-glass-react 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1,87 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),l=require("react/jsx-runtime"),sn={supportsBackdropFilter:!1,isChromium:!1,supportsSvgBackdropDisplacement:!1,isFirefox:!1,prefersReducedMotion:!1,prefersReducedTransparency:!1,prefersContrastMore:!1,canRefract:!1};function De(){return{...sn}}function rn(){return typeof window<"u"&&typeof document<"u"&&typeof navigator<"u"}function on(){return typeof CSS>"u"||typeof CSS.supports!="function"?!1:CSS.supports("backdrop-filter","blur(1px)")||CSS.supports("-webkit-backdrop-filter","blur(1px)")}function an(n){return/Firefox/i.test(n)}function cn(n,t){return t?!1:/Chrome|Chromium|Edg|OPR/i.test(n)}function ln(){return typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function un(){return typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-transparency: reduce)").matches}function dn(){return typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-contrast: more)").matches}function xt(){if(!rn())return De();const n=navigator.userAgent??"",t=on(),e=an(n),s=cn(n,e),r=s,o=ln(),a=un(),c=dn();return{supportsBackdropFilter:t,isChromium:s,supportsSvgBackdropDisplacement:r,isFirefox:e,prefersReducedMotion:o,prefersReducedTransparency:a,prefersContrastMore:c,canRefract:t&&r}}function yt(){const[n,t]=f.useState(De);return f.useEffect(()=>{t(xt())},[]),n}function J(n,t,e,s,r){const o=e/2,a=s/2,c=Math.max(0,Math.min(r,Math.min(o,a))),i=Math.abs(n)-(o-c),d=Math.abs(t)-(a-c),h=Math.max(i,0),x=Math.max(d,0),b=Math.sqrt(h*h+x*x),m=Math.min(Math.max(i,d),0);return b+m-c}function ee(n,t,e){if(n===t)return e<n?0:1;const s=Math.max(0,Math.min(1,(e-n)/(t-n)));return s*s*(3-2*s)}function et(n){const t=Math.round(128+n*127);return t<0?0:t>255?255:t}function fn(n,t,e){const s=new Uint8ClampedArray(t*e*4),r=t/2,o=e/2,a=Math.min(t,e)*.35;for(let c=0;c<e;c++)for(let i=0;i<t;i++){const d=i+.5-r,h=c+.5-o;let x=0,b=0;if(n==="polar"){const u=Math.sqrt(d*d+h*h),p=J(d,h,t,e,a),g=ee(-Math.min(t,e)*.5,0,p),S=u===0?0:d/u,R=u===0?0:h/u;x=S*g*.9,b=R*g*.9}else{let u,p,g;n==="standard"?(u=-Math.min(t,e)*.18,p=0,g=.7):n==="prominent"?(u=-Math.min(t,e)*.4,p=0,g=1):(u=-Math.min(t,e)*.1,p=Math.min(t,e)*.04,g=.85);const S=J(d-1,h,t,e,a),R=J(d+1,h,t,e,a),T=J(d,h-1,t,e,a),v=J(d,h+1,t,e,a),E=ee(u,p,S),te=ee(u,p,R),ne=ee(u,p,T),G=ee(u,p,v);x=(te-E)*.5*g,b=(G-ne)*.5*g}const m=(c*t+i)*4;s[m]=et(x),s[m+1]=0,s[m+2]=et(b),s[m+3]=255}return s}const mn=(()=>{const n=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let s=0;s<8;s++)e=e&1?3988292384^e>>>1:e>>>1;n[t]=e>>>0}return n})();function pn(n){let t=4294967295;for(let e=0;e<n.length;e++)t=mn[(t^n[e])&255]^t>>>8;return(t^4294967295)>>>0}function gn(n){let t=1,e=0;const s=65521;for(let r=0;r<n.length;r++)t=(t+n[r])%s,e=(e+t)%s;return(e<<16|t)>>>0}function hn(n){const e=Math.max(1,Math.ceil(n.length/65535)),s=new Uint8Array(2+e*5+n.length+4);let r=0;s[r++]=120,s[r++]=1;let o=0;do{const c=Math.min(n.length-o,65535),i=o+c>=n.length;s[r++]=i?1:0,s[r++]=c&255,s[r++]=c>>>8&255;const d=~c&65535;s[r++]=d&255,s[r++]=d>>>8&255,s.set(n.subarray(o,o+c),r),r+=c,o+=c}while(o<n.length);const a=gn(n);return s[r++]=a>>>24&255,s[r++]=a>>>16&255,s[r++]=a>>>8&255,s[r++]=a&255,s}function Te(n,t){const e=t.length,s=new Uint8Array(12+e);s[0]=e>>>24&255,s[1]=e>>>16&255,s[2]=e>>>8&255,s[3]=e&255,s[4]=n.charCodeAt(0),s[5]=n.charCodeAt(1),s[6]=n.charCodeAt(2),s[7]=n.charCodeAt(3),s.set(t,8);const r=pn(s.subarray(4,8+e));return s[8+e]=r>>>24&255,s[9+e]=r>>>16&255,s[10+e]=r>>>8&255,s[11+e]=r&255,s}function St(n,t,e){const s=t*4,r=new Uint8Array(e*(s+1));for(let u=0;u<e;u++){const p=u*(s+1);r[p]=0,r.set(n.subarray(u*s,u*s+s),p+1)}const o=hn(r),a=new Uint8Array(13);a[0]=t>>>24&255,a[1]=t>>>16&255,a[2]=t>>>8&255,a[3]=t&255,a[4]=e>>>24&255,a[5]=e>>>16&255,a[6]=e>>>8&255,a[7]=e&255,a[8]=8,a[9]=6,a[10]=0,a[11]=0,a[12]=0;const c=Uint8Array.from([137,80,78,71,13,10,26,10]),i=Te("IHDR",a),d=Te("IDAT",o),h=Te("IEND",new Uint8Array(0)),x=c.length+i.length+d.length+h.length,b=new Uint8Array(x);let m=0;for(const u of[c,i,d,h])b.set(u,m),m+=u.length;return b}const k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Rt(n){let t="",e=0;for(;e+2<n.length;e+=3){const r=n[e]<<16|n[e+1]<<8|n[e+2];t+=k.charAt(r>>>18&63)+k.charAt(r>>>12&63)+k.charAt(r>>>6&63)+k.charAt(r&63)}const s=n.length-e;if(s===1){const r=n[e]<<16;t+=`${k.charAt(r>>>18&63)}${k.charAt(r>>>12&63)}==`}else if(s===2){const r=n[e]<<16|n[e+1]<<8;t+=`${k.charAt(r>>>18&63)}${k.charAt(r>>>12&63)}${k.charAt(r>>>6&63)}=`}return t}function bn(){const n=new Uint8ClampedArray([0,0,0,0]);return`data:image/png;base64,${Rt(St(n,1,1))}`}const xn=32,Ne=16,Y=new Map;function tt(n){return Math.max(Ne,Math.round(n/Ne)*Ne)}function vt(n,t,e){if(!Number.isFinite(t)||!Number.isFinite(e)||t<=0||e<=0)return bn();const s=tt(t),r=tt(e),o=`${n}:${s}x${r}`,a=Y.get(o);if(a!==void 0)return Y.delete(o),Y.set(o,a),a;const c=fn(n,s,r),i=`data:image/png;base64,${Rt(St(c,s,r))}`;if(Y.set(o,i),Y.size>xn){const d=Y.keys().next().value;d!==void 0&&Y.delete(d)}return i}const At=["inset 0 1px 1px 0 rgba(255, 255, 255, 0.75)","inset 1px 0 1px 0 rgba(255, 255, 255, 0.4)","inset 0 -1px 2px 0 rgba(0, 0, 0, 0.18)","inset -1px 0 2px 0 rgba(0, 0, 0, 0.12)","inset 0 0 0 1px rgba(255, 255, 255, 0.22)"].join(", "),Ct=["inset 0 1px 1px 0 rgba(255, 255, 255, 0.35)","inset 1px 0 1px 0 rgba(255, 255, 255, 0.18)","inset 0 -1px 2px 0 rgba(0, 0, 0, 0.55)","inset -1px 0 2px 0 rgba(0, 0, 0, 0.45)","inset 0 0 0 1px rgba(255, 255, 255, 0.1)"].join(", ");function ie(n){return n==="dark"?Ct:At}const yn=200,Sn=300,nt=.3,st=.15,rt=.8,ot=.1;function Fe(n,t,e){return Math.min(e,Math.max(t,n))}function Et(n){return Number.isFinite(n)?Fe(1-n/yn,0,1):0}function wt(n,t,e,s,r){if(!(r>0))return{scaleX:1,scaleY:1};const o=n-e,a=t-s,c=Math.hypot(o,a);if(c===0||!Number.isFinite(c))return{scaleX:1,scaleY:1};const i=Et(c);if(i===0)return{scaleX:1,scaleY:1};const d=o/c,h=a/c,x=Math.abs(d),b=Math.abs(h),m=Math.min(c/Sn,1)*r*i,u=Fe(1+x*m*nt-b*m*st,rt,Number.POSITIVE_INFINITY),p=Fe(1+b*m*nt-x*m*st,rt,Number.POSITIVE_INFINITY);return{scaleX:u,scaleY:p}}function Mt(n,t,e,s,r){if(!(r>0))return{x:0,y:0};const o=n-e,a=t-s,c=Math.hypot(o,a);if(c===0||!Number.isFinite(c))return{x:0,y:0};const i=Et(c);return i===0?{x:0,y:0}:{x:o*r*ot*i,y:a*r*ot*i}}const j={displacementScale:70,blurAmount:.0625,saturation:140,aberrationIntensity:2,cornerRadius:999,mode:"standard",padding:"24px 32px",elasticity:.15},Rn=16,vn={light:"rgba(255, 255, 255, 0.75)",dark:"rgba(30, 30, 35, 0.75)"},An={light:"rgba(255, 255, 255, 0.92)",dark:"rgba(30, 30, 35, 0.92)"},Cn={light:"rgba(0, 0, 0, 0.92)",dark:"rgba(255, 255, 255, 0.92)"},En=2,wn={light:"rgba(255, 255, 255, 0.92)",dark:"rgba(22, 22, 26, 0.92)"},Mn=100,pe={light:"rgba(255, 255, 255, 0.96)",dark:"rgba(17, 17, 20, 0.96)"},at="50%",ct="0%",it={rest:.55,hover:.85},Tn="70%",lt=.5,Nn="60%",ut={static:1,dark:1.35,light:.7},dt={rest:[{y:8,blur:24,alpha:.22},{y:1,blur:4,alpha:.14}],hover:[{y:12,blur:32,alpha:.28},{y:2,blur:8,alpha:.18}]},Ln={regular:{saturationFactor:1,forceNonAdaptive:!1,scrim:null},clear:{saturationFactor:.7,forceNonAdaptive:!0,scrim:{light:"rgba(0, 0, 0, 0.18)",dark:"rgba(0, 0, 0, 0.28)"}}},In="rgba(255, 255, 255, 0.1)",ft={color:"rgba(255, 255, 255, 0.5)",width:1},F={luminance:null,scheme:null,sampled:!1},Tt=.5;function Le(n){const t=n/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Nt(n,t,e){const s=Le(n),r=Le(t),o=Le(e);return .2126*s+.7152*r+.0722*o}function Lt(n){return n>=Tt?"light":"dark"}function je(n){const t=Nt(n.r,n.g,n.b);return{luminance:t,scheme:Lt(t),sampled:!0}}function It(n){if(!n)return{r:0,g:0,b:0,a:0};const t=n.trim().toLowerCase();if(t==="transparent"||t==="none")return{r:0,g:0,b:0,a:0};const e=t.match(/rgba?\(([^)]+)\)/);if(!(e!=null&&e[1]))return{r:0,g:0,b:0,a:0};const s=e[1].split(/[\s,/]+/).filter(Boolean);if(s.length<3)return{r:0,g:0,b:0,a:0};const r=Ie(Number.parseFloat(s[0])),o=Ie(Number.parseFloat(s[1])),a=Ie(Number.parseFloat(s[2]));let c=1;const i=s[3];return i!==void 0&&(c=i.endsWith("%")?Number.parseFloat(i)/100:Number.parseFloat(i),Number.isFinite(c)||(c=1)),{r,g:o,b:a,a:kn(c)}}function Ie(n){return Number.isFinite(n)?Math.max(0,Math.min(255,Math.round(n))):0}function kn(n){return Math.max(0,Math.min(1,n))}function Fn(n,t){const e=n.a;return{r:n.r*e+t.r*(1-e),g:n.g*e+t.g*(1-e),b:n.b*e+t.b*(1-e)}}function kt(n,t){try{return n(t)}catch{return F}}function Ft(n,t){if(typeof document>"u"||typeof document.elementsFromPoint!="function"||typeof getComputedStyle!="function")return F;const e=document.elementsFromPoint(n.x,n.y);if(!e||e.length===0)return F;let s={r:255,g:255,b:255};const r=[];for(const o of e){if(t&&(o===t||t.contains(o)))continue;const a=getComputedStyle(o),c=a.backgroundImage&&a.backgroundImage!=="none",i=It(a.backgroundColor);if(c){r.push({r:128,g:128,b:128,a:1});break}if(i.a>0&&(r.push(i),i.a>=1))break}for(let o=r.length-1;o>=0;o--){const a=r[o];a&&(s=Fn(a,s))}return je(s)}function _t(n,t={}){const{strategy:e,ignore:s}=t;return kt(e??(o=>Ft(o,s)),n)}function _n(n,t=8){return()=>{if(typeof document>"u"||typeof document.createElement!="function")return F;const e=document.createElement("canvas");e.width=t,e.height=t;const s=e.getContext("2d");if(!s)return F;n(s,t,t);const{data:r}=s.getImageData(0,0,t,t);let o=0,a=0,c=0,i=0;for(let d=0;d<r.length;d+=4)o+=r[d]??0,a+=r[d+1]??0,c+=r[d+2]??0,i++;return i===0?F:je({r:o/i,g:a/i,b:c/i})}}function Ge(n,t={}){const{strategy:e,resampleOnScroll:s=!0,resampleOnResize:r=!0,disabled:o=!1}=t,[a,c]=f.useState(F),i=f.useRef(e);return i.current=e,f.useEffect(()=>{if(o){c(m=>m.sampled?F:m);return}if(typeof window>"u"||typeof document>"u")return;let d=0,h=!1;const x=()=>{const m=n.current;if(!m)return;const u=m.getBoundingClientRect(),p={x:u.left+u.width/2,y:u.top+u.height/2},g=_t(p,{strategy:i.current,ignore:m});h||c(S=>S.sampled===g.sampled&&S.luminance===g.luminance&&S.scheme===g.scheme?S:g)},b=()=>{d||(d=requestAnimationFrame(()=>{d=0,x()}))};return b(),s&&window.addEventListener("scroll",b,{passive:!0,capture:!0}),r&&window.addEventListener("resize",b,{passive:!0}),()=>{h=!0,d&&cancelAnimationFrame(d),s&&window.removeEventListener("scroll",b,{capture:!0}),r&&window.removeEventListener("resize",b)}},[n,o,s,r]),a}function Oe(n){const[t,e]=f.useState(!1);return f.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const s=window.matchMedia(n);e(s.matches);const r=o=>{e(o.matches)};return typeof s.addEventListener=="function"?(s.addEventListener("change",r),()=>s.removeEventListener("change",r)):(s.addListener(r),()=>s.removeListener(r))},[n]),t}const Dn="(prefers-reduced-motion: reduce)";function ge(){return Oe(Dn)}const _e={x:0,y:0},mt={mousePos:_e,offset:_e,isActive:!1};function pt(n){return n?n instanceof HTMLElement?n:n.current??null:null}function jn(){return typeof window>"u"?!1:"ontouchstart"in window||((navigator==null?void 0:navigator.maxTouchPoints)??0)>0}function Dt(n={}){const{container:t,globalMousePos:e,mouseOffset:s,elementRef:r}=n,o=ge(),[a,c]=f.useState(!1),[i,d]=f.useState(mt),h=f.useRef({container:t,elementRef:r});h.current={container:t,elementRef:r},f.useEffect(()=>{c(jn())},[]);const x=o||a,b=e!==void 0;if(f.useEffect(()=>{if(b||x||typeof window>"u"||typeof document>"u")return;const m=u=>{const{container:p,elementRef:g}=h.current,S=pt(p)??(g==null?void 0:g.current)??null;if(!S)return;const R=S.getBoundingClientRect(),T=R.left+R.width/2,v=R.top+R.height/2;d({mousePos:{x:u.clientX,y:u.clientY},offset:{x:u.clientX-T,y:u.clientY-v},isActive:!0})};return document.addEventListener("mousemove",m),()=>document.removeEventListener("mousemove",m)},[b,x]),x)return mt;if(b){const m=e;let u=s;if(u===void 0){const p=pt(t)??(r==null?void 0:r.current)??null;if(p){const g=p.getBoundingClientRect();u={x:m.x-(g.left+g.width/2),y:m.y-(g.top+g.height/2)}}else u=_e}return{mousePos:m,offset:u,isActive:!0}}return i}const Gn="(prefers-contrast: more)";function jt(){return Oe(Gn)}const On="(prefers-reduced-transparency: reduce)";function Gt(){return Oe(On)}const ke=16,$n=.015;function Bn(n,t){return(n?dt.hover:dt.rest).map(s=>{const r=Math.round(s.y*t*100)/100,o=Math.round(s.blur*t*100)/100,a=Math.round(Math.min(s.alpha*t,.6)*1e3)/1e3;return`0 ${r}px ${o}px rgba(0, 0, 0, ${a})`}).join(", ")}function gt(n){return Math.max(ke,Math.round(n/ke)*ke)}function Pn(){const[n,t]=f.useState(!1);return f.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const e=window.matchMedia("(prefers-color-scheme: dark)");t(e.matches);const s=r=>t(r.matches);return typeof e.addEventListener=="function"?(e.addEventListener("change",s),()=>e.removeEventListener("change",s)):(e.addListener(s),()=>e.removeListener(s))},[]),n}function ht(n){return typeof n=="number"?`${n}px`:n}function Un(n,t,e){return e||`blur(${n}px) saturate(${t}%)`}function bt({filterId:n,mode:t,width:e,height:s,effectiveScale:r,aberrationIntensity:o,blurStdDeviation:a,saturation:c}){const i=t==="turbulence",d=r+o,h=r,x=r-o,b=i?l.jsxs(l.Fragment,{children:[l.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:$n,numOctaves:2,seed:1,result:"noise"}),l.jsx("feGaussianBlur",{in:"noise",stdDeviation:1.5,result:"dispSource"})]}):l.jsx("feImage",{href:vt(t,e,s),x:"0",y:"0",width:e,height:s,preserveAspectRatio:"none",result:"dispSource"}),m=(R,T,v)=>{const E=T==="R"?"1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0":T==="G"?"0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0":"0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0";return l.jsxs(l.Fragment,{children:[l.jsx("feDisplacementMap",{in:"SourceGraphic",in2:"dispSource",scale:R,xChannelSelector:"R",yChannelSelector:"B",result:`${v}_disp`}),l.jsx("feColorMatrix",{in:`${v}_disp`,type:"matrix",values:E,result:v})]})},u=Math.min(e,s)*.5,p=Math.min(Math.max(a,0),u),g=e*.5+p*3,S=s*.5+p*3;return l.jsx("svg",{"aria-hidden":"true",width:"0",height:"0",style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:l.jsx("defs",{children:l.jsxs("filter",{id:n,primitiveUnits:"userSpaceOnUse",x:-g,y:-S,width:e+g*2,height:s+S*2,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[b,m(d,"R","chanR"),m(h,"G","chanG"),m(x,"B","chanB"),l.jsx("feComposite",{in:"chanR",in2:"chanG",operator:"arithmetic",k1:"0",k2:"1",k3:"1",k4:"0",result:"chanRG"}),l.jsx("feComposite",{in:"chanRG",in2:"chanB",operator:"arithmetic",k1:"0",k2:"1",k3:"1",k4:"0",result:"aberrated"}),l.jsx("feGaussianBlur",{in:"aberrated",stdDeviation:.5,result:"softened"}),l.jsxs("radialGradient",{id:`${n}-edge`,cx:"50%",cy:"50%",r:"50%",children:[l.jsx("stop",{offset:"0%",stopColor:"#000000",stopOpacity:"0"}),l.jsx("stop",{offset:"70%",stopColor:"#000000",stopOpacity:"0"}),l.jsx("stop",{offset:"100%",stopColor:"#ffffff",stopOpacity:"1"})]}),l.jsx("feImage",{href:`#${n}-edge`,x:"0",y:"0",width:e,height:s,preserveAspectRatio:"none",result:"edgeMask"}),l.jsx("feComposite",{in:"softened",in2:"edgeMask",operator:"in",result:"edgeOnly"}),l.jsx("feComposite",{in:"edgeOnly",in2:"SourceGraphic",operator:"over",result:"refracted"}),l.jsx("feGaussianBlur",{in:"refracted",stdDeviation:p,result:"blurred"}),l.jsx("feColorMatrix",{in:"blurred",type:"saturate",values:`${c/100}`})]})})})}function Yn({targetRef:n,onScheme:t}){const{sampled:e,scheme:s}=Ge(n);return f.useEffect(()=>{t(e?s:null)},[e,s,t]),null}function Hn({targetRef:n,onScheme:t}){const{sampled:e,scheme:s}=Ge(n);return f.useEffect(()=>{t(e?s:null)},[e,s,t]),null}function he({children:n,displacement:t=!1,displacementScale:e=j.displacementScale,blurAmount:s=j.blurAmount,saturation:r=j.saturation,aberrationIntensity:o=j.aberrationIntensity,elasticity:a=j.elasticity,cornerRadius:c=j.cornerRadius,padding:i=j.padding,overLight:d,adaptiveTint:h=!1,scrollAwareShadow:x=!1,variant:b="regular",mode:m=j.mode,refract:u,size:p,center:g,behind:S,className:R,style:T,onClick:v,globalMousePos:E,mouseOffset:te,mouseContainer:ne}){const{canRefract:G,supportsBackdropFilter:O}=yt(),L=f.useRef(null),[w,H]=f.useState(null),$=ge(),X=Gt(),N=jt(),se=Pn(),[q,re]=f.useState(!1),[le,oe]=f.useState(!1),[V,y]=f.useState(null),[A,M]=f.useState(null),{offset:C,isActive:B}=Dt({container:ne,globalMousePos:E,mouseOffset:te,elementRef:L}),_=`lg-${f.useId().replace(/:/g,"")}`;f.useEffect(()=>{const ae=L.current;if(!ae)return;let U=0;const ce=()=>{const Z=ae.getBoundingClientRect();if(!Number.isFinite(Z.width)||!Number.isFinite(Z.height)||Z.width<=0||Z.height<=0)return;const Ze=gt(Z.width),Je=gt(Z.height);H(me=>me&&me.width===Ze&&me.height===Je?me:{width:Ze,height:Je})};if(ce(),typeof ResizeObserver>"u")return;const fe=new ResizeObserver(()=>{U||(U=requestAnimationFrame(()=>{U=0,ce()}))});return fe.observe(ae),()=>{U&&cancelAnimationFrame(U),fe.disconnect()}},[]);const I=Ln[b],ue=h&&!I.forceNonAdaptive,be=d??(ue&&V?V==="light":!1),Be=be?e/2:e,xe=N?Mn:r*I.saturationFactor,Pe=N?0:o,W=w!==null&&w.width>0&&w.height>0,ye=t&&G&&W&&!X,$t=ye?`url(#${_})`:null,Bt=u!==void 0||p!==void 0||g!==void 0,Se=(p==null?void 0:p.width)??(W?w.width:0),Re=(p==null?void 0:p.height)??(W?w.height:0),Ue=Bt&&!X&&Number.isFinite(Se)&&Number.isFinite(Re)&&Se>0&&Re>0,Ye=`${_}-copy`,Pt=u!==void 0?u:n,Ut=`${(((g==null?void 0:g.x)??.5)*100).toFixed(2)}% ${(((g==null?void 0:g.y)??.5)*100).toFixed(2)}%`,He=O&&!ye&&!X&&!N,ve=s*Rn*(be?1.5:1),Ae=O?Un(ve,xe,$t):void 0,D=ht(c),z=B&&!$,Xe=z?wt(C.x,C.y,0,0,a):{scaleX:1,scaleY:1},qe=z?Mt(C.x,C.y,0,0,a):{x:0,y:0},Ve=typeof v=="function"&&le?.96:1,P=`translate(${qe.x.toFixed(2)}px, ${qe.y.toFixed(2)}px) scale(${(Xe.scaleX*Ve).toFixed(4)}, ${(Xe.scaleY*Ve).toFixed(4)})`,Yt=135+(z?C.x*.15:0);let Ce=at,Ee=ct;if(z&&W){const ae=50+C.x/(w.width/2)*50,U=50+C.y/(w.height/2)*50,ce=fe=>Math.max(-20,Math.min(120,fe));Ce=`${ce(ae).toFixed(2)}%`,Ee=`${ce(U).toFixed(2)}%`}const Ht=le,Xt=z&&W?Ce:"50%",qt=z&&W?Ee:"50%",we=ie(se?"dark":"light");let Me=we;N?Me=`inset 0 0 0 ${En}px ${Cn[se?"dark":"light"]}, ${we}`:He&&(Me=`inset 0 0 0 ${ft.width}px ${ft.color}, ${we}`);const We=q?it.hover:it.rest,ze=q?.55:.35,Vt={position:"relative",display:"inline-block",padding:ht(i),borderRadius:D,...T},Wt=x?ut[A??"static"]:ut.static,zt={position:"absolute",inset:0,borderRadius:D,transform:P,transition:x&&$?"transform 120ms ease-out":"box-shadow 200ms ease, transform 120ms ease-out",boxShadow:Bn(q,Wt),zIndex:-1,pointerEvents:"none"},Q=se?"dark":"light";let K;N?K=wn[Q]:X?K=O?vn[Q]:An[Q]:O?He&&(K=In):K=Q==="dark"?"rgba(30, 30, 35, 0.55)":"rgba(255, 255, 255, 0.55)";const Qt={position:"absolute",inset:0,borderRadius:D,overflow:"hidden",...Ae?{backdropFilter:Ae,WebkitBackdropFilter:Ae}:{},...K?{background:K}:{},boxShadow:Me,transform:P,transition:"transform 120ms ease-out",zIndex:0,pointerEvents:"none"},Kt={position:"absolute",inset:0,borderRadius:D,transform:P,transition:$?"transform 120ms ease-out":"transform 120ms ease-out, background-position 120ms ease-out",mixBlendMode:"screen","--lg-spec-x":Ce,"--lg-spec-y":Ee,background:`radial-gradient(circle ${Tn} at var(--lg-spec-x, ${at}) var(--lg-spec-y, ${ct}), rgba(255,255,255,${We}) 0%, rgba(255,255,255,${(We*.4).toFixed(3)}) 30%, rgba(255,255,255,0) 65%)`,zIndex:0,pointerEvents:"none"},Zt={position:"absolute",inset:0,borderRadius:D,transform:P,mixBlendMode:"screen","--lg-spec-x":Xt,"--lg-spec-y":qt,background:`radial-gradient(circle ${Nn} at var(--lg-spec-x, 50%) var(--lg-spec-y, 50%), rgba(255,255,255,${lt}) 0%, rgba(255,255,255,${(lt*.5).toFixed(3)}) 25%, rgba(255,255,255,0) 55%)`,opacity:Ht?1:0,transition:$?"transform 120ms ease-out":"transform 120ms ease-out, opacity 360ms ease-out",zIndex:0,pointerEvents:"none"},Jt={position:"absolute",inset:0,borderRadius:D,transform:P,transition:"transform 120ms ease-out",mixBlendMode:"overlay",padding:"1px",background:`linear-gradient(${Yt}deg, rgba(255,255,255,${ze}) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,${ze*.6}) 100%)`,zIndex:0,pointerEvents:"none"};let de;ue&&N?de=Q==="light"?pe.dark:pe.light:ue&&V&&(de=be?pe.dark:pe.light);const en={position:"relative",zIndex:1,...de?{color:de}:{}},tn={position:"absolute",inset:0,borderRadius:D,overflow:"hidden",transform:P,transition:"transform 120ms ease-out",zIndex:0,pointerEvents:"none"},nn={position:"absolute",inset:0,filter:Ue?`url(#${Ye})`:void 0,transformOrigin:Ut,...S?{background:S}:{}},Qe=I.scrim?I.scrim[Q]:null,Ke=Qe?{position:"absolute",inset:0,borderRadius:D,transform:P,transition:"transform 120ms ease-out",background:Qe,zIndex:0,pointerEvents:"none"}:null;return l.jsxs("div",{ref:L,className:R,style:Vt,onClick:v,onMouseEnter:()=>re(!0),onMouseLeave:()=>{re(!1),oe(!1)},onMouseDown:()=>oe(!0),onMouseUp:()=>oe(!1),children:[l.jsx("div",{"data-lg-shadow":"",style:zt,"aria-hidden":"true"}),l.jsx("div",{"data-lg-surface":"",style:Qt,children:ye?l.jsx(bt,{filterId:_,mode:m,width:w.width,height:w.height,effectiveScale:Be,aberrationIntensity:Pe,blurStdDeviation:ve,saturation:xe}):null}),Ue?l.jsxs("div",{"data-lg-refraction":"",style:tn,"aria-hidden":"true",inert:"true",children:[l.jsx(bt,{filterId:Ye,mode:m,width:Se,height:Re,effectiveScale:Be,aberrationIntensity:Pe,blurStdDeviation:ve,saturation:xe}),l.jsx("div",{"data-lg-refraction-copy":"",style:nn,children:Pt})]}):null,l.jsx("span",{"data-lg-highlight":"",style:Kt,"aria-hidden":"true"}),l.jsx("span",{"data-lg-press-glow":"",style:Zt,"aria-hidden":"true"}),l.jsx("span",{"data-lg-border":"",style:Jt,"aria-hidden":"true"}),Ke?l.jsx("span",{"data-lg-scrim":"",style:Ke,"aria-hidden":"true"}):null,ue?l.jsx(Yn,{targetRef:L,onScheme:y}):null,x?l.jsx(Hn,{targetRef:L,onScheme:M}):null,l.jsx("div",{"data-lg-content":"",style:en,children:n})]})}function Xn(...n){return t=>{for(const e of n)e&&(typeof e=="function"?e(t):e.current=t)}}function qn(n,t){return n?t?(...e)=>{n(...e);const s=e[0];(!s||!s.defaultPrevented)&&t(...e)}:n:t}function Vn(n,t){const e={...t};for(const s in n){const r=n[s],o=t[s];s==="className"?e.className=[o,r].filter(Boolean).join(" "):s==="style"?e.style={...o,...r}:/^on[A-Z]/.test(s)?e[s]=qn(o,r):r!==void 0&&(e[s]=r)}return e}const Ot=f.forwardRef(function(t,e){const{children:s,...r}=t;if(!f.isValidElement(s)||f.Children.count(s)!==1)throw new Error('Slot (asChild) expects exactly one valid React element child. Pass a single element, e.g. <GlassButton asChild><a href="…">Link</a></GlassButton>.');const o=s,a=o.props,c=o.ref??a.ref,i=Vn(r,a);return i.ref=Xn(e,c),f.cloneElement(o,i)});function Wn(...n){return n.filter(Boolean).join(" ")}function $e(n){const{base:t,variants:e,defaultVariants:s}=n;return(r={})=>{var a;const o=[t];for(const c in e){const i=r[c]??(s==null?void 0:s[c]);i!==void 0&&o.push((a=e[c])==null?void 0:a[i])}return o.push(r.className),Wn(...o)}}const zn={primary:{displacementScale:80,blurAmount:.0625,saturation:160},secondary:{displacementScale:60,blurAmount:.0625,saturation:140},subtle:{displacementScale:40,blurAmount:.05,saturation:120}},Qn={sm:{cornerRadius:999,padding:"6px 14px"},md:{cornerRadius:999,padding:"10px 20px"},lg:{cornerRadius:999,padding:"14px 28px"},icon:{cornerRadius:999,padding:"10px"}},Kn=$e({base:"lg-button",variants:{variant:{primary:"lg-button--primary",secondary:"lg-button--secondary",subtle:"lg-button--subtle"},size:{sm:"lg-button--sm",md:"lg-button--md",lg:"lg-button--lg",icon:"lg-button--icon"}},defaultVariants:{variant:"primary",size:"md"}}),Zn=f.forwardRef(function({variant:t="primary",size:e="md",asChild:s=!1,shine:r=!0,contentClassName:o,glassProps:a,className:c,children:i,style:d,type:h,disabled:x,...b},m){const u=Kn({variant:t,size:e,className:c}),p={"--lg-edge-shadow":ie("light"),...d},g=l.jsx("span",{className:["lg-content",o].filter(Boolean).join(" "),children:i}),S=s?l.jsx(Ot,{ref:m,className:u,style:p,"data-shine":r?"true":"false",...b,children:i}):l.jsx("button",{ref:m,type:h??"button",disabled:x,className:u,style:p,"data-shine":r?"true":"false",...b,children:g}),R={...zn[t],...Qn[e]};return l.jsx(he,{...R,...a,children:S})}),Jn=$e({base:"lg-card",variants:{elevation:{flat:"lg-card--flat",raised:"lg-card--raised",floating:"lg-card--floating"}},defaultVariants:{elevation:"raised"}}),es={cornerRadius:28,padding:"24px 28px",displacementScale:50},ts=f.forwardRef(function({elevation:t="raised",asChild:e=!1,contentClassName:s,glassProps:r,className:o,children:a,style:c,...i},d){const h=Jn({elevation:t,className:o}),x={"--lg-edge-shadow":ie("light"),...c},b=l.jsx("div",{className:["lg-content",s].filter(Boolean).join(" "),children:a}),m=e?l.jsx(Ot,{ref:d,className:h,style:x,"data-elevation":t,...i,children:a}):l.jsx("div",{ref:d,className:h,style:x,"data-elevation":t,...i,children:b});return l.jsx(he,{...es,...r,children:m})}),ns=typeof window<"u"?f.useLayoutEffect:f.useEffect,ss={sm:{displacementScale:40,blurAmount:.05,saturation:130},md:{displacementScale:56,blurAmount:.0625,saturation:140},lg:{displacementScale:72,blurAmount:.0625,saturation:150}},rs=$e({base:"lg-segmented",variants:{size:{sm:"lg-segmented--sm",md:"lg-segmented--md",lg:"lg-segmented--lg"}},defaultVariants:{size:"md"}}),os=f.forwardRef(function({options:t,value:e,defaultValue:s,onValueChange:r,size:o="md",label:a,"aria-label":c,showLabel:i=!1,className:d,style:h,name:x,glassProps:b},m){var V;const u=f.useId(),p=x??`lg-seg-${u.replace(/:/g,"")}`,g=(V=t[0])==null?void 0:V.value,S=e!==void 0,[R,T]=f.useState(s??g),v=S?e:R,E=f.useMemo(()=>{const y=t.findIndex(A=>A.value===v);return y<0?0:y},[t,v]),te=t.length||1,ne=ge(),G=f.useRef(null),O=f.useRef([]),[L,w]=f.useState(null),H=f.useCallback(()=>{const y=G.current,A=O.current[E];if(!y||!A)return;const M=y.getBoundingClientRect(),C=A.getBoundingClientRect();if(!Number.isFinite(M.width)||M.width<=0)return;const B=C.left-M.left,_=C.width;!Number.isFinite(B)||!Number.isFinite(_)||_<=0||w(I=>I&&I.left===B&&I.width===_?I:{left:B,width:_})},[E]),$=f.useRef(H);$.current=H,ns(()=>{H()},[H]),f.useEffect(()=>{const y=G.current;if(!y||typeof ResizeObserver>"u")return;let A=0;const M=new ResizeObserver(()=>{A||(A=requestAnimationFrame(()=>{A=0,$.current()}))});return M.observe(y),()=>{A&&cancelAnimationFrame(A),M.disconnect()}},[]);const X=f.useCallback(y=>{S||T(y),r==null||r(y)},[S,r]),N=ss[o],se=ie("light"),q=L!==null,re=q?{width:`${L.width}px`,transform:`translateX(${L.left}px)`}:{width:`${100/te}%`,transform:`translateX(${E*100}%)`};re.transition=ne?"none":"transform 320ms cubic-bezier(0.32, 0.72, 0, 1), width 320ms cubic-bezier(0.32, 0.72, 0, 1)";const le={"--lg-edge-shadow":se,...h},oe=l.jsx("legend",{className:i?"lg-segmented-legend lg-segmented-legend--visible":"lg-segmented-legend",children:a??c??"Options"});return l.jsxs("fieldset",{ref:m,className:rs({size:o,className:d}),style:le,"aria-label":c,"data-selected-index":E,"data-measured":q?"true":"false",children:[oe,l.jsxs("div",{className:"lg-segmented-track",ref:G,children:[l.jsx("div",{className:"lg-segmented-indicator",style:re,"data-selected-index":E,"aria-hidden":"true",children:l.jsx(he,{cornerRadius:"inherit",padding:0,displacementScale:N.displacementScale,blurAmount:N.blurAmount,saturation:N.saturation,...b,className:"lg-segmented-glass",style:{width:"100%",height:"100%",display:"block"},children:l.jsx("span",{"aria-hidden":"true",className:"lg-segmented-glass-fill"})})}),t.map((y,A)=>{const M=y.value===v,C=`${p}-${y.value}`;return l.jsxs("label",{htmlFor:C,className:"lg-segmented-option","data-active":M?"true":"false","data-icon-only":y.icon!=null&&y.label==null?"true":"false",ref:B=>{O.current[A]=B},children:[l.jsx("input",{id:C,className:"lg-segmented-input",type:"radio",name:p,value:y.value,checked:M,disabled:y.disabled,onChange:()=>X(y.value)}),y.icon!=null?l.jsx("span",{className:"lg-segmented-icon","aria-hidden":"true",children:y.icon}):null,y.label!=null?l.jsx("span",{className:"lg-segmented-label",children:y.label}):null]},y.value)})]})]})}),as="0.0.0";exports.GLASS_EDGE_DARK=Ct;exports.GLASS_EDGE_LIGHT=At;exports.GlassButton=Zn;exports.GlassCard=ts;exports.GlassSegmentedControl=os;exports.LIGHT_DARK_THRESHOLD=Tt;exports.LiquidGlass=he;exports.UNSAMPLED=F;exports.VERSION=as;exports.averageColorToSample=je;exports.calculateDirectionalScale=wt;exports.calculateElasticTranslation=Mt;exports.createCanvasSnapshotStrategy=_n;exports.detectGlassCapabilities=xt;exports.domBackgroundStrategy=Ft;exports.getConservativeGlassCapabilities=De;exports.getDisplacementMap=vt;exports.getGlassEdgeShadow=ie;exports.luminanceToScheme=Lt;exports.parseCssColor=It;exports.relativeLuminance=Nt;exports.roundedRectSDF=J;exports.safeSample=kt;exports.sampleBackdropLuminance=_t;exports.smoothStep=ee;exports.useBackdropLuminance=Ge;exports.useGlassCapabilities=yt;exports.useMousePosition=Dt;exports.usePrefersContrast=jt;exports.useReducedMotion=ge;exports.useReducedTransparency=Gt;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),n=require("react/jsx-runtime");var Ot={lensW:95,lensH:95,borderRadius:95,mapSize:512,clipToShape:!0,softEdge:!0,strength:.06,depth:.65,curvature:.6,splay:0,dispersion:.5,bend:0,bendWidth:.16,frost:.5,brightness:.1,specular:1,sheenAngle:45,sheenDark:!1,sheen:.3,sheenWidth:3,sheenFalloff:1.5,glow:.12,glowSpread:1,glowFalloff:.5},lr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",at=.22,Ar=Math.sqrt(Math.PI),_r=t=>Math.tanh(Ar*t),Zt=(t,e)=>e>0?(t-Math.sqrt(t*t-e*e))/e:0,kr=(t,e,a)=>{const i=Math.max(.01,Math.min(t,Math.min(e,a)-1)),s=(e*e+i*i)/(2*i),u=(a*a+i*i)/(2*i),f=Zt(s,e),h=Zt(u,a);return{Rx:s,Ry:u,scaleX:f>0?.5/f:1,scaleY:h>0?.5/h:1}},Fr=(t,e,a)=>{const i=Math.min(t,e*.999);return i/Math.sqrt(e*e-i*i)*a},Nt=(t,e)=>`${t} 0 0 0 ${.5*(1-t)} 0 ${e} 0 0 ${.5*(1-e)} 0 0 1 0 0 0 0 0 1 0`,er=new Map,ur=(t,e,a)=>{const i=Math.max(1,Math.round(t)),s=Math.max(1,Math.round(e)),u=Math.max(0,Math.min(Math.round(a),Math.min(i,s)/2)),f=`rr·${i}·${s}·${u}`,h=er.get(f);if(h)return{uri:h,key:f};const l=.5,o=Math.max(0,i-2*l),k=Math.max(0,s-2*l),X=Math.max(0,u-l),m=`<svg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' viewBox='0 0 ${i} ${s}'><rect fill='black' rx='${X}' ry='${X}' x='${l}' y='${l}' width='${o}' height='${k}'/></svg>`,d=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(m)}`;return er.set(f,d),{uri:d,key:f}},Lr=(t,e,a)=>{const i=Math.max(1,Math.round(t)),s=Math.max(1,Math.round(e)),u=Math.max(0,Math.min(Math.round(a),Math.floor(Math.min(i,s)/2)));return ur(i,s,u)},At=t=>(.5+t)*255+.5|0,tr=t=>127*t+128+.5|0,$t=t=>{let e=null,a=null,i=null,s=null,u=-1/0,f=-1/0,h=-1/0,l=0,o=!0,k=null;return{generate(X){e||(e=document.createElement("canvas"),e.width=t,e.height=t,a=e.getContext("2d"),i=a.createImageData(t,t));const{lensHalfWidth:m,lensHalfHeight:d,borderRadius:y,depth:G,clipToShape:N,softEdge:F,sheenAngle:z=45,glow:$=0,glowSpread:v=1,glowFalloff:q=1.5,sheen:U=0,sheenWidth:S=3,sheenFalloff:M=1.5,curvature:w=0,splay:D=0,bend:j=0,bendWidth:O=.16}=X,_=i.data,I=t>>1,W=Math.min(y,Math.min(m,d)),c=Math.min(m,d),K=Math.min(G*c,c-1),J=Math.max(0,m-K),E=Math.max(0,d-K),T=Math.max(0,Math.min(y,Math.min(J,E))),Y=K>0?Math.SQRT1_2/K:1e6,te=$>0||U>0,ce=z*Math.PI/180,re=Math.cos(ce),ee=Math.sin(ce),he=S>0?1/S:0,pe=1/Math.max(2,v*Math.min(m,d)),Re=2*m/t,C=2*d/t,V=1/m,g=1/d,Q=w>0,se=w*Math.min(m,d),A=D>0,Le=j>0,me=1/Math.max(2,O*Math.min(m,d)),B=(le,ue)=>le>0||ue>0?Math.sqrt(le*le+ue*ue):0;if(Q&&((!k||Math.abs(se-u)>.5||Math.abs(m-f)>1||Math.abs(d-h)>1)&&(k=kr(se,m,d),u=se,f=m,h=d,o=!0),l!==I&&(s=new Float32Array(I),l=I,o=!0),o)){const le=s,ue=k,Me=ue.Rx*ue.Rx,Ie=ue.Rx*(1-.001);for(let b=0;b<I;b+=1){const Te=-((b+.5)*Re-m),je=Te<Ie?Te:Ie;le[b]=je/Math.sqrt(Me-je*je)*ue.scaleX}o=!1}const Z=Q?s:null,ve=.5*Math.min(m,d),Ue=ve>0?1/ve:0,He=Math.SQRT1_2;for(let le=0;le<I;le+=1){const ue=t-1-le,Me=-((le+.5)*C-d),Ie=Me-d+W,b=F?Me-E+T:0,Te=Q&&Z?Fr(Me,k.Ry,k.scaleY):Me*g>1?1:Me*g,je=Me*g>1?1:Me*g,Oe=A?Math.max(0,1-(d-Me)*Ue):0,Ae=le*t,Ze=ue*t;for(let Ge=0;Ge<I;Ge+=1){const Ve=t-1-Ge,Pe=-((Ge+.5)*Re-m),we=Pe-m+W,x=B(we>0?we:0,Ie>0?Ie:0)+(we>Ie?we>0?0:we:Ie>0?0:Ie)-W,fe=(Ae+Ge)*4,de=(Ae+Ve)*4,be=(Ze+Ge)*4,ze=(Ze+Ve)*4;if(N&&x>=0){for(const ae of[fe,de,be,ze])_[ae]=128,_[ae+1]=128,_[ae+2]=128,_[ae+3]=255;continue}let R=Z?Z[Ge]:Pe*V>1?1:Pe*V,H=Te;if(A){const ae=Oe*D,Fe=Math.max(0,1-(m-Pe)*Ue)*D;if(ae>.001||Fe>.001){const et=R,Xe=H;R=et*(1-ae),H=Xe*(1-Fe);const tt=Math.sqrt(et*et+Xe*Xe),lt=Math.sqrt(R*R+H*H);if(lt>.001){const Mt=tt/lt;R*=Mt,H*=Mt}}}let ie=1;if(F){const ae=Pe-J+T,Fe=B(ae>0?ae:0,b>0?b:0)+(ae>b?ae>0?0:ae:b>0?0:b)-T;ie=.5*(1+_r(Fe*Y))}let Ce=.5*R*ie,De=.5*H*ie;if(Le){const ae=x<0?Math.max(0,1+x*me):0;if(ae>0){const Fe=Math.sqrt(R*R+H*H);if(Fe>1e-4){const et=6.75*ae*ae*(1-ae),Xe=.5*j*et*ie/Fe;Ce+=R*Xe,De+=H*Xe}}}let _e=0,ke=0;if(te){const ae=Pe*V>1?1:Pe*V,Fe=Math.min(1,Math.abs(ae*re+je*ee)*He),et=Math.min(1,Math.abs(ae*re-je*ee)*He);if(U>0){const Xe=x<0?Math.max(0,1+x*he):0,tt=U*Math.pow(Xe,M);_e+=tt*(.16+.84*Math.pow(Fe,1.6)),ke+=tt*(.16+.84*Math.pow(et,1.6))}if($>0){const tt=1-(x<0?Math.min(1,-x*pe):1),lt=$*Math.pow(tt*tt*(3-2*tt),q)*ie;_e+=lt*(.6+.4*Fe),ke+=lt*(.6+.4*et)}_e>1?_e=1:_e<-1&&(_e=-1),ke>1?ke=1:ke<-1&&(ke=-1)}const Ne=At(Ce),ct=At(-Ce),Be=At(De),ht=At(-De),Je=tr(_e),rt=tr(ke);_[fe]=Ne,_[fe+1]=Be,_[fe+2]=Je,_[fe+3]=255,_[de]=ct,_[de+1]=Be,_[de+2]=rt,_[de+3]=255,_[be]=Ne,_[be+1]=ht,_[be+2]=rt,_[be+3]=255,_[ze]=ct,_[ze+1]=ht,_[ze+2]=Je,_[ze+3]=255}}return a.putImageData(i,0,0),e.toDataURL()},dispose(){e&&(e.width=0,e.height=0,e=null),a=null,i=null,s=null,k=null,u=-1/0,f=-1/0,h=-1/0,l=0,o=!0}}},xe=t=>typeof t=="object"&&t!==null&&"get"in t&&"on"in t,We=t=>xe(t)?t.get():t,jr=class{constructor(t){this.subscribers=[],this.current=t}get(){return this.current}set(t){if(t!==this.current){this.current=t;for(const e of this.subscribers.slice())e(t)}}on(t,e){return this.subscribers.push(e),()=>{const a=this.subscribers.indexOf(e);a!==-1&&this.subscribers.splice(a,1)}}},ge=t=>new jr(t),ot=(t,e)=>{const a=ge(e()),i=()=>a.set(e());for(const s of t)s.on("change",i);return a},Et=(t,e,a,i)=>{const s=3*t,u=3*(a-t)-s,f=1-s-u,h=3*e,l=3*(i-e)-h,o=1-h-l,k=y=>((f*y+u)*y+s)*y,X=y=>((o*y+l)*y+h)*y,m=y=>(3*f*y+2*u)*y+s,d=y=>{let G=y;for(let z=0;z<8;z+=1){const $=k(G)-y;if(Math.abs($)<1e-6)return G;const v=m(G);if(Math.abs(v)<1e-6)break;G-=$/v}let N=0,F=1;for(G=y;N<F;){const z=k(G);if(Math.abs(z-y)<1e-6||(z<y?N=G:F=G,F-N<1e-7))break;G=(N+F)/2}return G};return y=>y<=0?0:y>=1?1:X(d(y))},Cr=Et(.34,1.36,.42,1),_t=new WeakMap,Dr=(t,e,{duration:a=.3,ease:i=Cr,onComplete:s}={})=>{var X;(X=_t.get(t))==null||X.stop();const u=t.get();if(u===e||a<=0)return t.set(e),s==null||s(),{stop(){}};const f=a*1e3;let h=0,l=0;const o=m=>{l===0&&(l=m);const d=(m-l)/f;if(d>=1){t.set(e),_t.delete(t),s==null||s();return}t.set(u+(e-u)*i(d)),h=requestAnimationFrame(o)};h=requestAnimationFrame(o);const k={stop(){cancelAnimationFrame(h),_t.delete(t)}};return _t.set(t,k),k},Wt=`#version 300 es
2
+ in vec2 a_pos;
3
+ out vec2 v_uv;
4
+ void main() {
5
+ // a_pos is a -1..1 fullscreen quad; v_uv is bottom-left-origin 0..1, which
6
+ // (with UNPACK_FLIP_Y on the textures) samples the source upright. The lens
7
+ // descriptor is supplied in this same bottom-left space by the component.
8
+ v_uv = a_pos * 0.5 + 0.5;
9
+ gl_Position = vec4(a_pos, 0.0, 1.0);
10
+ }`,Xr=`#version 300 es
11
+ precision highp float;
12
+ in vec2 v_uv;
13
+ out vec4 o;
14
+ uniform sampler2D u_src;
15
+ void main() { o = texture(u_src, v_uv); }`,Ir=`#version 300 es
16
+ precision highp float;
17
+ in vec2 v_uv;
18
+ out vec4 o;
19
+ uniform sampler2D u_src;
20
+ uniform vec2 u_step;
21
+ void main() {
22
+ vec4 c = texture(u_src, v_uv) * 0.1857;
23
+ c += (texture(u_src, v_uv + u_step) + texture(u_src, v_uv - u_step)) * 0.1671;
24
+ c += (texture(u_src, v_uv + 2.0 * u_step) + texture(u_src, v_uv - 2.0 * u_step)) * 0.1227;
25
+ c += (texture(u_src, v_uv + 3.0 * u_step) + texture(u_src, v_uv - 3.0 * u_step)) * 0.0768;
26
+ c += (texture(u_src, v_uv + 4.0 * u_step) + texture(u_src, v_uv - 4.0 * u_step)) * 0.0414;
27
+ o = c;
28
+ }`,Wr=`#version 300 es
29
+ precision highp float;
30
+ in vec2 v_uv;
31
+ out vec4 o;
32
+ uniform sampler2D u_src;
33
+ uniform sampler2D u_blur;
34
+ uniform sampler2D u_disp;
35
+ uniform vec2 u_origin;
36
+ uniform vec2 u_size;
37
+ uniform vec2 u_scale;
38
+ uniform vec2 u_lenspx; // lens box size in device px (for an aspect-correct SDF)
39
+ uniform float u_radiuspx; // corner radius in device px
40
+ uniform float u_dispersion;
41
+ uniform float u_sheen;
42
+ uniform float u_frost; // 0 = sharp; >0 = blend toward the pre-blurred copy
43
+ uniform float u_opacity; // enter/exit fade (multiplies coverage)
44
+ uniform float u_brightness; // white(>0)/black(<0) veil over the lens
45
+ // Signed distance to a rounded rectangle (negative inside). Computed in pixel
46
+ // space so the corner radius stays circular on non-square lenses. NB: the half-
47
+ // extent arg must NOT be named \`half\` — that's a reserved word in GLSL ES and
48
+ // Safari's (stricter) WebGL2 compiler rejects it, throwing at renderer init.
49
+ float sdRoundRect(vec2 p, vec2 b, float r) {
50
+ vec2 q = abs(p) - b + r;
51
+ return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
52
+ }
53
+ // Source sample, blended toward the frosted (pre-blurred) copy by mixAmt. The
54
+ // frost is what makes the glass read as liquid rather than a clear lens.
55
+ vec3 frosted(vec2 p, float mixAmt) {
56
+ vec3 raw = texture(u_src, p).rgb;
57
+ return mixAmt > 0.0 ? mix(raw, texture(u_blur, p).rgb, mixAmt) : raw;
58
+ }
59
+ void main() {
60
+ vec2 lensUV = (v_uv - u_origin) / u_size;
61
+ // Rounded-rect coverage. The SDF is in device px and a true distance field
62
+ // (gradient ~1), so a fixed ~1px feather anti-aliases the edge without fwidth
63
+ // (derivatives are handled inconsistently across WebGL2 backends).
64
+ vec2 p = (lensUV - 0.5) * u_lenspx;
65
+ float sdf = sdRoundRect(p, u_lenspx * 0.5, min(u_radiuspx, min(u_lenspx.x, u_lenspx.y) * 0.5));
66
+ float coverage = (1.0 - smoothstep(-1.0, 1.0, sdf)) * u_opacity;
67
+ if (coverage <= 0.0) discard;
68
+ vec4 d = texture(u_disp, clamp(lensUV, 0.0, 1.0));
69
+ vec2 disp = (d.rg - 0.5) * u_scale; // feDisplacementMap equivalent
70
+ // RGB split — red bent DISPERSION_SPREAD more than blue, green half that (keep
71
+ // in sync with DISPERSION_SPREAD in displacement.ts so DOM + WebGL match).
72
+ vec2 uvR = v_uv + disp * (1.0 + u_dispersion * 0.22);
73
+ vec2 uvG = v_uv + disp * (1.0 + u_dispersion * 0.11);
74
+ vec2 uvB = v_uv + disp;
75
+ vec3 lensCol = vec3(frosted(uvR, u_frost).r, frosted(uvG, u_frost).g, frosted(uvB, u_frost).b);
76
+ // Specular lift from B. The map encodes spec as B = 127·s + 128, so (B/255 − 0.5)
77
+ // = 0.498·s; this matches the DOM path's gain exactly (feColorMatrix 1× alpha
78
+ // then feComposite k2=specular → 0.498·specular·s). (NOT ×2 — that double-lifted it.)
79
+ lensCol += u_sheen * max(0.0, d.b - 0.5);
80
+ // Brightness veil (alpha-blend toward white/black, like the DOM path).
81
+ if (u_brightness > 0.0) lensCol = mix(lensCol, vec3(1.0), clamp(u_brightness, 0.0, 1.0));
82
+ else if (u_brightness < 0.0) lensCol = mix(lensCol, vec3(0.0), clamp(-u_brightness, 0.0, 1.0));
83
+ // Mix over the untouched backdrop by the coverage → an AA'd, frosted-clipping
84
+ // silhouette. Canvas stays fully opaque, so straight/premultiplied alpha is moot.
85
+ vec3 backdrop = texture(u_src, v_uv).rgb;
86
+ o = vec4(mix(backdrop, lensCol, coverage), 1.0);
87
+ }`,rr=(t,e,a)=>{const i=t.createShader(e);if(t.shaderSource(i,a),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){const s=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`glass-webgl shader: ${s}`)}return i},Gt=(t,e,a)=>{const i=t.createProgram(),s=rr(t,t.VERTEX_SHADER,e),u=rr(t,t.FRAGMENT_SHADER,a);if(t.attachShader(i,s),t.attachShader(i,u),t.bindAttribLocation(i,0,"a_pos"),t.linkProgram(i),t.deleteShader(s),t.deleteShader(u),!t.getProgramParameter(i,t.LINK_STATUS)){const f=t.getProgramInfoLog(i);throw t.deleteProgram(i),new Error(`glass-webgl link: ${f}`)}return i},Gr=class{constructor(t){this.dispCache=new Map,this.blurW=0,this.blurH=0,this.srcW=0,this.srcH=0,this.disposed=!1;const e=t.getContext("webgl2",{premultipliedAlpha:!1,alpha:!0,antialias:!1,preserveDrawingBuffer:!1});if(!e)throw new Error("webgl2 unavailable");this.gl=e,this.blit=Gt(e,Wt,Xr),this.lens=Gt(e,Wt,Wr),this.blur=Gt(e,Wt,Ir),this.quad=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.quad),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),e.STATIC_DRAW);const a=()=>{const i=e.createTexture();return e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),i};this.srcTex=a(),this.dispTex=a(),this.blurTex=[a(),a()],this.fbo=[e.createFramebuffer(),e.createFramebuffer()],e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),this.uBlitSrc=e.getUniformLocation(this.blit,"u_src"),this.uBlur={src:e.getUniformLocation(this.blur,"u_src"),step:e.getUniformLocation(this.blur,"u_step")},this.uLens={src:e.getUniformLocation(this.lens,"u_src"),blur:e.getUniformLocation(this.lens,"u_blur"),disp:e.getUniformLocation(this.lens,"u_disp"),origin:e.getUniformLocation(this.lens,"u_origin"),size:e.getUniformLocation(this.lens,"u_size"),scale:e.getUniformLocation(this.lens,"u_scale"),lenspx:e.getUniformLocation(this.lens,"u_lenspx"),radiuspx:e.getUniformLocation(this.lens,"u_radiuspx"),dispersion:e.getUniformLocation(this.lens,"u_dispersion"),specular:e.getUniformLocation(this.lens,"u_sheen"),frost:e.getUniformLocation(this.lens,"u_frost"),opacity:e.getUniformLocation(this.lens,"u_opacity"),brightness:e.getUniformLocation(this.lens,"u_brightness")}}ensureBlurTargets(t,e){if(t===this.blurW&&e===this.blurH)return;const a=this.gl;for(let i=0;i<2;i+=1)a.bindTexture(a.TEXTURE_2D,this.blurTex[i]),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,t,e,0,a.RGBA,a.UNSIGNED_BYTE,null),a.bindFramebuffer(a.FRAMEBUFFER,this.fbo[i]),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.blurTex[i],0);a.bindFramebuffer(a.FRAMEBUFFER,null),this.blurW=t,this.blurH=e}renderFrost(t){const e=this.gl;this.ensureBlurTargets(this.srcW,this.srcH),e.useProgram(this.blur),e.viewport(0,0,this.srcW,this.srcH),e.activeTexture(e.TEXTURE0),e.uniform1i(this.uBlur.src,0),e.bindFramebuffer(e.FRAMEBUFFER,this.fbo[0]),e.bindTexture(e.TEXTURE_2D,this.srcTex),e.uniform2f(this.uBlur.step,t/this.srcW,0),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindFramebuffer(e.FRAMEBUFFER,this.fbo[1]),e.bindTexture(e.TEXTURE_2D,this.blurTex[0]),e.uniform2f(this.uBlur.step,0,t/this.srcH),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindFramebuffer(e.FRAMEBUFFER,null)}setDisplacementMap(t){if(this.disposed)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,this.dispTex),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t)}dispTexFor(t){const e=this.gl;let a=this.dispCache.get(t);return a||(a=e.createTexture(),e.bindTexture(e.TEXTURE_2D,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),this.dispCache.set(t,a)),a}releaseDispMap(t){const e=this.dispCache.get(t);e&&(this.gl.deleteTexture(e),this.dispCache.delete(t))}resize(t,e){const a=this.gl.canvas;(a.width!==t||a.height!==e)&&(a.width=t,a.height=e)}uploadSource(t,e,a){const i=this.gl;i.bindTexture(i.TEXTURE_2D,this.srcTex),e!==this.srcW||a!==this.srcH?(i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.srcW=e,this.srcH=a):i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,t)}render(t,e,a,i){if(this.disposed||e===0||a===0)return;const s=this.gl;this.uploadSource(t,e,a),s.bindBuffer(s.ARRAY_BUFFER,this.quad),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,0,0),s.disable(s.BLEND);const u=i.reduce((l,o)=>Math.max(l,o.blur),0);u>0&&this.renderFrost(u);const f=s.canvas.width,h=s.canvas.height;s.viewport(0,0,f,h),s.useProgram(this.blit),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.srcTex),s.uniform1i(this.uBlitSrc,0),s.drawArrays(s.TRIANGLE_STRIP,0,4),s.useProgram(this.lens),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.srcTex),s.uniform1i(this.uLens.src,0),s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.dispTex),s.uniform1i(this.uLens.disp,1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.blurTex[1]),s.uniform1i(this.uLens.blur,2);for(const l of i){const o=l.opacity??1;o<=0||(s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,l.dispMap?this.dispTexFor(l.dispMap):this.dispTex),s.uniform2f(this.uLens.origin,l.originX,l.originY),s.uniform2f(this.uLens.size,l.sizeX,l.sizeY),s.uniform2f(this.uLens.scale,l.scaleX,l.scaleY),s.uniform2f(this.uLens.lenspx,l.sizeX*f,l.sizeY*h),s.uniform1f(this.uLens.radiuspx,(l.cornerRadius??0)*f),s.uniform1f(this.uLens.dispersion,l.dispersion),s.uniform1f(this.uLens.specular,l.specular),s.uniform1f(this.uLens.frost,l.blur>0?Math.min(1,l.blur/8):0),s.uniform1f(this.uLens.opacity,o),s.uniform1f(this.uLens.brightness,l.brightness??0),s.drawArrays(s.TRIANGLE_STRIP,0,4))}}dispose(){if(this.disposed)return;this.disposed=!0;const t=this.gl;t.deleteProgram(this.blit),t.deleteProgram(this.lens),t.deleteProgram(this.blur),t.deleteTexture(this.srcTex),t.deleteTexture(this.dispTex),this.dispCache.forEach(a=>t.deleteTexture(a)),this.dispCache.clear(),t.deleteTexture(this.blurTex[0]),t.deleteTexture(this.blurTex[1]),t.deleteFramebuffer(this.fbo[0]),t.deleteFramebuffer(this.fbo[1]),t.deleteBuffer(this.quad);const e=t.getExtension("WEBGL_lose_context");e==null||e.loseContext()}},Br=()=>typeof window<"u"&&window.devicePixelRatio||1,Pr=t=>({merged:{...Ot,...t.lens},lensW:t.lensW,lensH:t.lensH,radius:t.borderRadius,x:t.x,y:t.y,scale:t.scale??1,opacity:t.opacity??1}),Ur=(t,e,a,i,s,u)=>{const[f,h]=r.useState(!1),l=r.useRef(null),o=r.useRef(null),k=i[0],X=r.useRef(i);X.current=i;const m=i.some(S=>xe(S.x)||xe(S.y)||xe(S.lensW)||xe(S.lensH)||S.radius!=null&&xe(S.radius));r.useLayoutEffect(()=>{const S=t.current,M=e.current;if(!S||!M)return;let w;try{w=new Gr(S)}catch(_){typeof console<"u"&&console.warn("[liquid-glass] WebGL renderer unavailable, falling back:",_),h(!0);return}l.current=w;const D=Math.min(Br(),s),j=()=>{const _=M.clientWidth,I=M.clientHeight;S.style.width=`${_}px`,S.style.height=`${I}px`,w.resize(Math.round(_*D),Math.round(I*D))};j();const O=new ResizeObserver(j);return O.observe(M),()=>{O.disconnect(),w.dispose(),l.current=null}},[t,e,s]);const d=k.merged,y=We(k.lensW),G=We(k.lensH),N=k.radius!=null?We(k.radius):Math.min(y,G),F=JSON.stringify([d.mapSize,y,G,N,d.depth,d.clipToShape,d.softEdge,d.curvature,d.splay,d.glow,d.glowSpread,d.glowFalloff,d.sheen,d.sheenWidth,d.sheenFalloff,d.sheenAngle,d.bend,d.bendWidth]);r.useEffect(()=>{if(!l.current)return;o.current||(o.current=$t(d.mapSize));const M=o.current.generate({lensHalfWidth:y,lensHalfHeight:G,borderRadius:N,depth:d.depth,clipToShape:d.clipToShape,softEdge:d.softEdge,sheenAngle:d.sheenAngle,glow:d.glow,glowSpread:d.glowSpread,glowFalloff:d.glowFalloff,sheen:d.sheen,sheenWidth:d.sheenWidth,sheenFalloff:d.sheenFalloff,curvature:d.curvature,splay:d.splay,bend:d.bend,bendWidth:d.bendWidth});let w=!1;const D=new Image;return D.onload=()=>{var j;w||(j=l.current)==null||j.setDisplacementMap(D)},D.src=M,()=>{w=!0}},[F,f]);const z=S=>{const M=S.merged,w=We(S.lensW),D=We(S.lensH),j=S.radius!=null?We(S.radius):Math.min(w,D);return JSON.stringify([M.mapSize,w,D,j,M.depth,M.clipToShape,M.softEdge,M.curvature,M.splay,M.glow,M.glowSpread,M.glowFalloff,M.sheen,M.sheenWidth,M.sheenFalloff,M.sheenAngle,M.bend,M.bendWidth])},$=i.map(z),v=r.useRef($);v.current=$;const q=r.useRef(new Map),U=$.join("|");return r.useEffect(()=>{const S=o.current;if(!S)return;const M=new Set(v.current);q.current.forEach((O,_)=>{var I;M.has(_)||(q.current.delete(_),(I=l.current)==null||I.releaseDispMap(O))});const w=v.current[0],D=[],j=new Set;return i.forEach((O,_)=>{const I=v.current[_];if(I===w||j.has(I)||q.current.has(I))return;j.add(I);const W=O.merged,c=We(O.lensW),K=We(O.lensH),J=O.radius!=null?We(O.radius):Math.min(c,K),E=S.generate({lensHalfWidth:c,lensHalfHeight:K,borderRadius:J,depth:W.depth,clipToShape:W.clipToShape,softEdge:W.softEdge,sheenAngle:W.sheenAngle,glow:W.glow,glowSpread:W.glowSpread,glowFalloff:W.glowFalloff,sheen:W.sheen,sheenWidth:W.sheenWidth,sheenFalloff:W.sheenFalloff,curvature:W.curvature,splay:W.splay,bend:W.bend,bendWidth:W.bendWidth});let T=!1;const Y=new Image;Y.onload=()=>{T||q.current.set(I,Y)},Y.src=E,D.push(()=>{T=!0})}),()=>D.forEach(O=>O())},[U,f]),r.useEffect(()=>()=>{var S;(S=o.current)==null||S.dispose(),o.current=null},[]),r.useEffect(()=>{if(f)return;let S=0,M=0;const w=u,D=!!w&&!m&&typeof w.requestVideoFrameCallback=="function",j=()=>{const O=l.current,_=e.current;if(!O||!_)return;const I=a();if(I&&I.w>0&&I.h>0){const W=_.clientWidth,c=_.clientHeight,K=Math.sqrt((W*W+c*c)/2),J=v.current,E=X.current.map((T,Y)=>{const te=We(T.lensW),ce=We(T.lensH),re=T.radius!=null?We(T.radius):Math.min(te,ce),ee=We(T.x),he=We(T.y),pe=te*T.scale,Re=ce*T.scale,C=Y>0&&J[Y]!==J[0],V=C?q.current.get(J[Y]):void 0,g=C&&!V;return{originX:(ee*W-pe)/W,originY:1-(he*c+Re)/c,sizeX:2*pe/W,sizeY:2*Re/c,scaleX:g?0:(T.merged.scaleX??T.merged.strength)*K/W,scaleY:g?0:(T.merged.scaleY??T.merged.strength)*K/c,dispersion:T.merged.dispersion,specular:T.merged.specular,blur:T.merged.frost,cornerRadius:re*T.scale/W,opacity:T.opacity,brightness:T.merged.brightness,dispMap:V}});O.render(I.source,I.w,I.h,E)}D?M=w.requestVideoFrameCallback(j):S=requestAnimationFrame(j)};return D?M=w.requestVideoFrameCallback(j):S=requestAnimationFrame(j),()=>{var O;cancelAnimationFrame(S),D&&M&&((O=w.cancelVideoFrameCallback)==null||O.call(w,M))}},[f,a,e,u,m]),f},Or=({src:t,draw:e,poster:a,loop:i=!0,muted:s=!0,autoPlay:u=!0,crossOrigin:f,paused:h,videoRef:l,lenses:o,width:k,height:X,lens:m,lensW:d=90,lensH:y=90,borderRadius:G,x:N=.5,y:F=.5,maxDpr:z=1.5,className:$,style:v,children:q})=>{const U=t!=null,S=r.useRef(null),M=r.useRef(null),w=r.useRef(null),[D,j]=r.useState(null),O=r.useCallback(E=>{w.current=E,typeof l=="function"?l(E):l&&(l.current=E)},[l]),_=r.useRef(null),I=r.useRef(e);I.current=e;const W=r.useRef(0);!U&&!_.current&&typeof document<"u"&&(_.current=document.createElement("canvas"));const c=(o&&o.length?o.map(E=>({lens:E.optics?{...m,...E.optics}:m,lensW:E.w/2,lensH:E.h/2,borderRadius:E.radius,x:E.x,y:E.y,scale:E.scale,opacity:E.opacity})):[{lens:m,lensW:d,lensH:y,borderRadius:G,x:N,y:F}]).map(Pr);r.useEffect(()=>{U&&j(w.current)},[U]),r.useEffect(()=>{const E=w.current;!U||!E||h===void 0||(h?E.pause():E.play().catch(()=>{}))},[U,h]);const K=r.useCallback(()=>{if(U){const re=w.current;return!re||re.readyState<2?null:{source:re,w:re.videoWidth,h:re.videoHeight}}const E=_.current,T=S.current;if(!E||!T||!I.current)return null;const Y=k??Math.round(T.clientWidth),te=X??Math.round(T.clientHeight);if(Y===0||te===0)return null;(E.width!==Y||E.height!==te)&&(E.width=Y,E.height=te);const ce=E.getContext("2d");return ce?(W.current===0&&(W.current=performance.now()),I.current(ce,performance.now()-W.current),{source:E,w:Y,h:te}):null},[U,k,X]),J=Ur(M,S,K,c,z,U?D:null);return n.jsxs("div",{ref:S,className:$,style:{position:"relative",overflow:"hidden",...v},children:[U&&n.jsx("video",{ref:O,src:t,poster:a,loop:i,muted:s,autoPlay:u,playsInline:!0,crossOrigin:f,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",visibility:J?"visible":"hidden"}}),n.jsx("canvas",{ref:M,style:{position:"absolute",inset:0,pointerEvents:"none",display:J?"none":"block"}}),!U&&J&&n.jsx("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center",color:"#888",font:"13px system-ui"},children:"WebGL unavailable"}),q!=null&&n.jsx("div",{style:{position:"absolute",inset:0},children:q})]})},Nr=()=>{const[t,e]=r.useState(!1);return r.useEffect(()=>{if(typeof navigator>"u")return;const a=navigator.userAgent,s=navigator.userAgentData!=null||/\b(?:Chrome|Chromium|Edg)\//.test(a)&&!/\b(?:CriOS|EdgiOS|FxiOS|OPiOS)\b/.test(a)&&!/iPhone|iPad|iPod/.test(a);e(s)},[]),t},$r={strength:.05,depth:.5,curvature:.3,bend:.45,bendWidth:.16,dispersion:.32,frost:6,saturate:1.15,sheen:.32,sheenWidth:3,sheenFalloff:1.5,glow:.1,glowSpread:1,glowFalloff:.5,specular:1,sheenAngle:45,brightness:0},Hr=({dispScale:t,dispersion:e,specular:a,hasSpecular:i,mapMatrix:s,width:u,height:f,mapUrl:h,feImageRef:l})=>{const o=s?"scaledMap":"map";return n.jsxs(n.Fragment,{children:[n.jsx("feFlood",{floodColor:"rgb(128,128,128)",floodOpacity:"1",result:"mapBg"}),n.jsx("feImage",{ref:l,href:h||void 0,x:0,y:0,width:u,height:f,preserveAspectRatio:"none",result:"rawMap"}),n.jsx("feComposite",{in:"rawMap",in2:"mapBg",operator:"over",result:"map"}),s&&n.jsx("feColorMatrix",{in:"map",type:"matrix",values:s,result:"scaledMap"}),e>0?n.jsxs(n.Fragment,{children:[n.jsx("feDisplacementMap",{in:"SourceGraphic",in2:o,scale:t*(1+at*e),xChannelSelector:"R",yChannelSelector:"G"}),n.jsx("feColorMatrix",{type:"matrix",values:"1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0",result:"refractR"}),n.jsx("feDisplacementMap",{in:"SourceGraphic",in2:o,scale:t*(1+at*.5*e),xChannelSelector:"R",yChannelSelector:"G"}),n.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0",result:"refractG"}),n.jsx("feDisplacementMap",{in:"SourceGraphic",in2:o,scale:t,xChannelSelector:"R",yChannelSelector:"G"}),n.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0",result:"refractB"}),n.jsx("feComposite",{in:"refractR",in2:"refractG",operator:"arithmetic",k1:"0",k2:"1",k3:"1",k4:"0",result:"refractRG"}),n.jsx("feComposite",{in:"refractRG",in2:"refractB",operator:"arithmetic",k1:"0",k2:"1",k3:"1",k4:"0",result:"lensOut"})]}):n.jsx("feDisplacementMap",{in:"SourceGraphic",in2:o,scale:t,xChannelSelector:"R",yChannelSelector:"G",result:"lensOut"}),i&&n.jsxs(n.Fragment,{children:[n.jsx("feColorMatrix",{in:"map",type:"matrix",values:`0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 1 0 ${-128/255}`,result:"sheenMask"}),n.jsx("feComposite",{in:"sheenMask",in2:"lensOut",operator:"arithmetic",k1:"0",k2:a,k3:"1",k4:"0"})]})]})},Bt=t=>t==null?void 0:xe(t)?We(t):t,zr=({children:t,optics:e,radius:a,width:i,height:s,className:u,style:f,...h})=>{const l=Nr(),o=r.useMemo(()=>({...Ot,...$r,...e}),[e]),k=r.useId().replace(/:/g,""),X=r.useRef(null),m=r.useRef(null),d=r.useRef(null),y=r.useRef(null),G=r.useRef(""),N=r.useRef(0),[F,z]=r.useState({w:0,h:0,r:0,appliedR:void 0}),[$,v]=r.useState(!1),q=F.w>0&&F.h>0,U=Bt(a),S=Bt(i),M=Bt(s),w=(f==null?void 0:f.borderRadius)!=null,D=r.useRef(!1);r.useLayoutEffect(()=>{D.current=!1},[U,w,u]),r.useLayoutEffect(()=>{const C=X.current;if(!C)return;const V=()=>{const Q=C.getBoundingClientRect(),se=typeof getComputedStyle<"u",A=se?getComputedStyle(C):null,Le=A&&parseFloat(A.borderTopLeftRadius)||0;if(A){const Z=A.position;v(ve=>Z==="static"?!0:Z==="relative"?ve:!1)}let me,B;if(U!=null)me=U,B=U;else if(w||Le>0&&!D.current)me=Le,B=void 0;else{let Z=C.firstElementChild;for(;Z&&Z.hasAttribute("data-lg-layer");)Z=Z.nextElementSibling;const ve=Z&&se&&parseFloat(getComputedStyle(Z).borderTopLeftRadius)||0;me=ve,B=ve,D.current=!0}z(Z=>Z.w===Q.width&&Z.h===Q.height&&Z.r===me&&Z.appliedR===B?Z:{w:Q.width,h:Q.height,r:me,appliedR:B})};V();const g=new ResizeObserver(V);return g.observe(C),window.addEventListener("resize",V),()=>{g.disconnect(),window.removeEventListener("resize",V)}},[U,w,u]);const j=JSON.stringify([F.w,F.h,F.r,o.mapSize,o.clipToShape,o.softEdge,o.depth,o.curvature,o.splay,o.bend,o.bendWidth,o.sheen,o.sheenWidth,o.sheenFalloff,o.sheenAngle,o.glow,o.glowSpread,o.glowFalloff]),O=o.scaleX??o.strength,_=o.scaleY??o.strength,I=Math.max(O,_),W=q?Math.sqrt((F.w*F.w+F.h*F.h)/2):0,c=I*W,K=q?Math.ceil(c*(o.dispersion>0?1.2:1)*.5+28):0,J=I>0?O/I:1,E=I>0?_/I:1,T=J===1&&E===1?null:Nt(J,E),Y=o.glow>0||o.sheen>0;r.useLayoutEffect(()=>{var g,Q;if(!q)return;const C=o.mapSize;(!y.current||y.current.size!==C)&&((g=y.current)==null||g.gen.dispose(),y.current={gen:$t(C),size:C});const V=y.current.gen.generate({lensHalfWidth:F.w/2,lensHalfHeight:F.h/2,borderRadius:F.r,depth:o.depth,clipToShape:o.clipToShape,softEdge:o.softEdge,sheenAngle:o.sheenAngle,glow:o.glow,glowSpread:o.glowSpread,glowFalloff:o.glowFalloff,sheen:o.sheen,sheenWidth:o.sheenWidth,sheenFalloff:o.sheenFalloff,curvature:o.curvature,splay:o.splay,bend:o.bend,bendWidth:o.bendWidth});G.current=V,(Q=d.current)==null||Q.setAttribute("href",V),te()},[q,j]);const te=r.useMemo(()=>()=>{const C=X.current,V=m.current;if(!C)return;const g=Math.max(0,o.frost),Q=o.saturate??1,se=[g>0?`blur(${g}px)`:"",Q!==1?`saturate(${Q})`:""].filter(Boolean).join(" ");let A=se||"none";l&&V&&G.current&&(N.current+=1,V.id=`lg-mat-${k}-v${N.current}`,A=`${se?se+" ":""}url(#${V.id})`),C.style.backdropFilter=A,C.style.setProperty("-webkit-backdrop-filter",A)},[o.frost,o.saturate,l,k]);r.useEffect(()=>{q&&te()},[q,te,o.dispersion,o.strength,o.scaleX,o.scaleY,o.specular]),r.useEffect(()=>()=>{var C;(C=y.current)==null||C.gen.dispose(),y.current=null},[]);const ce=r.useRef(!1);r.useEffect(()=>{if(ce.current||!q||typeof getComputedStyle>"u"||typeof document>"u")return;const C=X.current;if(!C)return;const V=getComputedStyle(C).backgroundColor;let g=!1;try{const Q=document.createElement("canvas");Q.width=Q.height=1;const se=Q.getContext("2d");se&&(se.clearRect(0,0,1,1),se.fillStyle=V,se.fillRect(0,0,1,1),g=se.getImageData(0,0,1,1).data[3]===255)}catch{g=!1}g&&typeof console<"u"&&(console.warn("[liquid-glass] <Glass>: the wrapper's background is fully opaque, so it hides the refraction (no glass shows through). Give it an alpha (e.g. `bg-red-400/40` / `rgba(...,0.4)`). (An opaque `background-image` — a solid gradient or photo — hides it the same way.)"),ce.current=!0)},[q]);const re=r.useMemo(()=>{const C=Math.max(0,Math.min(1.5,o.specular));return[`inset 0 1px 0 rgba(255,255,255,${(.55*C).toFixed(3)})`,`inset 0 0 0 1px rgba(255,255,255,${(.12*C).toFixed(3)})`].join(", ")},[o.specular]),ee=f==null?void 0:f.position,pe=ee!=null&&ee!=="static"&&ee!=="unset"&&ee!=="initial"?ee:$?"relative":void 0,Re=o.brightness!==0?n.jsx("div",{"aria-hidden":!0,"data-lg-layer":"",style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",background:o.brightness>0?"#fff":"#000",opacity:Math.min(1,Math.abs(o.brightness))}}):null;return n.jsxs("div",{ref:X,"data-liquid-glass":"material",className:u,style:{display:"inline-block",...f,...pe!=null?{position:pe}:null,...S!=null?{width:S}:null,...M!=null?{height:M}:null,...F.appliedR!=null?{borderRadius:F.appliedR}:null},...h,children:[Re,t,n.jsx("div",{"aria-hidden":!0,"data-lg-layer":"",style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",boxShadow:re}}),n.jsx("svg",{"aria-hidden":!0,"data-lg-layer":"",width:0,height:0,style:{position:"absolute",width:0,height:0},children:n.jsx("defs",{children:n.jsx("filter",{ref:m,id:`lg-mat-${k}-v0`,filterUnits:"userSpaceOnUse",primitiveUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",x:-K,y:-K,width:F.w+2*K,height:F.h+2*K,children:q&&n.jsx(Hr,{dispScale:c,dispersion:o.dispersion,specular:o.specular,hasSpecular:Y,mapMatrix:T,width:F.w,height:F.h,mapUrl:G.current||"",feImageRef:d})})})})]})},Yr=()=>{const[t,e]=r.useState(!1);return r.useEffect(()=>{e(typeof navigator<"u"&&/^((?!chrome|chromium|android).)*safari/i.test(navigator.userAgent))},[]),t},qr=({lens:t,mapHref:e,feImageRef:a,mapMatrixRef:i,blurStdDeviation:s,specularFromRawMap:u,brightnessInFilter:f,filterW:h,filterH:l,clipShapeRef:o})=>{const k=t.scaleX??t.strength,X=t.scaleY??t.strength,m=Math.max(k,X),d=h&&l?Math.sqrt((h*h+l*l)/2):1,y=m*d,G=m>0?k/m:0,N=m>0?X/m:0,F=!(G===1&&N===1),z=F?"scaledMap":"map",$=t.frost>0&&!!s,v=$?"blurred":"SourceGraphic",q=t.glow>0||t.sheen>0,U=t.specular,S=f&&t.brightness!==0,M=$||S;return n.jsxs(n.Fragment,{children:[n.jsx("feFlood",{floodColor:"rgb(128,128,128)",floodOpacity:"1",result:"mapBg"}),n.jsx("feImage",{ref:a,"data-lens":"",href:e,preserveAspectRatio:"none",result:"rawMap"}),n.jsx("feComposite",{in:"rawMap",in2:"mapBg",operator:"over",result:"map"}),F&&n.jsx("feColorMatrix",{ref:i,in:"map",type:"matrix",values:Nt(G,N),result:"scaledMap"}),$&&n.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:s,result:"blurred"}),M&&n.jsx("feImage",{ref:o,"data-lens":"",href:lr,preserveAspectRatio:"none",result:"lensShape"}),t.dispersion>0?n.jsxs(n.Fragment,{children:[n.jsx("feDisplacementMap",{"data-lens":"",in:v,in2:z,scale:y*(1+at*.5*t.dispersion),xChannelSelector:"R",yChannelSelector:"G"}),n.jsx("feColorMatrix",{type:"matrix",values:"1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0",result:"refractR"}),n.jsx("feDisplacementMap",{"data-lens":"",in:v,in2:z,scale:y,xChannelSelector:"R",yChannelSelector:"G"}),n.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0",result:"refractG"}),n.jsx("feDisplacementMap",{"data-lens":"",in:v,in2:z,scale:y*(1-at*.5*t.dispersion),xChannelSelector:"R",yChannelSelector:"G"}),n.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0",result:"refractB"}),n.jsx("feComposite",{in:"refractR",in2:"refractG",operator:"arithmetic",k1:"0",k2:"1",k3:"1",k4:"0",result:"refractRG"}),n.jsx("feComposite",{in:"refractRG",in2:"refractB",operator:"arithmetic",k1:"0",k2:"1",k3:"1",k4:"0",result:"lensOut"})]}):n.jsx("feDisplacementMap",{"data-lens":"",in:v,in2:z,scale:y,xChannelSelector:"R",yChannelSelector:"G",result:"lensOut"}),q&&(t.sheenDark?n.jsxs(n.Fragment,{children:[n.jsx("feColorMatrix",{in:u?"rawMap":"map",type:"matrix",values:`0 0 ${-U} 0 ${1+128*U/255} 0 0 ${-U} 0 ${1+128*U/255} 0 0 ${-U} 0 ${1+128*U/255} 0 0 0 0 1`,result:"sheenMask"}),n.jsx("feComposite",{in:"sheenMask",in2:"lensOut",operator:"arithmetic",k1:"1",k2:"0",k3:"0",k4:"0",result:"lensOut"})]}):n.jsxs(n.Fragment,{children:[n.jsx("feColorMatrix",{in:u?"rawMap":"map",type:"matrix",values:`0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 1 0 ${-128/255}`,result:"sheenMask"}),n.jsx("feComposite",{in:"sheenMask",in2:"lensOut",operator:"arithmetic",k1:"0",k2:U,k3:"1",k4:"0",result:"lensOut"})]})),S&&n.jsxs(n.Fragment,{children:[n.jsx("feFlood",{"data-lens":"",floodColor:t.brightness>0?"white":"black",floodOpacity:Math.abs(t.brightness),result:"brightnessFlood"}),n.jsx("feComposite",{in:"brightnessFlood",in2:"lensShape",operator:"in",result:"brightnessVeil"}),n.jsx("feComposite",{in:"brightnessVeil",in2:"lensOut",operator:"over",result:"lensOut"})]}),M?n.jsxs(n.Fragment,{children:[n.jsx("feComposite",{in:"lensOut",in2:"lensShape",operator:"in",result:"lensOut"}),n.jsx("feComposite",{in:"SourceGraphic",in2:"lensShape",operator:"out",result:"cutoutSrc"}),n.jsx("feComposite",{in:"lensOut",in2:"cutoutSrc",operator:"over"})]}):n.jsxs(n.Fragment,{children:[n.jsx("feFlood",{"data-lens":"",floodColor:"black",floodOpacity:"1",result:"lensMask"}),n.jsx("feComposite",{in:"SourceGraphic",in2:"lensMask",operator:"out",result:"cutoutSrc"}),n.jsx("feComposite",{in:"lensOut",in2:"cutoutSrc",operator:"over"})]})]})},Kr=({children:t,lens:e,x:a=.5,y:i=.5,lensW:s,lensH:u,borderRadius:f,refractionTarget:h,refractionBackground:l="transparent",overlay:o,tintColor:k,tintOpacity:X,tintBlur:m,shadowOpacity:d,restShadowOpacity:y,edgeBias:G,depth:N,scale:F,filterResolution:z=1,brightnessInFilter:$=!1,pixelUnits:v=!1,live:q=!1,onLensMapChange:U,className:S,style:M,...w})=>{const D=Yr(),j=r.useRef(D);j.current=D;const O=r.useRef($);O.current=$;const _=r.useRef(v);_.current=v;const I=r.useRef(q);I.current=q;const W=r.useRef(z);W.current=z;const c=r.useMemo(()=>({...Ot,...e}),[e]),K=r.useRef(c);K.current=c;const J=r.useId().replace(/:/g,""),E=r.useRef(null),T=r.useRef(null),Y=r.useRef(null),te=r.useRef(null),ce=r.useRef(null),re=r.useRef(null),ee=r.useRef(null),he=r.useRef(null),pe=r.useRef(null),Re=r.useRef(null),C=r.useRef(null),V=r.useRef(null),g=r.useRef(null),Q=r.useRef([]),se=r.useRef([]),[A,Le]=r.useState({w:0,h:0}),me=r.useRef(A);me.current=A;const B=A.w>0&&A.h>0,Z=h!=null,[ve,Ue]=r.useState(null);r.useLayoutEffect(()=>{var L,ne;if(!Z||l!=="transparent"){Ue(null);return}if(typeof window>"u")return;let P=((L=E.current)==null?void 0:L.parentElement)??null,p=null;for(;P;){const Ye=getComputedStyle(P).backgroundColor,ye=(ne=Ye.match(/rgba?\(([^)]+)\)/))==null?void 0:ne[1].split(",");if((ye&&ye[3]!=null?parseFloat(ye[3]):1)>.95){p=Ye;break}P=P.parentElement}Ue(p)},[Z,l]);const He=l!=="transparent"?l:ve??"transparent",le=r.useRef(.5),ue=r.useRef(.5),Me=r.useRef(c.lensW),Ie=r.useRef(c.lensH),b=r.useRef(c.borderRadius),Te=r.useRef(s!==void 0);Te.current=s!==void 0;const je=r.useRef(u!==void 0);je.current=u!==void 0;const Oe=r.useRef(f!==void 0);Oe.current=f!==void 0;const Ae=r.useRef(0),Ze=r.useRef(c.depth),Ge=r.useRef(c.scaleX??c.strength),Ve=r.useRef(c.scaleY??c.strength),Pe=r.useRef(1),we=r.useRef(0),x=r.useRef(1),fe=r.useRef(0),de=r.useRef(.5),be=r.useRef(NaN),ze=r.useRef(NaN),R=r.useRef(NaN),H=r.useRef(1),ie=r.useRef(0),Ce=r.useRef(""),De=r.useRef(!1),_e=r.useRef(null),ke=r.useRef(null),Ne=r.useRef(null),ct=r.useRef(k);ct.current=k;const Be=r.useRef(U);Be.current=U;const ht=A.w>0&&A.h>0?Math.sqrt((A.w*A.w+A.h*A.h)/2):0;let Je=Math.max(c.scaleX??c.strength,c.scaleY??c.strength);if(ht>0){const P=typeof s=="number"?s*2:A.w,p=typeof u=="number"?u*2:A.h,L=1+at*c.dispersion;Je=Math.min(Je,Math.max(P,p)*.6/(ht*L))}const rt=v&&h!=null&&A.w>0&&A.h>0?Math.ceil(Je*ht*(1+at*c.dispersion)*.5+c.depth+28)+16:0,ae=r.useRef(rt);ae.current=rt,r.useLayoutEffect(()=>{const P=E.current;if(!P)return;const p=()=>{var Ye;const ne=P.getBoundingClientRect();if(!Oe.current&&typeof getComputedStyle<"u"){let ye=parseFloat(getComputedStyle(P).borderTopLeftRadius)||0;const Se=(Ye=T.current)==null?void 0:Ye.firstElementChild;!ye&&Se&&(ye=parseFloat(getComputedStyle(Se).borderTopLeftRadius)||0),Ae.current=ye}Le(ye=>ye.w===ne.width&&ye.h===ne.height?ye:{w:ne.width,h:ne.height})};p();const L=new ResizeObserver(p);return L.observe(P),window.addEventListener("resize",p),()=>{L.disconnect(),window.removeEventListener("resize",p)}},[]);const Fe=r.useCallback(()=>{const P=E.current;if(!P)return;let p=me.current.w,L=me.current.h;if(!(p>0&&L>0)){const oe=P.getBoundingClientRect();p=oe.width,L=oe.height}if(!(p>0&&L>0))return;const ne=K.current,Ye=Ge.current,ye=Ve.current;let Se=Math.max(Ye,ye);const pt=ne.dispersion,bt=Te.current?Me.current:p/2,xt=je.current?Ie.current:L/2,ut=Oe.current?b.current:Ae.current;let Dt=le.current*p,Xt=ue.current*L;_.current&&Y.current&&(Dt=Math.max(bt,Math.min(p-bt,Dt)),Xt=Math.max(xt,Math.min(L-xt,Xt)));const qe=Dt-bt,Ke=Xt-xt,nt=2*bt,it=2*xt;if(_.current){const oe=Math.sqrt((p*p+L*L)/2),Ee=1+at*pt,Rt=Math.max(nt,it)*.6;oe>0&&(Se=Math.min(Se,Rt/(oe*Ee)))}const Kt=W.current,Qe=Kt!==1&&!j.current?Kt:1,ft=j.current?Qe*H.current:Qe,vr=qe!==be.current||Ke!==ze.current,Vt=Se!==R.current;if(be.current=qe,ze.current=Ke,R.current=Se,vr||Vt||I.current){const oe=de.current,Ee=_.current,Rt=Math.sqrt((p*p+L*L)/2),wr=Se*Rt*(1+at*pt)*.5,Jt=Math.ceil(wr+Ze.current+28),gt=Ee&&Y.current?ae.current:0,yr=String(Ee?(qe+gt+oe)*ft:(qe+oe)/p),Sr=String(Ee?(Ke+gt+oe)*ft:(Ke+oe)/L),Er=String(Ee?Math.max(0,nt-2*oe)*ft:Math.max(0,nt-2*oe)/p),Mr=String(Ee?Math.max(0,it-2*oe)*ft:Math.max(0,it-2*oe)/L);for(const $e of Q.current)$e.setAttribute("x",yr),$e.setAttribute("y",Sr),$e.setAttribute("width",Er),$e.setAttribute("height",Mr);if(Vt){const $e=Ee?Se*Rt*ft:Se,Tr=pt>0?[$e*(1+at*.5*pt),$e,$e*(1-at*.5*pt)]:[$e],Qt=se.current;for(let Tt=0;Tt<Qt.length;Tt+=1)Qt[Tt].setAttribute("scale",String(Tr[Tt]??0))}const dt=Re.current;if(dt){Ee&&(dt.setAttribute("x","0"),dt.setAttribute("y","0"),Y.current?(dt.setAttribute("width",String((qe+gt+nt+Jt)*ft)),dt.setAttribute("height",String((Ke+gt+it+Jt)*ft))):(dt.setAttribute("width",String(p*ft)),dt.setAttribute("height",String(L*ft)))),ie.current+=1,dt.id=`lg-${J}-v${ie.current}`;const $e=_e.current?`url(#${dt.id})`:"";Y.current?(Y.current.style.filter!==$e&&(Y.current.style.filter=$e),Y.current.style.clipPath=`inset(${Math.max(0,Ke+gt)*Qe}px ${Math.max(0,p+gt-(qe+nt))*Qe}px ${Math.max(0,L+gt-(Ke+it))*Qe}px ${Math.max(0,qe+gt)*Qe}px round ${ut*Qe}px)`,T.current&&!te.current&&(T.current.style.filter="")):T.current&&T.current.style.filter!==$e&&(T.current.style.filter=$e)}}te.current&&(te.current.style.clipPath=`inset(${Math.max(0,Ke)*Qe}px ${Math.max(0,p-(qe+nt))*Qe}px ${Math.max(0,L-(Ke+it))*Qe}px ${Math.max(0,qe)*Qe}px round ${ut*Qe}px)`),ce.current&&!te.current&&(ce.current.style.clipPath=`inset(${Math.max(0,Ke)}px ${Math.max(0,p-(qe+nt))}px ${Math.max(0,L-(Ke+it))}px ${Math.max(0,qe)}px round ${ut}px)`);const It=(oe,Ee)=>{oe.style.transform=`translate(${qe}px, ${Ke}px)`,oe.style.width=`${nt}px`,oe.style.height=`${it}px`,oe.style.borderRadius=`${ut}px`,Ee!==void 0&&(oe.style.opacity=String(Ee))};if(he.current&&It(he.current,x.current),pe.current&&It(pe.current,fe.current),ee.current){ee.current.style.transform=`translate3d(${qe}px, ${Ke}px, 0)`,ee.current.style.width=`${nt}px`,ee.current.style.height=`${it}px`,ee.current.style.borderRadius=`${ut}px`;const{uri:oe,key:Ee}=ur(nt,it,ut);if(Ce.current!==Ee){const Rt=`url("${oe}")`;ee.current.style.maskImage=Rt,ee.current.style.setProperty("-webkit-mask-image",Rt),ee.current.style.maskSize="100% 100%",ee.current.style.setProperty("-webkit-mask-size","100% 100%"),Ce.current=Ee}}if(re.current){It(re.current);const oe=ct.current??"white";re.current.style.background=`color-mix(in srgb, ${oe} ${100*Pe.current}%, transparent)`,re.current.style.opacity="1";const Ee=we.current>0?`blur(${we.current}px)`:"none";re.current.style.backdropFilter=Ee,re.current.style.setProperty("-webkit-backdrop-filter",Ee)}if(g.current){const oe=Se>0?Ye/Se:0,Ee=Se>0?ye/Se:0;g.current.setAttribute("values",Nt(oe,Ee))}},[J]),et=r.useCallback(()=>{De.current||(De.current=!0,queueMicrotask(()=>{De.current=!1,Fe()}))},[Fe]),Xe=r.useCallback(()=>{be.current=NaN,R.current=NaN,Fe()},[Fe]);r.useEffect(()=>{const P=()=>{const L=window.innerWidth,ne=L>0?window.outerWidth/L:1;return ne>.2&&ne<12?Math.abs(ne-1)<.04?1:ne:1},p=()=>{const L=P();Math.abs(L-H.current)>.002&&(H.current=L,Xe())};return p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[Xe]);const tt=r.useCallback(()=>{var Se,pt,bt,xt;const P=K.current.mapSize;(!Ne.current||Ne.current.size!==P)&&((Se=Ne.current)==null||Se.gen.dispose(),Ne.current={gen:$t(P),size:P});const p=K.current,L=Te.current?Me.current:me.current.w/2,ne=je.current?Ie.current:me.current.h/2,Ye=Oe.current?b.current:Ae.current,ye=Ne.current.gen.generate({lensHalfWidth:L,lensHalfHeight:ne,borderRadius:Ye,depth:Ze.current,clipToShape:p.clipToShape,softEdge:p.softEdge,sheenAngle:p.sheenAngle,glow:p.glow,glowSpread:p.glowSpread,glowFalloff:p.glowFalloff,sheen:p.sheen,sheenWidth:p.sheenWidth,sheenFalloff:p.sheenFalloff,curvature:p.curvature,splay:p.splay,bend:p.bend,bendWidth:p.bendWidth});if(_e.current=ye,(pt=C.current)==null||pt.setAttribute("href",ye),p.frost>0||O.current&&p.brightness!==0){const ut=Lr(2*L,2*ne,Ye);ke.current=ut.uri,(bt=V.current)==null||bt.setAttribute("href",ut.uri)}(xt=Be.current)==null||xt.call(Be,ye),Xe()},[Xe]),lt=r.useRef(tt);lt.current=tt;const Mt=JSON.stringify([c.mapSize,c.clipToShape,c.softEdge,c.sheenAngle,c.glow,c.glowSpread,c.glowFalloff,c.sheen,c.sheenWidth,c.sheenFalloff,c.curvature,c.splay,c.bend,c.bendWidth,xe(s)?"mv":s??(A.w/2||c.lensW),xe(u)?"mv":u??(A.h/2||c.lensH),xe(f)?"mv":f??Ae.current,xe(N)?"mv":N??c.depth,$&&c.brightness!==0]);r.useLayoutEffect(()=>{const P=[],p=(L,ne,Ye,ye=()=>{I.current||et()})=>{if(L===void 0){ne.current=Ye;return}xe(L)?(ne.current=L.get(),P.push(L.on("change",Se=>{ne.current=Se,ye()}))):ne.current=L};return p(a,le,.5),p(i,ue,.5),p(s??c.lensW,Me,c.lensW),p(u??c.lensH,Ie,c.lensH),p(f??c.borderRadius,b,c.borderRadius),p(N??c.depth,Ze,c.depth),p(F??c.scaleX??c.strength,Ge,c.scaleX??c.strength),p(F??c.scaleY??c.strength,Ve,c.scaleY??c.strength),p(X,Pe,1),p(m,we,0),p(d,x,1),p(y,fe,0),p(G,de,.5),Fe(),()=>P.forEach(L=>L())},[a,i,s,u,f,N,F,X,m,d,y,G,c,et,Fe]);const mr=c.dispersion>0,jt=c.frost>0,br=c.glow>0||c.sheen>0;r.useLayoutEffect(()=>{const P=Re.current;Q.current=P?Array.from(P.querySelectorAll("[data-lens]")):[],se.current=P?Array.from(P.querySelectorAll("feDisplacementMap")):[],C.current&&_e.current&&C.current.setAttribute("href",_e.current),V.current&&ke.current&&V.current.setAttribute("href",ke.current),Xe()},[B,mr,jt,br,c.sheenDark,c.scaleX,c.scaleY,c.strength,c.brightness,$,v,D,h!=null,o!=null,Xe]),r.useLayoutEffect(()=>{B&&Xe()},[A.w,A.h,rt,Xe]),r.useLayoutEffect(()=>{B&&lt.current()},[B,Mt]),r.useEffect(()=>{const P=[];let p;const L=()=>{clearTimeout(p),p=setTimeout(()=>lt.current(),90)};for(const ne of[s,u,f,N])xe(ne)&&P.push(ne.on("change",L));return()=>{P.forEach(ne=>ne()),clearTimeout(p)}},[s,u,f,N]),r.useEffect(()=>()=>{var P,p;(P=Ne.current)==null||P.gen.dispose(),Ne.current=null,(p=Be.current)==null||p.call(Be,null)},[]),r.useEffect(()=>{if(!q||!B)return;let P=0;const p=()=>{P=requestAnimationFrame(p),Fe()};return P=requestAnimationFrame(p),()=>cancelAnimationFrame(P)},[q,B,Fe]);const xr=z!==1&&!D?z:1,Rr=jt&&B?v?`${c.frost*xr}`:`${c.frost/A.w} ${c.frost/A.h}`:void 0,st=z!==1&&!D?z:1,Ct=st>1&&o==null&&h==null&&B,Ht=o==null&&h==null&&!Ct&&s===void 0,zt=(P,p,L)=>n.jsx("div",{ref:P,style:{...L,position:"absolute",top:0,left:0,width:A.w*st,height:A.h*st,transform:`scale(${1/st})`,transformOrigin:"top left"},children:n.jsx("div",{style:{transform:`scale(${st})`,transformOrigin:"top left",width:A.w,height:A.h},children:p})}),Yt=c.brightness!==0&&!$?n.jsx("div",{ref:ce,style:{position:"absolute",inset:0,pointerEvents:"none",background:c.brightness>0?"white":"black",opacity:Math.abs(c.brightness)}}):null,qt=(P,p,L)=>p||L?n.jsx("div",{ref:P,style:{position:"absolute",top:0,left:0,pointerEvents:"none",willChange:"transform",boxSizing:"border-box",boxShadow:[p,L?`inset ${L}`:null].filter(Boolean).join(", ")}}):null;return n.jsxs("div",{ref:E,"data-liquid-glass":"",className:S,style:{contain:"layout",position:"relative",overflow:"visible",...Ht?{width:"fit-content"}:null,...Ct?{minHeight:A.h}:null,...M},...w,children:[Ct?zt(T,t,{willChange:"filter"}):o==null&&h==null?n.jsx("div",{ref:T,style:Ht?{willChange:"filter"}:{willChange:"filter",position:"relative",height:B?A.h:void 0,overflow:"hidden",contain:"paint"},children:t}):o==null&&v?n.jsx("div",{ref:T,style:{position:"absolute",inset:0,isolation:"isolate"},children:t}):n.jsx("div",{ref:o!=null?void 0:T,style:o!=null?void 0:{willChange:"filter"},children:t}),h!=null&&(v?n.jsx("div",{ref:Y,style:{position:"absolute",inset:-rt,pointerEvents:"none",willChange:"filter, clip-path",background:He},children:n.jsx("div",{style:{position:"absolute",inset:rt},children:h})}):st>1?zt(Y,h,{pointerEvents:"none",willChange:"filter, clip-path",background:He}):n.jsx("div",{ref:Y,style:{position:"absolute",inset:0,pointerEvents:"none",willChange:"filter, clip-path",background:He},children:h})),o!=null&&n.jsxs("div",{ref:te,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[n.jsx("div",{ref:T,style:{willChange:"filter"},children:o}),Yt]}),n.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[n.jsx("svg",{viewBox:`0 0 ${A.w} ${A.h}`,width:"100%",height:"100%",style:{display:"block"},children:n.jsx("defs",{children:n.jsx("filter",{ref:Re,id:`lg-${J}-v0`,filterUnits:v?"userSpaceOnUse":"objectBoundingBox",primitiveUnits:v?"userSpaceOnUse":"objectBoundingBox",colorInterpolationFilters:"sRGB",x:0,y:0,width:v?A.w*st:1,height:v?A.h*st:1,children:B&&n.jsx(qr,{lens:{...c,scaleX:F!==void 0?We(F):c.scaleX??c.strength,scaleY:F!==void 0?We(F):c.scaleY??c.strength},mapHref:lr,feImageRef:C,mapMatrixRef:g,blurStdDeviation:Rr,specularFromRawMap:D,brightnessInFilter:$,filterW:v?A.w*st:void 0,filterH:v?A.h*st:void 0,clipShapeRef:V})})})}),o==null&&Yt,k!==void 0&&n.jsx("div",{ref:re,style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"hidden",willChange:"transform"}})]}),jt&&t==null&&h==null&&o==null&&n.jsx("div",{ref:ee,style:{position:"absolute",top:0,left:0,pointerEvents:"none",willChange:"backdrop-filter, transform",backdropFilter:`blur(${c.frost}px)`,WebkitBackdropFilter:`blur(${c.frost}px)`}}),qt(he,c.edgeShadow,c.edgeInsetShadow),qt(pe,c.restEdgeShadow,c.restEdgeInsetShadow)]})},sr=t=>r.useMemo(()=>t==null?void 0:xe(t)?ot([t],()=>t.get()/2):t/2,[t]),mt=t=>{const{children:e,width:a,height:i,size:s,radius:u,center:f,optics:h,refract:l,behind:o,src:k,draw:X,lenses:m,videoRef:d,paused:y,poster:G,loop:N,muted:F,autoPlay:z,crossOrigin:$,maxDpr:v,unstable_lens:q,...U}=t,S={...U,...q??{}},M=f==null?void 0:f.x,w=f==null?void 0:f.y,[D,j]=Array.isArray(s)?s:s!=null?[s,s]:[void 0,void 0],O=sr(a??D),_=sr(i??j);if(k!=null||X!=null)return n.jsx(Or,{src:k,draw:X,lens:h,lenses:m,videoRef:d,paused:y,poster:G,loop:N,muted:F,autoPlay:z,crossOrigin:$,maxDpr:v,lensW:O,lensH:_,borderRadius:u,x:M,y:w,className:t.className,style:t.style,children:e});const{overlay:I,tintColor:W,tintOpacity:c,tintBlur:K,shadowOpacity:J,restShadowOpacity:E,edgeBias:T,brightnessInFilter:Y,depth:te,scale:ce,filterResolution:re,pixelUnits:ee,live:he,onLensMapChange:pe,...Re}=S,C=xe(a)||xe(i)||xe(u)||xe(D)||xe(j)||xe(M)||xe(w);return e!=null&&l==null&&k==null&&X==null&&m==null&&I==null&&!ee&&W==null&&c==null&&K==null&&J==null&&E==null&&T==null&&!Y&&re==null&&!he&&te==null&&ce==null&&pe==null&&M==null&&w==null&&!C?n.jsx(zr,{...Re,optics:h,radius:u,width:a??D,height:i??j,children:e}):n.jsx(Kr,{...S,lensW:O,lensH:_,borderRadius:u,x:M,y:w,lens:h,refractionTarget:l,refractionBackground:o,children:e})},Vr=176,Jr=13.6,kt=.34,Qr=.75,Zr=84,nr=.033,ir=.008,ar=.03,es=(t,e,a,i)=>{r.useEffect(()=>{let s=0,u=0,f=0,h=0,l=t.get(),o=!1;const k=G=>{const N=Math.pow(G,Qr)/Zr,F=N<kt?N:kt,z=a.current,$=F>z?F:z;return $<kt?$:kt},X=G=>Math.abs(u)<6e-4&&Math.abs(f)<.006&&G<.006&&a.current===0,m=G=>{const N=(G-h)/1e3,F=N<nr?N:nr;h=G;const z=t.get(),$=N<ir?ir:N>ar?ar:N,v=Math.abs((z-l)/$);l=z;const q=k(v),U=Vr*(q-u)-Jr*f;if(f+=U*F,u+=f*F,e.set(u),X(v)){o=!1,e.set(0);return}s=requestAnimationFrame(m)},d=()=>{o||(o=!0,h=performance.now(),l=t.get(),s=requestAnimationFrame(m))};i.current=d;const y=t.on("change",d);return()=>{y(),cancelAnimationFrame(s),i.current=()=>{}}},[t,e,a,i])},Lt=(t,e,a)=>{const i=t<a?t/a:1;return e*i*(3+i*(i-3))},St=r.forwardRef(({x:t,scaleX:e,scaleY:a,style:i,children:s,...u},f)=>{const h=r.useRef(null);return r.useEffect(()=>{const l=h.current;if(!l)return;const o=[t,e,a].filter(m=>m!=null),k=()=>{let m="";if(t&&(m=`translateX(${t.get()}px)`),e||a){const d=e?e.get():1,y=a?a.get():1;m+=`${m?" ":""}scale(${d}, ${y})`}l.style.transform=m};k();const X=o.map(m=>m.on("change",k));return()=>X.forEach(m=>m())},[t,e,a]),n.jsx("div",{ref:l=>{h.current=l,typeof f=="function"?f(l):f&&(f.current=l)},style:i,...u,children:s})});St.displayName="GlassDiv";const ts=r.forwardRef(function({variant:e="primary",size:a="md",glassProps:i,contentClassName:s,className:u="",type:f="button",children:h,...l},o){return n.jsxs("span",{className:`matui-glass-button-shell matui-glass-button--${e}`,children:[n.jsx(mt,{...i,"aria-hidden":!0,style:{...i==null?void 0:i.style,position:"absolute",inset:0,width:"100%",height:"100%",borderRadius:"inherit",pointerEvents:"none"},children:n.jsx("span",{})}),n.jsx("button",{...l,ref:o,type:f,className:`matui-glass-button matui-glass-button--${a} ${u}`,children:n.jsx("span",{className:s,children:h})})]})}),rs=r.forwardRef(function({elevation:e="raised",glassProps:a,className:i="",children:s,...u},f){return n.jsx("div",{...u,ref:f,className:`matui-glass-card matui-glass-card--${e} ${i}`,children:n.jsx(mt,{...a,style:{width:"100%",padding:28,borderRadius:"inherit",...a==null?void 0:a.style},children:s})})});function ss({label:t,options:e,value:a,defaultValue:i,onValueChange:s,name:u,disabled:f,className:h=""}){var m;const l=r.useId(),[o,k]=r.useState(i??((m=e.find(d=>!d.disabled))==null?void 0:m.value)??""),X=a??o;return n.jsxs("fieldset",{disabled:f,className:`matui-glass-segmented ${h}`,children:[n.jsx("legend",{className:"matui-glass-sr-only",children:t}),e.map(d=>n.jsxs("div",{className:"matui-glass-segment",children:[X===d.value&&n.jsx(mt,{"aria-hidden":!0,className:"matui-glass-segment-lens",style:{position:"absolute",inset:0,borderRadius:18,width:"100%",height:"100%",background:"#ffffff44",pointerEvents:"none"},children:n.jsx("span",{})}),n.jsxs("label",{children:[n.jsx("input",{type:"radio",name:u??l,value:d.value,checked:X===d.value,disabled:d.disabled,onChange:()=>{a===void 0&&k(d.value),s==null||s(d.value)}}),n.jsx("span",{children:d.label})]})]},d.value))]})}const fr="(prefers-reduced-motion: reduce)",ns=t=>{const e=window.matchMedia(fr);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},is=()=>window.matchMedia(fr).matches,as=()=>!1;function dr(){return r.useSyncExternalStore(ns,is,as)}function hr(){const t=dr();return r.useCallback((...[e,a,i])=>Dr(e,a,t?{...i,duration:0}:i),[t])}function pr(...[t,e,a,i]){const s=dr(),u=r.useMemo(()=>ge(0),[]),f=r.useRef(0),h=r.useRef(()=>{});es(s?u:t,e,s?f:a,s?h:i),r.useEffect(()=>{s&&(e.set(0),i.current=()=>{})},[s,e,i])}const gr=Et(.34,1.36,.42,1),os=Et(.36,0,.18,1),vt={ease:gr,duration:.52},yt={ease:gr,duration:.26},wt={ease:os,duration:.46},cs={mapSize:256,depth:.2,dispersion:.65,strength:.19,clipToShape:!0,softEdge:!0,curvature:.3,splay:.6,bend:.1,bendWidth:.06,frost:0,brightness:.05,specular:1.2,sheenAngle:45,sheenDark:!1,glow:.05,glowSpread:.5,glowFalloff:1.5,sheen:.45,sheenWidth:2,sheenFalloff:1.5,edgeShadow:"0 2px 6px rgba(0, 0, 0, 0.16)",edgeInsetShadow:"0 -4px 10px rgba(0, 0, 0, 0.12)",restEdgeShadow:"0 1px 3px rgba(0, 0, 0, 0.24), 0 4px 10px rgba(0, 0, 0, 0.14)"},ls={brightness:.12,glow:.4,sheen:.5},us={brightness:-.02,sheenAngle:30,specular:1.5,glow:.4,glowSpread:.5,glowFalloff:2,sheen:1,sheenWidth:1.5,sheenFalloff:1},or="color-mix(in srgb, var(--glass-track), var(--glass-active) calc(var(--switch-progress, 0) * 100%))",fs=({checked:t,defaultChecked:e=!1,onCheckedChange:a,disabled:i,name:s,value:u,ariaLabel:f,width:h=74,height:l=28,lens:o,tintBlur:k,rubberOvershoot:X=.15,rubberDampening:m=10,filterResolution:d=2,forceExpanded:y=!1,onLensMapChange:G,scheme:N="light",trackColor:F,activeColor:z,surface:$})=>{const v=hr(),[q,U]=r.useState(e),S=t??q,M=N==="dark",w=Math.round(.6*h),D=l-6,j=h-w-6,O=h*X,_=O*m,I=l/2,W=D/2,c=w/2,K=D/2,J=Math.round(.75*l),E=Math.ceil(.5*Math.max(c,K)+O)+2,T=h+2*E,Y=l+2*E,te=r.useRef(j),ce=r.useRef(w),re=r.useRef(T),ee=r.useRef(E),he=r.useRef(c),pe=r.useRef(K),Re=r.useRef(W),C=r.useRef(k??0);r.useLayoutEffect(()=>{te.current=j,ce.current=w,re.current=T,ee.current=E,he.current=c,pe.current=K,Re.current=W,C.current=k??0});const V=r.useRef(S),g=r.useMemo(()=>{const x=ge(V.current?te.current:0),fe=ot([x],()=>(ee.current+3+ce.current/2+x.get())/re.current),de=ge(he.current),be=ge(pe.current),ze=ge(Re.current),R=ge(1),H=ge(.85),ie=ge(.525),Ce=ge(C.current),De=ge(0),_e=ot([De],()=>1-De.get()),ke=ge(0),Ne=ot([de,ke],()=>de.get()*(1-.2*ke.get())*2),ct=ot([be,ke],()=>be.get()*(1+.4*ke.get())*2),Be=ot([R],()=>.5*R.get());return{thumbX:x,lensX:fe,halfW:de,halfH:be,radius:ze,tintOpacity:R,trackScaleX:H,trackScaleY:ie,blur:Ce,shadowOpacity:De,restShadowOpacity:_e,stretch:ke,lensW:Ne,lensH:ct,edgeBias:Be}},[]),Q=r.useRef(0),se=r.useRef(()=>{});pr(g.thumbX,g.stretch,Q,se);const A=x=>{v(g.halfW,1.5*he.current,x),v(g.halfH,1.5*pe.current,x),v(g.radius,1.5*Re.current,x),v(g.tintOpacity,0,x),v(g.blur,0,x),v(g.trackScaleX,.95,x),v(g.trackScaleY,.975,x),v(g.shadowOpacity,1,x)},Le=x=>{v(g.halfW,he.current,x),v(g.halfH,pe.current,x),v(g.radius,Re.current,x),v(g.tintOpacity,1,x),v(g.blur,C.current,x),v(g.trackScaleX,.85,x),v(g.trackScaleY,.525,x),v(g.shadowOpacity,0,x)},me=r.useRef(!1);r.useEffect(()=>{y!==me.current&&(me.current=y,y?(A(yt),Q.current=.175,se.current()):(Le(wt),Q.current=0))},[y]);const B=r.useRef("idle"),Z=r.useRef(void 0),ve=r.useRef(void 0),Ue=r.useRef(!0),[He,le]=r.useState(!1),ue=r.useRef(!1),Me=r.useRef(null),Ie=r.useRef(null),b=r.useRef(null),Te=r.useRef(0),je=r.useRef(0),Oe=r.useRef(!1),Ae=r.useRef(null);r.useEffect(()=>{Ue.current=!0;const x=Ie.current;return()=>{if(Ue.current=!1,clearTimeout(Z.current),clearTimeout(ve.current),b.current!==null&&x){try{x.releasePointerCapture(b.current)}catch{}b.current=null}}},[]),r.useEffect(()=>{He||B.current==="tap"||(Ae.current=v(g.thumbX,S?j:0,vt))},[S,He,g.thumbX,j,v]),r.useLayoutEffect(()=>{const x=fe=>{var be;const de=te.current;(be=Me.current)==null||be.style.setProperty("--switch-progress",String(de>0?Math.max(0,Math.min(1,fe/de)):0))};return x(g.thumbX.get()),g.thumbX.on("change",x)},[g.thumbX]);const Ze=r.useMemo(()=>({...cs,...M?ls:us,...o,sheenDark:!M}),[M,o]),Ge=x=>{ue.current||i||(t===void 0&&U(x),a==null||a(x),B.current==="idle"&&(B.current="tap",A(yt),clearTimeout(ve.current),ve.current=setTimeout(()=>{Le(wt)},290),Ae.current=v(g.thumbX,x?j:0,{...vt,onComplete:()=>{Ue.current&&B.current==="tap"&&(B.current="idle")}})))},Ve=$??(M?"#1f1f24":"#ffffff"),Pe=F??(M?"#2a2828":"#e1dfdf"),we=z??"#0a84ff";return n.jsxs("label",{ref:Me,className:"matui-glass-control",style:{flexShrink:0,width:h,height:l,overflow:"visible",cursor:i?"not-allowed":"pointer",opacity:i?.4:void 0,borderRadius:999,display:"block",position:"relative","--glass-track":Pe,"--glass-active":we},children:[n.jsx("input",{type:"checkbox",role:"switch","aria-checked":S,checked:S??!1,onChange:x=>Ge(x.target.checked),onClick:x=>{ue.current&&x.preventDefault()},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Ge(!S))},disabled:i,name:s,value:u,"aria-label":f,style:{whiteSpace:"nowrap",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",pointerEvents:"none",border:0,width:1,height:1,margin:-1,padding:0,position:"absolute",overflow:"hidden"}}),n.jsx(mt,{optics:Ze,center:{x:g.lensX,y:.5},size:[g.lensW,g.lensH],radius:g.radius,unstable_lens:{tintColor:"white",tintOpacity:g.tintOpacity,tintBlur:g.blur,shadowOpacity:g.shadowOpacity,restShadowOpacity:g.restShadowOpacity,edgeBias:g.edgeBias},filterResolution:d,onLensMapChange:G,behind:Ve,style:{width:T,height:Y,overflow:"visible",margin:-E},refract:n.jsx("div",{style:{padding:E,height:l,display:"flex",alignItems:"center",boxSizing:"content-box"},children:n.jsx(St,{scaleX:g.trackScaleX,scaleY:g.trackScaleY,style:{width:h,height:J,borderRadius:J/2,background:or}})}),children:n.jsx("div",{style:{padding:E},children:n.jsx("div",{"aria-hidden":!0,style:{width:h,height:l,borderRadius:I,background:or,display:"block",position:"relative",overflow:"visible"},children:n.jsx(St,{ref:Ie,x:g.thumbX,style:{position:"absolute",willChange:"transform",userSelect:"none",WebkitUserSelect:"none",width:w,height:D,top:3,left:3,touchAction:"none"},onPointerDown:x=>{b.current!==null||i||(b.current=x.pointerId,x.currentTarget.setPointerCapture(x.pointerId),Te.current=x.clientX,je.current=g.thumbX.get(),Oe.current=!1,le(!0),ue.current=!0,clearTimeout(Z.current),clearTimeout(ve.current),B.current="pending",Z.current=setTimeout(()=>{var fe;B.current==="pending"&&(B.current="hold",(fe=Ae.current)==null||fe.stop(),A(yt),Q.current=.175,se.current())},170))},onPointerMove:x=>{var be;if(x.pointerId!==b.current)return;const fe=x.clientX-Te.current;if(!Oe.current){if(Math.abs(fe)<3)return;Oe.current=!0,(be=Ae.current)==null||be.stop(),je.current=g.thumbX.get(),Te.current=x.clientX,clearTimeout(Z.current),Q.current=0,B.current!=="hold"&&(B.current="hold",A(yt))}let de=je.current+(x.clientX-Te.current);de<0?de=-Lt(-de,O,_):de>j&&(de=j+Lt(de-j,O,_)),g.thumbX.set(de)},onPointerUp:x=>{if(x.pointerId===b.current)if(b.current=null,clearTimeout(Z.current),Oe.current){le(!1),B.current="idle",Le(wt);const fe=Math.max(0,Math.min(j,g.thumbX.get()))>j/2;Ae.current=v(g.thumbX,fe?j:0,vt),fe!==S&&(a==null||a(fe)),requestAnimationFrame(()=>{ue.current=!1})}else if(B.current==="pending"||B.current==="tap"){B.current="tap",ue.current=!1,le(!1),A(yt),clearTimeout(ve.current),ve.current=setTimeout(()=>{Le(wt)},290);const fe=S?0:j;Ae.current=v(g.thumbX,fe,{...vt,onComplete:()=>{Ue.current&&B.current==="tap"&&(B.current="idle")}})}else B.current==="hold"?(B.current="idle",le(!1),Q.current=0,Le(wt),Ae.current=v(g.thumbX,S?j:0,vt),requestAnimationFrame(()=>{ue.current=!1})):(le(!1),ue.current=!1)},onPointerCancel:x=>{x.pointerId===b.current&&(b.current=null,clearTimeout(Z.current),Q.current=0,le(!1),B.current="idle",Le(wt),Ae.current=v(g.thumbX,S?j:0,vt),requestAnimationFrame(()=>{ue.current=!1}))},onDragStart:x=>x.preventDefault()})})})})]})},cr={ease:Et(.34,1.36,.42,1),duration:.27},Pt={ease:Et(.36,0,.18,1),duration:.46},ds={mapSize:256,depth:.2,dispersion:.5,scaleX:.06,scaleY:.06,clipToShape:!0,softEdge:!0,curvature:.55,splay:.5,bend:.1,bendWidth:.05,frost:0,brightness:.06,specular:1.5,sheenAngle:45,sheenDark:!1,glow:.4,glowSpread:.5,glowFalloff:1.5,sheen:0,sheenWidth:3,sheenFalloff:1.5,edgeShadow:"0 2px 6px rgba(0, 0, 0, 0.16)",edgeInsetShadow:"0 -4px 10px rgba(0, 0, 0, 0.12)"},hs={restEdgeShadow:"0 1.333px 5.333px rgba(0, 0, 0, 0.5)",scaleX:.133,scaleY:.135,brightness:.12,sheenAngle:45,glowFalloff:1.5,sheen:.5,sheenWidth:1,sheenFalloff:1.5},ps={restEdgeShadow:"0 1.333px 5.333px rgba(46, 15, 15, 0.12)",scaleX:.1,scaleY:.1,brightness:-.02,sheenAngle:30,glowFalloff:2,sheen:1,sheenWidth:1,sheenFalloff:1},gs={scaleY:.25},ms=()=>{const[t,e]=r.useState(!1);return r.useEffect(()=>{e(typeof navigator<"u"&&/^((?!chrome|chromium|android).)*safari/i.test(navigator.userAgent))},[]),t},bs=({value:t,defaultValue:e=50,onValueChange:a,min:i=0,max:s=100,step:u=1,disabled:f,width:h=240,thumbHeight:l=22,thumbWidth:o,height:k=6,rubberOvershoot:X=.05,rubberDampening:m=30,refractionTrackHeight:d,lens:y,tintBlur:G,filterResolution:N=2,name:F,ariaLabel:z,forceExpanded:$=!1,onLensMapChange:v,scheme:q="light",trackColor:U,activeColor:S,surface:M})=>{const w=hr(),D=q==="dark",j=ms(),O=t!==void 0,[_,I]=r.useState(e),W=O?t:_,c=r.useCallback(R=>{const H=u>0?Math.round((R-i)/u)*u+i:R,ie=Math.max(i,Math.min(s,H));O||I(ie),a==null||a(ie)},[i,s,u,O,a]),K=o??Math.round(2*l),J=h-K,E=K/2,T=l/2,Y=l/2,te=k/2,ce=h*X,re=ce*m,ee=d??Math.round(.75*l),he=Math.ceil(.5*Math.max(E,T)+ce)+2,pe=h+2*he,Re=l+2*he,C=r.useRef(J),V=r.useRef(K),g=r.useRef(pe),Q=r.useRef(he),se=r.useRef(E),A=r.useRef(T),Le=r.useRef(Y),me=r.useRef(!1),B=r.useRef(0),Z=r.useRef(0),ve=r.useRef(ce),Ue=r.useRef(re),He=r.useRef(G??0);r.useLayoutEffect(()=>{C.current=J,V.current=K,g.current=pe,Q.current=he,se.current=E,A.current=T,Le.current=Y,ve.current=ce,Ue.current=re,He.current=G??0});const le=r.useCallback(R=>s>i?(R-i)/(s-i)*J:0,[i,s,J]),ue=r.useCallback(R=>{const H=Math.max(0,Math.min(J,R)),ie=J>0?i+H/J*(s-i):i;return Math.max(i,Math.min(s,u>0?Math.round((ie-i)/u)*u+i:ie))},[i,s,J,u]),Me=r.useRef(le),Ie=r.useRef(W),b=r.useMemo(()=>{const R=ge(Me.current(Ie.current)),H=ot([R],()=>(Q.current+V.current/2+R.get())/g.current),ie=ge(se.current),Ce=ge(A.current),De=ge(Le.current),_e=ge(1),ke=ge(.85),Ne=ge(.525),ct=ge(He.current),Be=ge(0),ht=ot([Be],()=>1-Be.get()),Je=ge(0),rt=ot([ie,Je],()=>ie.get()*(1-.2*Je.get())*2),ae=ot([Ce,Je],()=>Ce.get()*(1+.4*Je.get())*2);return{thumbX:R,lensX:H,halfW:ie,halfH:Ce,radius:De,tintOpacity:_e,trackScaleX:ke,trackScaleY:Ne,blur:ct,shadowOpacity:Be,restShadowOpacity:ht,stretch:Je,lensW:rt,lensH:ae}},[]);r.useEffect(()=>{me.current||(b.halfW.set(E),b.halfH.set(T),b.radius.set(Y))},[E,T,Y,b]);const Te=r.useRef(0),je=r.useRef(()=>{});pr(b.thumbX,b.stretch,Te,je);const Oe=R=>{w(b.halfW,1.5*se.current,R),w(b.halfH,1.5*A.current,R),w(b.radius,1.5*Le.current,R),w(b.tintOpacity,0,R),w(b.blur,0,R),w(b.trackScaleX,.95,R),w(b.trackScaleY,.975,R),w(b.shadowOpacity,1,R)},Ae=R=>{w(b.halfW,se.current,R),w(b.halfH,A.current,R),w(b.radius,Le.current,R),w(b.tintOpacity,1,R),w(b.blur,He.current,R),w(b.trackScaleX,.85,R),w(b.trackScaleY,.525,R),w(b.shadowOpacity,0,R)},Ze=r.useRef(!1);r.useEffect(()=>{$!==Ze.current&&(Ze.current=$,$?(Oe(cr),Te.current=.175,je.current()):(Ae(Pt),Te.current=0))},[$]);const Ge=r.useRef(null),Ve=r.useRef(null),Pe=r.useRef(null),we=r.useRef(null);r.useEffect(()=>()=>{if(we.current!==null&&Ve.current){try{Ve.current.releasePointerCapture(we.current)}catch{}we.current=null}},[]),r.useEffect(()=>{me.current||b.thumbX.set(le(W))},[W,le,b.thumbX]),r.useEffect(()=>{const R=H=>{const ie=Ge.current;if(!ie)return;const Ce=V.current/2+H,De=C.current>0?H/C.current:0;ie.style.setProperty("--slider-fill",`${Ce}px`),ie.style.setProperty("--slider-progress",String(Math.max(0,Math.min(1,De))))};return R(b.thumbX.get()),b.thumbX.on("change",R)},[b.thumbX]);const x=r.useMemo(()=>({...ds,...D?hs:ps,...j?gs:null,...y,sheenDark:!D}),[D,j,y]),fe=M??(D?"#1f1f24":"#ffffff"),de=U??(D?"#2a2828":"#e1dfdf"),be=S??"#0a84ff",ze=R=>{if(R.pointerId!==we.current)return;we.current=null,me.current=!1,Te.current=0;const H=Math.max(0,Math.min(C.current,b.thumbX.get()));w(b.thumbX,H,Pt),Ae(Pt)};return n.jsx("div",{ref:Ge,className:"matui-glass-control",style:{flexShrink:0,width:h,height:l,overflow:"visible",borderRadius:999,position:"relative",opacity:f?.4:void 0,cursor:f?"not-allowed":void 0,"--glass-track":de,"--glass-active":be},children:n.jsx(mt,{optics:x,center:{x:b.lensX,y:.5},size:[b.lensW,b.lensH],radius:b.radius,unstable_lens:{tintColor:"white",tintOpacity:b.tintOpacity,tintBlur:b.blur,shadowOpacity:b.shadowOpacity,restShadowOpacity:b.restShadowOpacity},filterResolution:N,onLensMapChange:v,behind:fe,style:{width:pe,height:Re,overflow:"visible",margin:-he},refract:n.jsx("div",{style:{padding:he,height:l,display:"flex",alignItems:"center",boxSizing:"content-box"},children:n.jsxs(St,{scaleX:b.trackScaleX,scaleY:b.trackScaleY,style:{position:"relative",width:h,height:ee,borderRadius:ee/2,overflow:"hidden"},children:[n.jsx("div",{style:{position:"absolute",inset:0,background:"var(--glass-track)"}}),n.jsx("div",{style:{position:"absolute",inset:0,background:"var(--glass-active)",borderRadius:"inherit",transform:"translateX(calc((var(--slider-progress, 0) - 1) * 100%))"}})]})}),children:n.jsxs("div",{style:{padding:he},children:[n.jsx("input",{ref:Pe,type:"range",min:i,max:s,step:u,value:W,disabled:f,name:F,"aria-label":z,onChange:R=>c(Number(R.target.value)),style:{whiteSpace:"nowrap",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",pointerEvents:"none",border:0,width:1,height:1,margin:-1,padding:0,position:"absolute",overflow:"hidden"}}),n.jsxs("div",{ref:Ve,"aria-hidden":!0,style:{width:h,height:l,cursor:f?"not-allowed":"pointer",touchAction:"none",userSelect:"none",WebkitUserSelect:"none",alignItems:"center",display:"flex",position:"relative",overflow:"visible"},onPointerDown:R=>{var De,_e;if(f||we.current!==null)return;we.current=R.pointerId,R.currentTarget.setPointerCapture(R.pointerId),me.current=!0,(De=Pe.current)==null||De.focus({preventScroll:!0});const H=(_e=Ve.current)==null?void 0:_e.getBoundingClientRect(),ie=H?R.clientX-H.left-V.current/2:0,Ce=Math.max(0,Math.min(C.current,ie));b.thumbX.set(Ce),c(ue(Ce)),B.current=R.clientX,Z.current=Ce,Oe(cr),Te.current=.175,je.current()},onPointerMove:R=>{if(R.pointerId!==we.current)return;let H=Z.current+(R.clientX-B.current);H<0?H=-Lt(-H,ve.current,Ue.current):H>C.current&&(H=C.current+Lt(H-C.current,ve.current,Ue.current)),b.thumbX.set(H),c(ue(Math.max(0,Math.min(C.current,H))))},onPointerUp:ze,onPointerCancel:ze,onDragStart:R=>R.preventDefault(),children:[n.jsxs("div",{style:{width:"100%",position:"relative",overflow:"hidden",height:k,borderRadius:te},children:[n.jsx("div",{style:{position:"absolute",inset:0,background:"var(--glass-track)",borderRadius:"inherit"}}),n.jsx("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:"var(--slider-fill)",background:"var(--glass-active)",borderRadius:te}})]}),n.jsx(St,{x:b.thumbX,style:{willChange:"transform",position:"absolute",top:0,left:0,width:K,height:l}})]})]})})})},xs="-apple-system, 'SF Pro Text', ui-sans-serif, system-ui, sans-serif",Rs={mapSize:256,clipToShape:!0,softEdge:!0,depth:1,curvature:.5,dispersion:.6,strength:.17,bend:.7,bendWidth:.12,frost:3,brightness:.22,specular:1.3,sheenAngle:50,glow:.32,glowSpread:1,glowFalloff:1,sheen:1.3,sheenWidth:3},vs="#1c1c1e",ws="rgba(0,0,0,0.5)",ys="rgba(0,0,0,0.74)",Ss="radial-gradient(120% 120% at 12% 18%, #ff9d4d 0%, transparent 46%),radial-gradient(120% 120% at 82% 14%, #4dc3ff 0%, transparent 44%),radial-gradient(130% 130% at 78% 88%, #ff5d8f 0%, transparent 50%),radial-gradient(140% 140% at 22% 86%, #7a5cff 0%, transparent 52%),linear-gradient(135deg, #b24bd8, #f0793b)",Es=({bg:t})=>n.jsx("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,background:t,backgroundSize:"cover",backgroundPosition:"center"}}),Ms=420,Ts=48,Ft=84,Ut=20,As=()=>{const t=r.useRef(null),[e,a]=r.useState({w:0,h:0});return r.useLayoutEffect(()=>{const i=t.current;if(!i)return;const s=()=>a({w:i.clientWidth,h:i.clientHeight});s();const u=new ResizeObserver(s);return u.observe(i),()=>u.disconnect()},[]),[t,e]},_s=({title:t="Priya Raman",time:e="now",body:a="Just landed — grabbing a cab. Save me a seat and order the usual?",avatar:i="PR",wallpaper:s=Ss,lens:u})=>{const[f,{w:h,h:l}]=As(),o=Math.round(Math.min(h-Ts,Ms)),k=h>0&&l>0&&o>0,X=Math.round((h-o)/2),m=Math.round((l-Ft)/2);return n.jsxs("div",{ref:f,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",fontFamily:xs,userSelect:"none"},children:[n.jsx(Es,{bg:s}),k&&n.jsxs(n.Fragment,{children:[n.jsx(mt,{optics:{...Rs,...u},brightnessInFilter:!0,width:o,height:Ft,radius:Ut,refract:n.jsx("div",{"aria-hidden":!0,style:{position:"absolute",left:-X,top:-m,width:h,height:l,background:s,backgroundSize:"cover",backgroundPosition:"center"}}),behind:"#c8569f",style:{position:"absolute",left:X,top:m,width:o,height:Ft,borderRadius:Ut}}),n.jsxs("div",{style:{position:"absolute",left:X,top:m,width:o,height:Ft,borderRadius:Ut,background:"linear-gradient(180deg, rgba(255,255,255,0.62) 0%, rgba(255,255,255,0.16) 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.95), inset 0 0 0 1px rgba(255,255,255,0.5), inset 0 0 24px rgba(255,255,255,0.55), 0 0 0 0.5px rgba(0,0,0,0.18), 0 14px 36px rgba(0,0,0,0.22), 0 2px 5px rgba(0,0,0,0.14)",display:"flex",alignItems:"center",gap:14,padding:"0 18px",boxSizing:"border-box",color:vs},children:[n.jsx("div",{"aria-hidden":!0,style:{flexShrink:0,width:40,height:40,borderRadius:"50%",display:"grid",placeItems:"center",background:"linear-gradient(160deg, #2e9bff 0%, #0a6cff 100%)",color:"#fff",fontSize:14,fontWeight:600,letterSpacing:.3,boxShadow:"inset 0 1px 1px rgba(255,255,255,0.4)"},children:i}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[n.jsx("span",{style:{fontSize:14.5,fontWeight:600},children:t}),n.jsx("span",{style:{marginLeft:"auto",fontSize:12,color:ws,whiteSpace:"nowrap"},children:e})]}),n.jsx("div",{style:{marginTop:3,fontSize:13.5,lineHeight:1.35,color:ys,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:a})]})]})]})]})},ks="0.3.0";exports.Glass=mt;exports.GlassButton=ts;exports.GlassCard=rs;exports.GlassNotification=_s;exports.GlassSegmentedControl=ss;exports.GlassSlider=bs;exports.GlassSwitch=fs;exports.LiquidGlass=mt;exports.VERSION=ks;