@aberhamm/liquid-glass-react 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +38 -0
- package/README.md +627 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +1191 -0
- package/dist/index.d.ts +1191 -0
- package/dist/index.mjs +1314 -0
- package/dist/liquid-glass-react.css +1 -0
- package/dist/native/index.native.d.ts +19 -0
- package/dist/native/index.native.js +19 -0
- package/dist/native/liquid-glass.native.d.ts +65 -0
- package/dist/native/liquid-glass.native.js +200 -0
- package/dist/native/tokens.d.ts +245 -0
- package/dist/native/tokens.js +254 -0
- package/dist/native/types.d.ts +464 -0
- package/dist/native/types.js +9 -0
- package/package.json +122 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
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;
|