@zakisheriff/liquid-glass 0.2.7 → 0.3.1

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.mjs CHANGED
@@ -134,6 +134,37 @@ function rubberband(offset, dimension, constant = 0.55) {
134
134
  }
135
135
  var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
136
136
 
137
+ // src/engine/selection.ts
138
+ function guardSelection(el2) {
139
+ let held = false;
140
+ const block = (event) => {
141
+ if (held) event.preventDefault();
142
+ };
143
+ const clear = () => {
144
+ const selection = window.getSelection?.();
145
+ if (selection && !selection.isCollapsed) selection.removeAllRanges();
146
+ };
147
+ const down = () => {
148
+ held = true;
149
+ clear();
150
+ };
151
+ const up = () => {
152
+ if (!held) return;
153
+ held = false;
154
+ clear();
155
+ };
156
+ el2.addEventListener("pointerdown", down, true);
157
+ document.addEventListener("selectstart", block, true);
158
+ window.addEventListener("pointerup", up, true);
159
+ window.addEventListener("pointercancel", up, true);
160
+ return () => {
161
+ el2.removeEventListener("pointerdown", down, true);
162
+ document.removeEventListener("selectstart", block, true);
163
+ window.removeEventListener("pointerup", up, true);
164
+ window.removeEventListener("pointercancel", up, true);
165
+ };
166
+ }
167
+
137
168
  // src/engine/press.ts
138
169
  var FOLLOW = springFrom(0.2, 0.82);
139
170
  function usePress(ref, options = {}) {
@@ -163,18 +194,20 @@ function usePress(ref, options = {}) {
163
194
  };
164
195
  const track = (event) => {
165
196
  if (!pointer) return;
166
- const { box, base } = pointer;
197
+ const { box, base, w, h } = pointer;
167
198
  light(event, box);
168
199
  const dx = event.clientX - pointer.x;
169
200
  const dy = event.clientY - pointer.y;
170
- const tx = rubberband(dx, lean * 2.2, 0.5);
171
- const ty = rubberband(dy, lean * 2.2, 0.5);
172
201
  const dist = Math.hypot(dx, dy);
173
- const pull = 1 - 1 / (1 + dist / 55);
174
- const k = stretch * pull;
175
202
  const cx = dist ? (dx / dist) ** 2 : 0;
176
203
  const cy = dist ? (dy / dist) ** 2 : 0;
177
- to([base * (1 + k * cx - k * 0.5 * cy), base * (1 + k * cy - k * 0.5 * cx), tx, ty], FOLLOW);
204
+ const span = Math.min(w * cx + h * cy, 64);
205
+ const reach = rubberband(dist, span * stretch * 2, 0.55);
206
+ const ex = reach * cx / w;
207
+ const ey = reach * cy / h;
208
+ const tx = Math.sign(dx) * (reach * cx * base) / 2 + rubberband(dx, lean * 0.6, 0.4);
209
+ const ty = Math.sign(dy) * (reach * cy * base) / 2 + rubberband(dy, lean * 0.6, 0.4);
210
+ to([base * (1 + ex - ey * 0.35), base * (1 + ey - ex * 0.35), tx, ty], FOLLOW);
178
211
  };
179
212
  const move = (event) => {
180
213
  if (event.pointerId === pointer?.id) track(event);
@@ -197,7 +230,7 @@ function usePress(ref, options = {}) {
197
230
  const natural = Math.min(0.22, Math.max(0.07, 9 / Math.sqrt(w * h)));
198
231
  const amount = (grow ?? natural) * (event.pointerType === "mouse" ? 0.75 : 1);
199
232
  const base = 1 + amount;
200
- pointer = { id: event.pointerId, x: event.clientX, y: event.clientY, box, base };
233
+ pointer = { id: event.pointerId, x: event.clientX, y: event.clientY, box, base, w, h };
201
234
  el2.dataset.pressed = "";
202
235
  light(event, box);
203
236
  to([base, base, 0, 0], SPRINGS.press);
@@ -209,12 +242,14 @@ function usePress(ref, options = {}) {
209
242
  const hold = (event) => {
210
243
  if (pointer && event.cancelable) event.preventDefault();
211
244
  };
245
+ const unguard = guardSelection(el2);
212
246
  el2.addEventListener("touchmove", hold, { passive: false });
213
247
  el2.addEventListener("pointerdown", down);
214
248
  window.addEventListener("blur", blur);
215
249
  return () => {
216
250
  up();
217
251
  springs.forEach((s) => s.stop());
252
+ unguard();
218
253
  el2.removeEventListener("pointerdown", down);
219
254
  el2.removeEventListener("touchmove", hold);
220
255
  window.removeEventListener("blur", blur);
@@ -244,6 +279,7 @@ function clone(source) {
244
279
  });
245
280
  root.querySelectorAll(`[${SELF}], .lg-mirror, [data-lg-mirror-skip], input, textarea, select`).forEach((n) => n.remove());
246
281
  root.removeAttribute("data-mirror");
282
+ root.setAttribute("data-lg-copy", "");
247
283
  root.setAttribute("inert", "");
248
284
  root.setAttribute("aria-hidden", "true");
249
285
  return { root, pairs };
@@ -267,6 +303,7 @@ function backdropChain(glass, source) {
267
303
  }
268
304
  return chain;
269
305
  }
306
+ var stateOf = (el2) => Array.from(el2.attributes).map((a) => a.name).filter((name) => name.startsWith("data-") && name !== "data-mirror" && !name.startsWith("data-lg-mirror")).sort().join(" ");
270
307
  var BACKGROUND = ["background-color", "background-image", "background-size", "background-position", "background-repeat", "border-radius"];
271
308
  function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
272
309
  const layer = document.createElement("div");
@@ -350,6 +387,10 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
350
387
  root.style.margin = "0px";
351
388
  root.style.width = `${sw}px`;
352
389
  root.style.height = `${sh}px`;
390
+ root.style.maxWidth = "none";
391
+ root.style.maxHeight = "none";
392
+ root.style.minWidth = "0px";
393
+ root.style.minHeight = "0px";
353
394
  root.style.scale = "none";
354
395
  root.style.translate = "none";
355
396
  root.style.transformOrigin = "0 0";
@@ -372,10 +413,19 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
372
413
  pair.copy.className = cls;
373
414
  }
374
415
  }
416
+ const flags = stateOf(source);
417
+ if (flags !== copyFlags) {
418
+ const now = new Set(flags.split(" "));
419
+ for (const name of copyFlags.split(" ")) if (name && !now.has(name)) copy.root.removeAttribute(name);
420
+ for (const name of flags.split(" ")) if (name) copy.root.setAttribute(name, source.getAttribute(name) ?? "");
421
+ copyFlags = flags;
422
+ }
375
423
  };
424
+ let copyFlags = "";
376
425
  let zoomed = "";
377
426
  const applyZoom = () => {
378
- const value = `scale(${zoom()})`;
427
+ const z = zoom();
428
+ const value = Array.isArray(z) ? `scale(${z[0]}, ${z[1]})` : `scale(${z})`;
379
429
  if (value !== zoomed) zoomer.style.transform = zoomed = value;
380
430
  };
381
431
  const tick = () => {
@@ -401,6 +451,7 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
401
451
  const next = clone(source);
402
452
  copy.root.replaceWith(next.root);
403
453
  copy = next;
454
+ copyFlags = "";
404
455
  placed = "";
405
456
  buildUnder();
406
457
  align();
@@ -488,10 +539,17 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
488
539
  const rimA = new Float32Array(cw * ch);
489
540
  const rimHue = new Float32Array(cw * ch);
490
541
  const inside = new Float32Array(cw * ch);
542
+ const zone = new Float32Array(cw * ch);
491
543
  let max = 1e-4;
492
544
  const hw = width / 2;
493
545
  const hh = height / 2;
494
546
  const px1 = 1 / density;
547
+ const edge = hh - shape.inset;
548
+ const band = (py) => {
549
+ if (!shape.inset) return 1;
550
+ const t = clamp((Math.abs(py) - (edge - 2)) / 3, 0, 1);
551
+ return 1 - t * t * (3 - 2 * t);
552
+ };
495
553
  for (let y = 0; y < ch; y++) {
496
554
  for (let x = 0; x < cw; x++) {
497
555
  const px = (x + 0.5) * W / cw - W / 2;
@@ -515,18 +573,19 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
515
573
  ny = Math.sign(py);
516
574
  }
517
575
  const i = y * cw + x;
518
- const s = shift(d) * shape.strength * direction;
576
+ const s = shift(d) * shape.strength * direction * band(py);
519
577
  let vx = nx * s;
520
578
  let vy = ny * s;
521
579
  if (simple && magnify) {
522
- vx -= px * magnify;
523
- vy -= py * magnify;
580
+ vx -= px * magnify * band(py);
581
+ vy -= py * magnify * band(py);
524
582
  }
525
583
  dx[i] = vx;
526
584
  dy[i] = vy;
527
585
  const m = Math.max(Math.abs(vx), Math.abs(vy));
528
586
  if (m > max) max = m;
529
587
  inside[i] = clamp(d / px1 + 0.5, 0, 1);
588
+ zone[i] = (d <= 0 ? 1 : clamp(1 - d / Math.max(1, shape.bezel), 0, 1) ** 1.3) * band(py);
530
589
  if (d >= -px1) {
531
590
  const facing = -(nx + ny) * Math.SQRT1_2;
532
591
  const light = 0.22 + 0.78 * Math.abs(facing) ** 2.2 * (facing > 0 ? 1 : 0.62);
@@ -561,8 +620,9 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
561
620
  const o = (y * cw + x) * 4;
562
621
  const px = (x + 0.5) * W / cw - W / 2;
563
622
  const py = (y + 0.5) * H / ch - H / 2;
564
- ramp.data[o] = Math.round(127.5 - px / reach * 127.5);
565
- ramp.data[o + 1] = Math.round(127.5 - py / reach * 127.5);
623
+ const k = band(py);
624
+ ramp.data[o] = Math.round(127.5 - px / reach * 127.5 * k);
625
+ ramp.data[o + 1] = Math.round(127.5 - py / reach * 127.5 * k);
566
626
  ramp.data[o + 2] = 128;
567
627
  ramp.data[o + 3] = 255;
568
628
  }
@@ -598,6 +658,17 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
598
658
  }
599
659
  ctx.putImageData(shapeMask, 0, 0);
600
660
  const mask = canvas.toDataURL();
661
+ let smooth = "";
662
+ if (lens && !simple) {
663
+ const soft = ctx.createImageData(cw, ch);
664
+ for (let i = 0; i < cw * ch; i++) {
665
+ const o = i * 4;
666
+ soft.data[o] = soft.data[o + 1] = soft.data[o + 2] = 255;
667
+ soft.data[o + 3] = Math.round(zone[i] * 255);
668
+ }
669
+ ctx.putImageData(soft, 0, 0);
670
+ smooth = canvas.toDataURL();
671
+ }
601
672
  const id = `lg-refract-${++counter}`;
602
673
  const box = { x: 0, y: 0, width: W, height: H };
603
674
  const filter = el("filter", {
@@ -662,9 +733,20 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
662
733
  })
663
734
  );
664
735
  }
736
+ let out = "bent";
737
+ if (smooth) {
738
+ filter.append(
739
+ el("feGaussianBlur", { in: "bent", stdDeviation: 0.65, result: "bent-soft" }),
740
+ el("feImage", { href: smooth, ...box, preserveAspectRatio: "none", result: "rim-zone" }),
741
+ el("feComposite", { in: "bent-soft", in2: "rim-zone", operator: "in", result: "rim-soft" }),
742
+ el("feComposite", { in: "bent", in2: "rim-zone", operator: "out", result: "core" }),
743
+ el("feComposite", { in: "rim-soft", in2: "core", operator: "arithmetic", k2: 1, k3: 1, result: "smoothed" })
744
+ );
745
+ out = "smoothed";
746
+ }
665
747
  filter.append(
666
748
  el("feImage", { href: mask, ...box, preserveAspectRatio: "none", result: "shape" }),
667
- el("feComposite", { in: "bent", in2: "shape", operator: "in" })
749
+ el("feComposite", { in: out, in2: "shape", operator: "in" })
668
750
  );
669
751
  container().append(filter);
670
752
  return { filter: `url(#${id})`, rim: `url("${rim}")`, inner: `url("${mask}")` };
@@ -679,8 +761,11 @@ function resolve(shape, width, height) {
679
761
  thickness: shape.thickness ?? (lens ? short * 0.55 : clamp(short * 0.32, 8, 26)),
680
762
  ior: shape.ior ?? 1.5,
681
763
  zoom: shape.zoom ?? (lens ? 1.16 : 1),
764
+ zoomX: shape.zoomX ?? shape.zoom ?? (lens ? 1.16 : 1),
682
765
  dispersion: shape.dispersion ?? (lens ? 1 : 0),
683
- strength: shape.strength ?? 1
766
+ strength: shape.strength ?? 1,
767
+ inset: shape.inset ?? 0,
768
+ copy: shape.copy ?? false
684
769
  };
685
770
  }
686
771
  function glassFor(width, height, radius, shape = {}, pad = 0, simple = false) {
@@ -688,7 +773,7 @@ function glassFor(width, height, radius, shape = {}, pad = 0, simple = false) {
688
773
  const h = Math.round(height);
689
774
  const r = Math.min(w / 2, h / 2, Math.max(0, radius));
690
775
  const full = resolve(shape, w, h);
691
- const key = [w, h, Math.round(r * 2) / 2, full.kind, full.bezel.toFixed(1), full.thickness.toFixed(1), full.ior, full.zoom, full.dispersion, full.strength, pad, simple].join("|");
776
+ const key = [w, h, Math.round(r * 2) / 2, full.kind, full.bezel.toFixed(1), full.thickness.toFixed(1), full.ior, full.zoom, full.dispersion, full.strength, full.inset, pad, simple].join("|");
692
777
  let baked = cache.get(key);
693
778
  if (!baked) {
694
779
  baked = bake(w, h, r, full, pad, simple);
@@ -715,11 +800,18 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
715
800
  useEffect2(() => {
716
801
  const element = ref.current;
717
802
  if (!element || !enabled) return;
718
- const live = canRefractBackdrop();
803
+ const live = canRefractBackdrop() && !(shape.copy && mirror);
719
804
  let cancel;
720
805
  let filter = "";
721
806
  let pad = 0;
722
807
  let zoom = 1;
808
+ let zoomX = 1;
809
+ const bendCopy = shape.copy === "refract" && canRefractBackdrop() && !!mirror;
810
+ let copyFilter = "";
811
+ const applyCopyFilter = () => {
812
+ const viewport = element.querySelector(":scope > .lg-mirror > .lg-mirror__viewport");
813
+ if (viewport && copyFilter) viewport.style.filter = copyFilter;
814
+ };
723
815
  const fit = () => {
724
816
  const width = element.offsetWidth;
725
817
  const height = element.offsetHeight;
@@ -729,10 +821,17 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
729
821
  filter = baked.filter;
730
822
  if (!live && mirror?.current) {
731
823
  pad = Math.ceil(Math.min(width, height) * 0.45 + 6);
732
- zoom = resolve(shape, width, height).zoom;
824
+ ({ zoom, zoomX } = resolve(shape, width, height));
733
825
  element.style.setProperty("--lg-inner-mask", baked.inner);
826
+ if (bendCopy) {
827
+ copyFilter = glassFor(width, height, radius, { ...shape, zoom: 1, zoomX: 1, dispersion: 0 }, pad).filter;
828
+ applyCopyFilter();
829
+ }
830
+ }
831
+ if (live) {
832
+ element.style.setProperty("--lg-filter", baked.filter);
833
+ element.setAttribute("data-lg-refract", "");
734
834
  }
735
- if (live) element.style.setProperty("--lg-filter", baked.filter);
736
835
  element.style.setProperty("--lg-rim", baked.rim);
737
836
  };
738
837
  const observer = new ResizeObserver(() => {
@@ -742,13 +841,15 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
742
841
  observer.observe(element);
743
842
  fit();
744
843
  const source = mirror?.current;
745
- const unmirror = !live && source ? mirrorBackdrop(element, source, () => pad, () => zoom, mirrorActive) : void 0;
844
+ const unmirror = !live && source ? mirrorBackdrop(element, source, () => pad, () => [zoomX, zoom], mirrorActive) : void 0;
845
+ applyCopyFilter();
746
846
  return () => {
747
847
  cancel?.();
748
848
  unmirror?.();
749
849
  observer.disconnect();
750
850
  element.style.removeProperty("--lg-filter");
751
851
  element.style.removeProperty("--lg-rim");
852
+ element.removeAttribute("data-lg-refract");
752
853
  };
753
854
  }, [ref, signature, enabled, mirror]);
754
855
  }
@@ -972,106 +1073,139 @@ import { createPortal } from "react-dom";
972
1073
  import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
973
1074
  var OPEN = springFrom(0.42, 0.86);
974
1075
  var CLOSE = springFrom(0.34, 1);
975
- var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label": ariaLabel }) => {
1076
+ var SNAP = springFrom(0.4, 0.84);
1077
+ var GlassSheet = ({ open, onClose, intensity = 5, tint, container: container2, detents, children, "aria-label": ariaLabel }) => {
976
1078
  const [mounted, setMounted] = useState2(open);
977
1079
  const sheetRef = useRef4(null);
978
1080
  const scrimRef = useRef4(null);
979
- const progress = useRef4(null);
1081
+ const api = useRef4(null);
1082
+ const stopsKey = detents?.join(",") ?? "";
980
1083
  const closeRef = useRef4(onClose);
981
1084
  closeRef.current = onClose;
982
1085
  useEffect3(() => {
983
1086
  if (open) setMounted(true);
984
- else progress.current?.set(0);
1087
+ else api.current?.close();
985
1088
  }, [open]);
986
1089
  useRefraction(sheetRef, { kind: "surface", strength: Math.max(1, Math.min(10, intensity)) / 5, bezel: 20, thickness: 28 }, mounted);
987
1090
  useEffect3(() => {
988
1091
  if (!mounted) return;
989
1092
  const sheet = sheetRef.current;
990
1093
  const scrim = scrimRef.current;
991
- let height = sheet.offsetHeight || 400;
992
- let drag = 0;
993
- const paint = (p) => {
994
- const y = (1 - p) * (height + 24) + drag;
1094
+ const layer = sheet.parentElement;
1095
+ const wanted = stopsKey ? stopsKey.split(",") : [];
1096
+ let height = 0;
1097
+ let hidden = 0;
1098
+ let stops = [0];
1099
+ let rest = 0;
1100
+ let medium = 0;
1101
+ const measure = () => {
1102
+ height = sheet.offsetHeight || 400;
1103
+ const top = sheet.offsetTop;
1104
+ hidden = layer.clientHeight - top + 24;
1105
+ medium = Math.max(0, layer.clientHeight * 0.5 - top);
1106
+ stops = wanted.length ? wanted.map((d) => d === "large" ? 0 : medium).sort((x, y) => x - y) : [0];
1107
+ rest = wanted.includes("medium") ? medium : stops[0];
1108
+ };
1109
+ measure();
1110
+ const paint = (y) => {
995
1111
  sheet.style.transform = `translateY(${y}px)`;
996
- scrim.style.opacity = String(clamp(p, 0, 1) * clamp(1 - drag / height, 0, 1));
1112
+ const dim = wanted.includes("medium") && medium > 0 ? clamp(1 - y / medium, 0, 1) : clamp(1 - y / Math.max(1, height), 0, 1);
1113
+ scrim.style.opacity = String(dim);
1114
+ const raised = y <= 1;
1115
+ if (wanted.length && sheet.hasAttribute("data-raised") !== raised) sheet.toggleAttribute("data-raised", raised);
997
1116
  };
998
- const spring = createSpring(0, OPEN, (p) => {
999
- paint(p);
1000
- if (p <= 1e-3 && spring.target === 0) setMounted(false);
1117
+ let closing = false;
1118
+ const position = createSpring(hidden, OPEN, (y) => {
1119
+ paint(y);
1120
+ if (closing && y >= hidden - 1) setMounted(false);
1001
1121
  });
1002
- progress.current = {
1003
- ...spring,
1004
- set(target, instant) {
1005
- spring.tune(target ? OPEN : CLOSE);
1006
- spring.set(target, instant);
1122
+ const go = (y, feel) => {
1123
+ position.tune(feel);
1124
+ position.set(y);
1125
+ };
1126
+ api.current = {
1127
+ close() {
1128
+ closing = true;
1129
+ go(hidden, CLOSE);
1007
1130
  }
1008
1131
  };
1009
- paint(0);
1132
+ paint(hidden);
1010
1133
  requestAnimationFrame(() => {
1011
- height = sheet.offsetHeight || height;
1012
- if (open) progress.current?.set(1);
1134
+ measure();
1135
+ position.set(hidden, true);
1136
+ if (open) go(rest, OPEN);
1013
1137
  });
1014
1138
  let gesture = null;
1015
1139
  const down = (event) => {
1016
- if (event.defaultPrevented) return;
1140
+ if (event.defaultPrevented || closing) return;
1017
1141
  const target = event.target;
1018
- if (!target.closest(".lg-sheet__grabber-zone") && sheet.scrollTop > 0) return;
1142
+ const raised = position.value <= 1;
1143
+ if (raised && !target.closest(".lg-sheet__grabber-zone") && sheet.scrollTop > 0) return;
1019
1144
  if (target.closest('input, textarea, button, a, [role="slider"], [role="switch"]')) return;
1020
- gesture = { id: event.pointerId, y: event.clientY, t: event.timeStamp, v: 0 };
1145
+ position.stop();
1146
+ gesture = { id: event.pointerId, y: event.clientY, from: position.value, t: event.timeStamp, v: 0, last: position.value };
1021
1147
  sheet.setPointerCapture(event.pointerId);
1022
1148
  };
1023
1149
  const move = (event) => {
1024
1150
  if (event.pointerId !== gesture?.id) return;
1025
- const dy = event.clientY - gesture.y;
1151
+ const raw = gesture.from + event.clientY - gesture.y;
1152
+ const y = raw < 0 ? rubberband(raw, height, 0.3) : raw;
1026
1153
  const dt = Math.max(1, event.timeStamp - gesture.t);
1027
- gesture.v = (dy - drag) / dt;
1154
+ gesture.v = gesture.v * 0.2 + (y - gesture.last) / dt * 0.8;
1028
1155
  gesture.t = event.timeStamp;
1029
- drag = dy > 0 ? dy : rubberband(dy, height, 0.3);
1030
- paint(spring.value);
1156
+ gesture.last = y;
1157
+ position.set(y, true);
1158
+ paint(y);
1031
1159
  };
1032
1160
  const up = (event) => {
1033
1161
  if (event.pointerId !== gesture?.id) return;
1034
- const flick = gesture.v > 0.6;
1162
+ const { v, last: last2 } = gesture;
1035
1163
  gesture = null;
1036
- const settle = createSpring(drag, SPRINGS.snap, (value) => {
1037
- drag = value;
1038
- paint(spring.value);
1039
- });
1040
- if (flick || drag > height * 0.3) {
1041
- settle.stop();
1042
- const p = 1 - clamp(drag / (height + 24), 0, 1);
1043
- drag = 0;
1044
- spring.set(p, true);
1164
+ const projected = last2 + v * 180;
1165
+ const lowest = stops[stops.length - 1];
1166
+ if (projected > lowest + (hidden - lowest) * 0.45 || v > 0.9 && last2 >= lowest - 4) {
1167
+ closing = true;
1168
+ go(hidden, CLOSE);
1045
1169
  closeRef.current?.();
1046
- } else {
1047
- settle.set(0);
1170
+ return;
1048
1171
  }
1172
+ const target = stops.reduce((best, stop) => Math.abs(stop - projected) < Math.abs(best - projected) ? stop : best, stops[0]);
1173
+ go(target, SNAP);
1049
1174
  };
1050
1175
  const key = (event) => {
1051
1176
  if (event.key === "Escape") closeRef.current?.();
1052
1177
  };
1178
+ const resize = () => {
1179
+ const at = position.target;
1180
+ const was = stops.indexOf(at);
1181
+ measure();
1182
+ if (!closing) go(was >= 0 ? stops[Math.min(was, stops.length - 1)] : rest, SNAP);
1183
+ };
1184
+ const observer = new ResizeObserver(resize);
1185
+ observer.observe(layer);
1053
1186
  sheet.addEventListener("pointerdown", down);
1054
1187
  sheet.addEventListener("pointermove", move);
1055
1188
  sheet.addEventListener("pointerup", up);
1056
1189
  sheet.addEventListener("pointercancel", up);
1057
1190
  window.addEventListener("keydown", key);
1058
1191
  const overflow = document.body.style.overflow;
1059
- document.body.style.overflow = "hidden";
1192
+ if (!container2) document.body.style.overflow = "hidden";
1060
1193
  sheet.focus({ preventScroll: true });
1061
1194
  return () => {
1062
- spring.stop();
1063
- progress.current = null;
1195
+ position.stop();
1196
+ api.current = null;
1197
+ observer.disconnect();
1064
1198
  sheet.removeEventListener("pointerdown", down);
1065
1199
  sheet.removeEventListener("pointermove", move);
1066
1200
  sheet.removeEventListener("pointerup", up);
1067
1201
  sheet.removeEventListener("pointercancel", up);
1068
1202
  window.removeEventListener("keydown", key);
1069
- document.body.style.overflow = overflow;
1203
+ if (!container2) document.body.style.overflow = overflow;
1070
1204
  };
1071
- }, [mounted]);
1205
+ }, [mounted, container2, stopsKey]);
1072
1206
  if (!mounted || typeof document === "undefined") return null;
1073
1207
  return createPortal(
1074
- /* @__PURE__ */ jsxs3("div", { className: "lg-sheet-layer", "data-liquid-glass": "", children: [
1208
+ /* @__PURE__ */ jsxs3("div", { className: "lg-sheet-layer", "data-liquid-glass": "", style: container2 ? { position: "absolute" } : void 0, children: [
1075
1209
  /* @__PURE__ */ jsx5("div", { ref: scrimRef, className: "lg-sheet__scrim", onClick: () => onClose?.(), "aria-hidden": "true" }),
1076
1210
  /* @__PURE__ */ jsxs3(
1077
1211
  "div",
@@ -1081,7 +1215,7 @@ var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label":
1081
1215
  "aria-modal": "true",
1082
1216
  "aria-label": ariaLabel,
1083
1217
  tabIndex: -1,
1084
- className: "lg-glass lg-glass--host lg-sheet",
1218
+ className: ["lg-glass", "lg-glass--host", "lg-sheet", detents?.length ? "lg-sheet--detents" : ""].filter(Boolean).join(" "),
1085
1219
  style: tint ? { "--lg-host-tint": tint } : void 0,
1086
1220
  children: [
1087
1221
  /* @__PURE__ */ jsx5("div", { className: "lg-sheet__grabber-zone", "aria-hidden": "true", children: /* @__PURE__ */ jsx5("span", { className: "lg-sheet__grabber" }) }),
@@ -1090,24 +1224,263 @@ var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label":
1090
1224
  }
1091
1225
  )
1092
1226
  ] }),
1093
- document.body
1227
+ container2 ?? document.body
1094
1228
  );
1095
1229
  };
1096
1230
  GlassSheet.displayName = "GlassSheet";
1097
1231
 
1232
+ // src/components/GlassMenu/GlassMenu.tsx
1233
+ import { useEffect as useEffect4, useLayoutEffect, useRef as useRef5, useState as useState3 } from "react";
1234
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
1235
+ var OPEN2 = springFrom(0.36, 0.74);
1236
+ var CLOSE2 = springFrom(0.34, 0.9);
1237
+ var FADE = springFrom(0.24, 1);
1238
+ var FADE_OUT = springFrom(0.14, 1);
1239
+ var JELLY = springFrom(0.42, 0.4);
1240
+ var Tick = () => /* @__PURE__ */ jsx6("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx6("path", { d: "M3.5 8.5l3 3 6-7", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) });
1241
+ var GlassMenu = ({
1242
+ icon,
1243
+ items,
1244
+ "aria-label": ariaLabel,
1245
+ align = "end",
1246
+ size = "md",
1247
+ width = 230,
1248
+ check,
1249
+ className
1250
+ }) => {
1251
+ const [open, setOpen] = useState3(false);
1252
+ const [mounted, setMounted] = useState3(false);
1253
+ const anchorRef = useRef5(null);
1254
+ const triggerRef = useRef5(null);
1255
+ const surfaceRef = useRef5(null);
1256
+ const panelRef = useRef5(null);
1257
+ const contentRef = useRef5(null);
1258
+ const spring = useRef5(null);
1259
+ const itemsRef = useRef5(items);
1260
+ itemsRef.current = items;
1261
+ usePress(surfaceRef, { grow: 0.035, lean: 6, stretch: 0.1, disabled: !mounted });
1262
+ useEffect4(() => {
1263
+ if (open) setMounted(true);
1264
+ else if (spring.current) {
1265
+ spring.current.tune(CLOSE2);
1266
+ spring.current.set(0);
1267
+ }
1268
+ }, [open]);
1269
+ useLayoutEffect(() => {
1270
+ if (!mounted) return;
1271
+ const surface = surfaceRef.current;
1272
+ const panel = panelRef.current;
1273
+ const content = contentRef.current;
1274
+ const trigger = triggerRef.current;
1275
+ const w = trigger.offsetWidth;
1276
+ const h = trigger.offsetHeight;
1277
+ const W = Math.max(w, Math.min(width, window.innerWidth - 24));
1278
+ content.style.width = `${W}px`;
1279
+ const H = Math.max(h, content.offsetHeight);
1280
+ surface.style.width = `${W}px`;
1281
+ surface.style.height = `${H}px`;
1282
+ const end = align === "end";
1283
+ const box = { cw: w, ch: h, r: h / 2 };
1284
+ let scaleNow = 1;
1285
+ const clipContent = () => {
1286
+ const k = scaleNow;
1287
+ const right = Math.max(0, W - box.cw / k);
1288
+ const bottom = Math.max(0, H - box.ch / k);
1289
+ content.style.clipPath = box.cw >= W - 0.5 && box.ch >= H - 0.5 && k === 1 ? "" : `inset(0 ${end ? 0 : right}px ${bottom}px ${end ? right : 0}px round ${box.r / k}px)`;
1290
+ };
1291
+ const shape = (p) => {
1292
+ const cw = Math.max(1, w + (W - w) * p);
1293
+ const ch = Math.max(1, h + (H - h) * p);
1294
+ const sx = cw / W;
1295
+ const sy = ch / H;
1296
+ panel.style.transform = `scale(${sx}, ${sy})`;
1297
+ const land = clamp((p - 0.5) / 0.5, 0, 1);
1298
+ const r = Math.min(cw, ch) / 2 * (1 - land) + 24 * land;
1299
+ panel.style.borderRadius = `${r / sx}px / ${r / sy}px`;
1300
+ box.cw = cw;
1301
+ box.ch = ch;
1302
+ box.r = r;
1303
+ clipContent();
1304
+ const k = clamp(p / 0.35, 0, 1);
1305
+ panel.style.opacity = String(k);
1306
+ trigger.style.opacity = String(1 - k);
1307
+ };
1308
+ const reveal = (q) => {
1309
+ const t = clamp(q, 0, 1);
1310
+ const blur = 9 * (1 - t) ** 2.5;
1311
+ content.style.opacity = String(t);
1312
+ scaleNow = t < 0.999 ? 0.82 + 0.18 * t : 1;
1313
+ content.style.scale = scaleNow === 1 ? "" : String(scaleNow);
1314
+ clipContent();
1315
+ content.style.filter = blur > 0.05 ? `blur(${blur.toFixed(2)}px)` : "none";
1316
+ };
1317
+ shape(0);
1318
+ reveal(0);
1319
+ const s = createSpring(0, OPEN2, (p) => {
1320
+ shape(p);
1321
+ if (p <= 0.02 && s.target === 0) {
1322
+ trigger.style.opacity = "";
1323
+ const jelly = createSpring(0.07, JELLY, (v) => {
1324
+ trigger.style.scale = Math.abs(v) < 5e-4 ? "" : `${1 - v} ${1 + v}`;
1325
+ });
1326
+ jelly.set(0);
1327
+ setMounted(false);
1328
+ }
1329
+ });
1330
+ const fade = createSpring(0, FADE, reveal);
1331
+ spring.current = {
1332
+ ...s,
1333
+ tune: s.tune,
1334
+ set(target, instant) {
1335
+ fade.tune(target ? FADE : FADE_OUT);
1336
+ fade.set(target, instant);
1337
+ s.set(target, instant);
1338
+ }
1339
+ };
1340
+ spring.current.set(1);
1341
+ content.querySelector('[role="menuitem"]:not([disabled])')?.focus({ preventScroll: true });
1342
+ return () => {
1343
+ s.stop();
1344
+ fade.stop();
1345
+ spring.current = null;
1346
+ trigger.style.opacity = "";
1347
+ };
1348
+ }, [mounted]);
1349
+ useEffect4(() => {
1350
+ if (!mounted) return;
1351
+ const panel = surfaceRef.current;
1352
+ let held = null;
1353
+ let hot = null;
1354
+ const itemAt = (x, y) => document.elementFromPoint(x, y)?.closest(".lg-menu__item:not(:disabled)") ?? null;
1355
+ const light = (next) => {
1356
+ if (next === hot) return;
1357
+ hot?.removeAttribute("data-active");
1358
+ hot = next;
1359
+ if (hot) {
1360
+ hot.setAttribute("data-active", "");
1361
+ haptic();
1362
+ }
1363
+ };
1364
+ const down = (event) => {
1365
+ if (!event.isPrimary || event.button !== 0) return;
1366
+ held = event.pointerId;
1367
+ hot = null;
1368
+ light(itemAt(event.clientX, event.clientY));
1369
+ };
1370
+ const move = (event) => {
1371
+ if (event.pointerId === held) light(itemAt(event.clientX, event.clientY));
1372
+ };
1373
+ const up = (event) => {
1374
+ if (event.pointerId !== held) return;
1375
+ held = null;
1376
+ const target = hot;
1377
+ light(null);
1378
+ const index = target ? Number(target.dataset.index) : -1;
1379
+ const item = itemsRef.current[index];
1380
+ if (item && !item.disabled) {
1381
+ event.preventDefault();
1382
+ haptic();
1383
+ item.onSelect?.();
1384
+ setOpen(false);
1385
+ }
1386
+ };
1387
+ const cancel = (event) => {
1388
+ if (event.pointerId !== held) return;
1389
+ held = null;
1390
+ light(null);
1391
+ };
1392
+ const hold = (event) => {
1393
+ if (held !== null && event.cancelable) event.preventDefault();
1394
+ };
1395
+ panel.addEventListener("pointerdown", down);
1396
+ window.addEventListener("pointermove", move);
1397
+ window.addEventListener("pointerup", up);
1398
+ window.addEventListener("pointercancel", cancel);
1399
+ panel.addEventListener("touchmove", hold, { passive: false });
1400
+ return () => {
1401
+ panel.removeEventListener("pointerdown", down);
1402
+ window.removeEventListener("pointermove", move);
1403
+ window.removeEventListener("pointerup", up);
1404
+ window.removeEventListener("pointercancel", cancel);
1405
+ panel.removeEventListener("touchmove", hold);
1406
+ };
1407
+ }, [mounted]);
1408
+ useEffect4(() => {
1409
+ if (!open) return;
1410
+ const outside = (event) => {
1411
+ if (!anchorRef.current?.contains(event.target)) setOpen(false);
1412
+ };
1413
+ const key = (event) => {
1414
+ if (event.key === "Escape") {
1415
+ setOpen(false);
1416
+ triggerRef.current?.focus({ preventScroll: true });
1417
+ }
1418
+ };
1419
+ document.addEventListener("pointerdown", outside, true);
1420
+ window.addEventListener("keydown", key);
1421
+ return () => {
1422
+ document.removeEventListener("pointerdown", outside, true);
1423
+ window.removeEventListener("keydown", key);
1424
+ };
1425
+ }, [open]);
1426
+ const select = (item) => {
1427
+ haptic();
1428
+ item.onSelect?.();
1429
+ setOpen(false);
1430
+ };
1431
+ return /* @__PURE__ */ jsxs4("span", { ref: anchorRef, className: ["lg-menu-anchor", className].filter(Boolean).join(" "), "data-align": align, children: [
1432
+ /* @__PURE__ */ jsx6(
1433
+ GlassButton,
1434
+ {
1435
+ ref: triggerRef,
1436
+ size,
1437
+ icon,
1438
+ "aria-label": ariaLabel,
1439
+ "aria-haspopup": "menu",
1440
+ "aria-expanded": open,
1441
+ onClick: () => setOpen((value) => !value)
1442
+ }
1443
+ ),
1444
+ mounted && /* @__PURE__ */ jsxs4("div", { ref: surfaceRef, className: "lg-menu-surface", children: [
1445
+ /* @__PURE__ */ jsx6("div", { ref: panelRef, className: "lg-glass lg-menu", "data-liquid-glass": "", "aria-hidden": "true" }),
1446
+ /* @__PURE__ */ jsx6("div", { ref: contentRef, className: "lg-menu__content", role: "menu", "aria-label": ariaLabel, children: items.map((item, index) => /* @__PURE__ */ jsxs4(
1447
+ "button",
1448
+ {
1449
+ type: "button",
1450
+ role: "menuitem",
1451
+ className: "lg-menu__item",
1452
+ "data-destructive": item.destructive ? "" : void 0,
1453
+ "data-index": index,
1454
+ disabled: item.disabled,
1455
+ onClick: (event) => {
1456
+ if (event.detail === 0) select(item);
1457
+ },
1458
+ children: [
1459
+ item.icon != null && /* @__PURE__ */ jsx6("span", { className: "lg-menu__icon", children: item.icon }),
1460
+ /* @__PURE__ */ jsx6("span", { className: "lg-menu__label", children: item.label }),
1461
+ item.checked && /* @__PURE__ */ jsx6("span", { className: "lg-menu__check", children: check ?? /* @__PURE__ */ jsx6(Tick, {}) })
1462
+ ]
1463
+ },
1464
+ index
1465
+ )) })
1466
+ ] })
1467
+ ] });
1468
+ };
1469
+ GlassMenu.displayName = "GlassMenu";
1470
+
1098
1471
  // src/components/GlassNav/GlassNav.tsx
1099
- import React6 from "react";
1472
+ import React7 from "react";
1100
1473
 
1101
1474
  // src/components/internal/LensTrack.tsx
1102
- import { useRef as useRef6 } from "react";
1475
+ import { useRef as useRef7 } from "react";
1103
1476
 
1104
1477
  // src/engine/lensTrack.ts
1105
- import { useEffect as useEffect4, useRef as useRef5 } from "react";
1478
+ import { useEffect as useEffect5, useRef as useRef6 } from "react";
1106
1479
  function useLensTrack(refs, options) {
1107
- const latest = useRef5(options);
1480
+ const latest = useRef6(options);
1108
1481
  latest.current = options;
1109
- const api = useRef5(null);
1110
- useEffect4(() => {
1482
+ const api = useRef6(null);
1483
+ useEffect5(() => {
1111
1484
  const bar = refs.bar.current;
1112
1485
  const lens = refs.lens.current;
1113
1486
  const glass = refs.glass.current;
@@ -1124,7 +1497,7 @@ function useLensTrack(refs, options) {
1124
1497
  let gesture = null;
1125
1498
  let dropTimer = 0;
1126
1499
  let suppressClick = false;
1127
- const buttons = Array.from(bar.querySelectorAll("[data-lg-item]"));
1500
+ const buttons = Array.from(bar.querySelectorAll(":scope > [data-lg-item]"));
1128
1501
  let glyphs = [];
1129
1502
  const preview = (index) => {
1130
1503
  if (index === void 0) delete bar.dataset.previewing;
@@ -1147,14 +1520,23 @@ function useLensTrack(refs, options) {
1147
1520
  select.style.width = `${slot}px`;
1148
1521
  select.style.left = `${pad}px`;
1149
1522
  glyphs = buttons.flatMap(
1150
- (button) => Array.from(button.querySelectorAll(".lg-nav__label, .lg-nav__icon > .lg-symbol")).map((node) => ({
1151
- node,
1152
- x: button.offsetLeft + node.offsetLeft - pad,
1153
- y: node.offsetTop,
1154
- width: node.offsetWidth,
1155
- height: node.offsetHeight,
1156
- label: node.classList.contains("lg-nav__label")
1157
- }))
1523
+ (button) => Array.from(button.querySelectorAll(".lg-nav__label, .lg-nav__icon > .lg-symbol")).map((node) => {
1524
+ const label2 = node.classList.contains("lg-nav__label");
1525
+ const host = label2 ? node : node.parentElement;
1526
+ const n = node.getBoundingClientRect();
1527
+ const h = host.getBoundingClientRect();
1528
+ return {
1529
+ node,
1530
+ x: button.offsetLeft + node.offsetLeft - pad,
1531
+ y: node.offsetTop,
1532
+ width: node.offsetWidth,
1533
+ height: node.offsetHeight,
1534
+ label: label2,
1535
+ host,
1536
+ dx: n.left - h.left,
1537
+ dy: n.top - h.top
1538
+ };
1539
+ })
1158
1540
  );
1159
1541
  };
1160
1542
  const paint = () => {
@@ -1176,8 +1558,24 @@ function useLensTrack(refs, options) {
1176
1558
  if (lift2 <= 0.02 && !gesture) {
1177
1559
  glyph.node.style.removeProperty("--lg-content-tint");
1178
1560
  glyph.node.style.removeProperty("transform");
1561
+ glyph.host.style.removeProperty("--lg-content-hide");
1179
1562
  continue;
1180
1563
  }
1564
+ if (latest.current.copied) {
1565
+ const hy = H * ky / 2;
1566
+ const hx = H * kx / 2;
1567
+ const run = Math.max(0, (W - H) * kx / 2);
1568
+ const ccx = x2 + slot / 2 - glyph.x + glyph.dx;
1569
+ const ccy = height / 2 - glyph.y + glyph.dy;
1570
+ const fade = clamp(lift2 * 3, 0, 1);
1571
+ const solid = `rgb(0 0 0 / ${fade})`;
1572
+ glyph.host.style.setProperty("--lg-content-hide", [
1573
+ "linear-gradient(#000, #000)",
1574
+ `radial-gradient(ellipse ${hx}px ${hy}px at ${ccx - run}px ${ccy}px, ${solid} calc(100% - 1px), transparent 100%)`,
1575
+ `radial-gradient(ellipse ${hx}px ${hy}px at ${ccx + run}px ${ccy}px, ${solid} calc(100% - 1px), transparent 100%)`,
1576
+ `linear-gradient(${solid}, ${solid}) ${ccx - run}px ${ccy - hy}px / ${run * 2}px ${hy * 2}px no-repeat`
1577
+ ].join(", "));
1578
+ }
1181
1579
  const zoom = latest.current.contentZoom ?? 1;
1182
1580
  const ry = H * ky / (2 * zoom);
1183
1581
  const rx = H * kx / (2 * zoom);
@@ -1370,6 +1768,7 @@ function useLensTrack(refs, options) {
1370
1768
  x.set(current * slot, true);
1371
1769
  bar.dataset.ready = "";
1372
1770
  observer.observe(bar);
1771
+ const unguard = guardSelection(bar);
1373
1772
  bar.addEventListener("pointerdown", onDown);
1374
1773
  window.addEventListener("pointermove", onMove);
1375
1774
  window.addEventListener("pointerup", onUp);
@@ -1383,6 +1782,7 @@ function useLensTrack(refs, options) {
1383
1782
  clearTimeout(dropTimer);
1384
1783
  api.current = null;
1385
1784
  [x, lift, swell].forEach((s) => s.stop());
1785
+ unguard();
1386
1786
  observer.disconnect();
1387
1787
  bar.removeEventListener("pointerdown", onDown);
1388
1788
  window.removeEventListener("pointermove", onMove);
@@ -1395,19 +1795,20 @@ function useLensTrack(refs, options) {
1395
1795
  delete bar.dataset.ready;
1396
1796
  delete bar.dataset.lifted;
1397
1797
  preview();
1398
- glyphs.forEach(({ node }) => {
1798
+ glyphs.forEach(({ node, host }) => {
1399
1799
  node.style.removeProperty("--lg-content-tint");
1400
1800
  node.style.removeProperty("transform");
1801
+ host.style.removeProperty("--lg-content-hide");
1401
1802
  });
1402
1803
  };
1403
1804
  }, [options.count]);
1404
- useEffect4(() => {
1805
+ useEffect5(() => {
1405
1806
  api.current?.setIndex(options.index);
1406
1807
  }, [options.index]);
1407
1808
  }
1408
1809
 
1409
1810
  // src/components/internal/LensTrack.tsx
1410
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
1811
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1411
1812
  function LensTrack({
1412
1813
  items,
1413
1814
  labels,
@@ -1419,28 +1820,36 @@ function LensTrack({
1419
1820
  style,
1420
1821
  "aria-label": ariaLabel
1421
1822
  }) {
1422
- const bar = useRef6(null);
1423
- const glass = useRef6(null);
1424
- const lens = useRef6(null);
1425
- const select = useRef6(null);
1823
+ const bar = useRef7(null);
1824
+ const glass = useRef7(null);
1825
+ const lens = useRef7(null);
1826
+ const select = useRef7(null);
1426
1827
  const strength = Math.max(1, Math.min(10, intensity)) / 5;
1427
1828
  const tabbar = variant === "tabbar";
1428
1829
  const zoom = tabbar ? 1.14 : 1.1;
1429
1830
  useRefraction(glass, { kind: "surface", strength });
1430
- useRefraction(lens, { kind: "lens", strength: 0, zoom, dispersion: 0, bezel: 2 });
1831
+ const overhang = tabbar ? 14 : 12;
1832
+ useRefraction(
1833
+ lens,
1834
+ { kind: "lens", strength: 0.85, zoom, dispersion: 0.25, inset: overhang / 2, copy: "refract" },
1835
+ true,
1836
+ bar,
1837
+ () => bar.current?.hasAttribute("data-lifted") ?? false
1838
+ );
1431
1839
  useLensTrack(
1432
1840
  { bar, glass, lens, select },
1433
1841
  {
1434
1842
  count: items.length,
1435
1843
  index,
1436
1844
  onSelect: (next) => onChange?.(next),
1437
- overhang: tabbar ? 14 : 12,
1845
+ overhang,
1438
1846
  spread: tabbar ? 0.3 : 0.16,
1439
- contentZoom: canRefractBackdrop() ? zoom : 1,
1847
+ contentZoom: zoom,
1848
+ copied: true,
1440
1849
  swell: tabbar ? 8 : 14
1441
1850
  }
1442
1851
  );
1443
- return /* @__PURE__ */ jsxs4(
1852
+ return /* @__PURE__ */ jsxs5(
1444
1853
  "div",
1445
1854
  {
1446
1855
  ref: bar,
@@ -1450,9 +1859,9 @@ function LensTrack({
1450
1859
  "data-liquid-glass": "",
1451
1860
  style: { ...style, "--lg-count": items.length, "--lg-index": index },
1452
1861
  children: [
1453
- /* @__PURE__ */ jsx6("span", { ref: glass, className: "lg-glass lg-track__glass", "aria-hidden": "true" }),
1454
- /* @__PURE__ */ jsx6("span", { ref: select, className: "lg-track__select", "aria-hidden": "true" }),
1455
- items.map((item, i) => /* @__PURE__ */ jsx6(
1862
+ /* @__PURE__ */ jsx7("span", { ref: glass, className: "lg-glass lg-track__glass", "aria-hidden": "true" }),
1863
+ /* @__PURE__ */ jsx7("span", { ref: select, className: "lg-track__select", "aria-hidden": "true" }),
1864
+ items.map((item, i) => /* @__PURE__ */ jsx7(
1456
1865
  "button",
1457
1866
  {
1458
1867
  type: "button",
@@ -1466,38 +1875,40 @@ function LensTrack({
1466
1875
  },
1467
1876
  i
1468
1877
  )),
1469
- /* @__PURE__ */ jsx6("span", { ref: lens, className: "lg-glass lg-track__lens", "aria-hidden": "true" })
1878
+ /* @__PURE__ */ jsx7("span", { ref: lens, className: "lg-glass lg-track__lens", "data-lg-mirror-bare": "", "aria-hidden": "true" })
1470
1879
  ]
1471
1880
  }
1472
1881
  );
1473
1882
  }
1474
1883
 
1475
1884
  // src/components/GlassNav/GlassNav.tsx
1476
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1885
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1477
1886
  var GlassNav = ({
1478
1887
  items,
1479
1888
  activeIndex = 0,
1480
1889
  onChange,
1481
1890
  intensity = 5,
1891
+ showLabels = true,
1482
1892
  className,
1483
1893
  style,
1484
1894
  "aria-label": ariaLabel = "Tabs"
1485
1895
  }) => {
1486
1896
  const hasIcons = items.some((item) => item.icon != null);
1487
- return /* @__PURE__ */ jsx7(
1897
+ const iconsOnly = hasIcons && !showLabels;
1898
+ return /* @__PURE__ */ jsx8(
1488
1899
  LensTrack,
1489
1900
  {
1490
1901
  variant: "tabbar",
1491
- className: ["lg-nav", hasIcons ? "" : "lg-track--labels-only", className].filter(Boolean).join(" "),
1902
+ className: ["lg-nav", hasIcons ? "" : "lg-track--labels-only", iconsOnly ? "lg-track--icons-only" : "", className].filter(Boolean).join(" "),
1492
1903
  style,
1493
1904
  "aria-label": ariaLabel,
1494
1905
  intensity,
1495
1906
  index: activeIndex,
1496
1907
  onChange,
1497
1908
  labels: items.map((item) => item.label),
1498
- items: items.map((item, i) => /* @__PURE__ */ jsxs5(React6.Fragment, { children: [
1499
- item.icon != null && /* @__PURE__ */ jsx7("span", { className: "lg-nav__icon", children: item.icon }),
1500
- /* @__PURE__ */ jsx7("span", { className: "lg-nav__label", children: item.label })
1909
+ items: items.map((item, i) => /* @__PURE__ */ jsxs6(React7.Fragment, { children: [
1910
+ item.icon != null && /* @__PURE__ */ jsx8("span", { className: "lg-nav__icon", children: item.icon }),
1911
+ !iconsOnly && /* @__PURE__ */ jsx8("span", { className: "lg-nav__label", children: item.label })
1501
1912
  ] }, i))
1502
1913
  }
1503
1914
  );
@@ -1505,8 +1916,8 @@ var GlassNav = ({
1505
1916
  GlassNav.displayName = "GlassNav";
1506
1917
 
1507
1918
  // src/components/GlassSegmented/GlassSegmented.tsx
1508
- import React7 from "react";
1509
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1919
+ import React8 from "react";
1920
+ import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1510
1921
  var GlassSegmented = ({
1511
1922
  options,
1512
1923
  value,
@@ -1518,7 +1929,7 @@ var GlassSegmented = ({
1518
1929
  "aria-label": ariaLabel
1519
1930
  }) => {
1520
1931
  const normalized = options.map((option) => typeof option === "string" ? { label: option } : option);
1521
- return /* @__PURE__ */ jsx8(
1932
+ return /* @__PURE__ */ jsx9(
1522
1933
  LensTrack,
1523
1934
  {
1524
1935
  variant: "segmented",
@@ -1529,9 +1940,9 @@ var GlassSegmented = ({
1529
1940
  index: value,
1530
1941
  onChange,
1531
1942
  labels: normalized.map((option) => option.label),
1532
- items: normalized.map((option, i) => /* @__PURE__ */ jsxs6(React7.Fragment, { children: [
1943
+ items: normalized.map((option, i) => /* @__PURE__ */ jsxs7(React8.Fragment, { children: [
1533
1944
  option.icon,
1534
- /* @__PURE__ */ jsx8("span", { children: option.label })
1945
+ /* @__PURE__ */ jsx9("span", { className: "lg-nav__label", children: option.label })
1535
1946
  ] }, i))
1536
1947
  }
1537
1948
  );
@@ -1539,9 +1950,9 @@ var GlassSegmented = ({
1539
1950
  GlassSegmented.displayName = "GlassSegmented";
1540
1951
 
1541
1952
  // src/components/GlassSlider/GlassSlider.tsx
1542
- import React8, { useEffect as useEffect5, useImperativeHandle as useImperativeHandle4, useRef as useRef7 } from "react";
1543
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1544
- var GlassSlider = React8.forwardRef(
1953
+ import React9, { useEffect as useEffect6, useImperativeHandle as useImperativeHandle4, useRef as useRef8 } from "react";
1954
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1955
+ var GlassSlider = React9.forwardRef(
1545
1956
  ({
1546
1957
  value = 0,
1547
1958
  min = 0,
@@ -1560,22 +1971,23 @@ var GlassSlider = React8.forwardRef(
1560
1971
  disabled,
1561
1972
  ...rest
1562
1973
  }, forwardedRef) => {
1563
- const rootRef = useRef7(null);
1564
- const inputRef = useRef7(null);
1565
- const thumbRef = useRef7(null);
1566
- const faceRef = useRef7(null);
1567
- const blockRef = useRef7(null);
1974
+ const rootRef = useRef8(null);
1975
+ const inputRef = useRef8(null);
1976
+ const thumbRef = useRef8(null);
1977
+ const faceRef = useRef8(null);
1978
+ const blockRef = useRef8(null);
1979
+ const pastRef = useRef8(0);
1568
1980
  useImperativeHandle4(forwardedRef, () => inputRef.current);
1569
- useEffect5(() => {
1981
+ useEffect6(() => {
1570
1982
  const input2 = inputRef.current;
1571
1983
  const root = rootRef.current;
1572
1984
  const setValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set;
1573
1985
  let drag = null;
1574
1986
  const update = (clientX) => {
1575
1987
  if (!drag || max <= min) return;
1576
- const inset = showThumb ? 19 * drag.width / root.offsetWidth : 0;
1577
- const travel = Math.max(1, drag.width - inset * 2);
1578
- const fraction = clamp((clientX - drag.left - inset - drag.offset) / travel, 0, 1);
1988
+ const raw = drag.from + (clientX - drag.x) / drag.travel;
1989
+ const fraction = clamp(raw, 0, 1);
1990
+ pastRef.current = (raw - fraction) * drag.travel;
1579
1991
  let next = min + fraction * (max - min);
1580
1992
  const increment = Number(step2);
1581
1993
  if (step2 !== "any" && Number.isFinite(increment) && increment > 0) {
@@ -1594,13 +2006,11 @@ var GlassSlider = React8.forwardRef(
1594
2006
  if (event.pointerType !== "touch") input2.focus({ preventScroll: true });
1595
2007
  const box = root.getBoundingClientRect();
1596
2008
  const inset = showThumb ? 19 * box.width / root.offsetWidth : 0;
1597
- const current = max > min ? clamp((input2.valueAsNumber - min) / (max - min), 0, 1) : 0;
1598
- const center = box.left + inset + current * (box.width - inset * 2);
1599
- const offset = showThumb && Math.abs(event.clientX - center) <= inset ? event.clientX - center : 0;
1600
- drag = { id: event.pointerId, left: box.left, width: box.width, offset };
2009
+ const from = max > min ? clamp((input2.valueAsNumber - min) / (max - min), 0, 1) : 0;
2010
+ drag = { id: event.pointerId, x: event.clientX, from, travel: Math.max(1, box.width - inset * 2) };
2011
+ pastRef.current = 0;
1601
2012
  root.dataset.dragging = "";
1602
2013
  root.setPointerCapture(event.pointerId);
1603
- update(event.clientX);
1604
2014
  };
1605
2015
  const move = (event) => {
1606
2016
  if (event.pointerId !== drag?.id) return;
@@ -1611,6 +2021,7 @@ var GlassSlider = React8.forwardRef(
1611
2021
  if (!drag) return;
1612
2022
  const id = drag.id;
1613
2023
  drag = null;
2024
+ pastRef.current = 0;
1614
2025
  delete root.dataset.dragging;
1615
2026
  if (root.hasPointerCapture(id)) root.releasePointerCapture(id);
1616
2027
  };
@@ -1619,6 +2030,7 @@ var GlassSlider = React8.forwardRef(
1619
2030
  update(event.clientX);
1620
2031
  release();
1621
2032
  };
2033
+ const unguard = guardSelection(root);
1622
2034
  root.addEventListener("pointerdown", down);
1623
2035
  root.addEventListener("pointermove", move);
1624
2036
  root.addEventListener("pointerup", up);
@@ -1627,6 +2039,7 @@ var GlassSlider = React8.forwardRef(
1627
2039
  window.addEventListener("blur", release);
1628
2040
  return () => {
1629
2041
  release();
2042
+ unguard();
1630
2043
  root.removeEventListener("pointerdown", down);
1631
2044
  root.removeEventListener("pointermove", move);
1632
2045
  root.removeEventListener("pointerup", up);
@@ -1636,29 +2049,31 @@ var GlassSlider = React8.forwardRef(
1636
2049
  };
1637
2050
  }, [min, max, step2, showThumb]);
1638
2051
  const strength = Math.max(1, Math.min(10, intensity)) / 5;
1639
- const [mirrored, setMirrored] = React8.useState(false);
1640
- useEffect5(() => setMirrored(!canRefractBackdrop()), []);
2052
+ const [mirrored, setMirrored] = React9.useState(false);
2053
+ useEffect6(() => setMirrored(!canRefractBackdrop()), []);
1641
2054
  const progress = max > min ? clamp((Number(value) - min) / (max - min), 0, 1) : 0;
1642
2055
  useRefraction(
1643
2056
  thumbRef,
1644
- { kind: "lens", zoom: 1.95, bezel: 7, thickness: 16, strength, dispersion: 0.6 },
2057
+ { kind: "lens", zoom: 1.95, bezel: 7, thickness: 16, strength, dispersion: 0.6, inset: 11 },
1645
2058
  showThumb,
1646
2059
  rootRef,
1647
2060
  () => parseFloat(rootRef.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
1648
2061
  );
1649
2062
  useRefraction(blockRef, { kind: "surface", strength }, !showThumb);
1650
- useEffect5(() => {
2063
+ useEffect6(() => {
1651
2064
  if (!showThumb) return;
1652
2065
  const input2 = inputRef.current;
1653
2066
  const thumb = thumbRef.current;
1654
2067
  const face = faceRef.current;
1655
2068
  const root = rootRef.current;
1656
- const v = { lift: 0, stretch: 0 };
2069
+ const v = { lift: 0, stretch: 0, over: 0 };
1657
2070
  const paint = () => {
1658
2071
  const s = 0.655 + 0.345 * v.lift;
1659
- thumb.style.scale = `${s * (1 + v.stretch)} ${s * (1 - v.stretch * 0.5)}`;
2072
+ const pull = Math.abs(v.over) / 58 * 0.6;
2073
+ thumb.style.scale = `${s * (1 + v.stretch + pull)} ${s * (1 - v.stretch * 0.5 - pull * 0.4)}`;
1660
2074
  face.style.opacity = String(1 - clamp(v.lift, 0, 1) * 0.92);
1661
2075
  root.style.setProperty("--lg-lift", String(clamp(v.lift, 0, 1)));
2076
+ root.style.setProperty("--lg-over", `${v.over.toFixed(2)}px`);
1662
2077
  if (v.lift < 0.01 && lift.target === 0) delete root.dataset.lifted;
1663
2078
  };
1664
2079
  const lift = createSpring(0, SPRINGS.lift, (x) => {
@@ -1669,6 +2084,10 @@ var GlassSlider = React8.forwardRef(
1669
2084
  v.stretch = x;
1670
2085
  paint();
1671
2086
  });
2087
+ const over = createSpring(0, SPRINGS.release, (x) => {
2088
+ v.over = x;
2089
+ paint();
2090
+ });
1672
2091
  paint();
1673
2092
  let lastX = 0;
1674
2093
  let lastT = 0;
@@ -1689,6 +2108,8 @@ var GlassSlider = React8.forwardRef(
1689
2108
  lastT = event.timeStamp;
1690
2109
  stretch.tune(SPRINGS.drag);
1691
2110
  stretch.set(clamp(speed * 0.015, 0, 0.035));
2111
+ over.tune(SPRINGS.drag);
2112
+ over.set(rubberband(pastRef.current, 12, 0.5));
1692
2113
  };
1693
2114
  const up = () => {
1694
2115
  if (lift.target === 0) return;
@@ -1696,6 +2117,8 @@ var GlassSlider = React8.forwardRef(
1696
2117
  lift.set(0);
1697
2118
  stretch.tune(SPRINGS.release);
1698
2119
  stretch.set(0);
2120
+ over.tune(SPRINGS.release);
2121
+ over.set(0);
1699
2122
  };
1700
2123
  root.addEventListener("pointerdown", down);
1701
2124
  window.addEventListener("pointermove", move);
@@ -1706,6 +2129,7 @@ var GlassSlider = React8.forwardRef(
1706
2129
  return () => {
1707
2130
  lift.stop();
1708
2131
  stretch.stop();
2132
+ over.stop();
1709
2133
  root.removeEventListener("pointerdown", down);
1710
2134
  window.removeEventListener("pointermove", move);
1711
2135
  window.removeEventListener("pointerup", up);
@@ -1715,7 +2139,7 @@ var GlassSlider = React8.forwardRef(
1715
2139
  delete root.dataset.lifted;
1716
2140
  };
1717
2141
  }, [showThumb]);
1718
- useEffect5(() => {
2142
+ useEffect6(() => {
1719
2143
  if (showThumb) return;
1720
2144
  const input2 = inputRef.current;
1721
2145
  const block = blockRef.current;
@@ -1739,17 +2163,15 @@ var GlassSlider = React8.forwardRef(
1739
2163
  let active2 = null;
1740
2164
  const down = (event) => {
1741
2165
  if (input2.disabled || !event.isPrimary || event.button !== 0) return;
1742
- active2 = { id: event.pointerId, box: block.getBoundingClientRect() };
2166
+ active2 = { id: event.pointerId };
1743
2167
  swell.tune(SPRINGS.press);
1744
2168
  swell.set(1);
1745
2169
  haptic();
1746
2170
  };
1747
2171
  const move = (event) => {
1748
2172
  if (event.pointerId !== active2?.id) return;
1749
- const { box } = active2;
1750
- const past = event.clientX < box.left ? event.clientX - box.left : event.clientX > box.right ? event.clientX - box.right : 0;
1751
2173
  over.tune(SPRINGS.drag);
1752
- over.set(rubberband(past, 26, 0.6));
2174
+ over.set(rubberband(pastRef.current, 26, 0.6));
1753
2175
  };
1754
2176
  const reset = () => {
1755
2177
  if (!active2) return;
@@ -1779,7 +2201,7 @@ var GlassSlider = React8.forwardRef(
1779
2201
  window.removeEventListener("pointercancel", up);
1780
2202
  };
1781
2203
  }, [showThumb]);
1782
- const input = /* @__PURE__ */ jsx9(
2204
+ const input = /* @__PURE__ */ jsx10(
1783
2205
  "input",
1784
2206
  {
1785
2207
  ref: inputRef,
@@ -1799,7 +2221,7 @@ var GlassSlider = React8.forwardRef(
1799
2221
  );
1800
2222
  const vars = { "--lg-progress": progress, ...tint ? { "--lg-slider-fill": tint } : {}, ...style };
1801
2223
  if (!showThumb) {
1802
- return /* @__PURE__ */ jsxs7(
2224
+ return /* @__PURE__ */ jsxs8(
1803
2225
  "div",
1804
2226
  {
1805
2227
  ref: rootRef,
@@ -1807,16 +2229,16 @@ var GlassSlider = React8.forwardRef(
1807
2229
  "data-liquid-glass": "",
1808
2230
  style: vars,
1809
2231
  children: [
1810
- /* @__PURE__ */ jsxs7("div", { ref: blockRef, className: "lg-glass lg-slider__block", children: [
1811
- /* @__PURE__ */ jsxs7("span", { className: "lg-slider__block-content", "aria-hidden": "true", children: [
1812
- icon && /* @__PURE__ */ jsx9("span", { className: "lg-slider__icon", children: icon }),
1813
- label2 && /* @__PURE__ */ jsx9("span", { className: "lg-slider__label", children: label2 }),
1814
- /* @__PURE__ */ jsx9("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
2232
+ /* @__PURE__ */ jsxs8("div", { ref: blockRef, className: "lg-glass lg-slider__block", children: [
2233
+ /* @__PURE__ */ jsxs8("span", { className: "lg-slider__block-content", "aria-hidden": "true", children: [
2234
+ icon && /* @__PURE__ */ jsx10("span", { className: "lg-slider__icon", children: icon }),
2235
+ label2 && /* @__PURE__ */ jsx10("span", { className: "lg-slider__label", children: label2 }),
2236
+ /* @__PURE__ */ jsx10("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
1815
2237
  ] }),
1816
- /* @__PURE__ */ jsx9("span", { className: "lg-slider__block-fill", "aria-hidden": "true", children: /* @__PURE__ */ jsxs7("span", { className: "lg-slider__block-content lg-slider__block-content--lit", children: [
1817
- icon && /* @__PURE__ */ jsx9("span", { className: "lg-slider__icon", children: icon }),
1818
- label2 && /* @__PURE__ */ jsx9("span", { className: "lg-slider__label", children: label2 }),
1819
- /* @__PURE__ */ jsx9("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
2238
+ /* @__PURE__ */ jsx10("span", { className: "lg-slider__block-fill", "aria-hidden": "true", children: /* @__PURE__ */ jsxs8("span", { className: "lg-slider__block-content lg-slider__block-content--lit", children: [
2239
+ icon && /* @__PURE__ */ jsx10("span", { className: "lg-slider__icon", children: icon }),
2240
+ label2 && /* @__PURE__ */ jsx10("span", { className: "lg-slider__label", children: label2 }),
2241
+ /* @__PURE__ */ jsx10("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
1820
2242
  ] }) })
1821
2243
  ] }),
1822
2244
  input
@@ -1824,7 +2246,7 @@ var GlassSlider = React8.forwardRef(
1824
2246
  }
1825
2247
  );
1826
2248
  }
1827
- return /* @__PURE__ */ jsxs7(
2249
+ return /* @__PURE__ */ jsxs8(
1828
2250
  "div",
1829
2251
  {
1830
2252
  ref: rootRef,
@@ -1833,8 +2255,8 @@ var GlassSlider = React8.forwardRef(
1833
2255
  "data-mirror": mirrored ? "" : void 0,
1834
2256
  style: vars,
1835
2257
  children: [
1836
- /* @__PURE__ */ jsx9("span", { className: "lg-slider__rail", "aria-hidden": "true", children: /* @__PURE__ */ jsx9("span", { className: "lg-slider__fill" }) }),
1837
- /* @__PURE__ */ jsx9("span", { className: "lg-slider__thumb-slot", "aria-hidden": "true", children: /* @__PURE__ */ jsx9("span", { ref: thumbRef, className: "lg-glass lg-slider__thumb", "data-lg-mirror-bare": "", children: /* @__PURE__ */ jsx9("span", { ref: faceRef, className: "lg-slider__face" }) }) }),
2258
+ /* @__PURE__ */ jsx10("span", { className: "lg-slider__rail", "aria-hidden": "true", children: /* @__PURE__ */ jsx10("span", { className: "lg-slider__fill" }) }),
2259
+ /* @__PURE__ */ jsx10("span", { className: "lg-slider__thumb-slot", "aria-hidden": "true", children: /* @__PURE__ */ jsx10("span", { ref: thumbRef, className: "lg-glass lg-slider__thumb", "data-lg-mirror-bare": "", children: /* @__PURE__ */ jsx10("span", { ref: faceRef, className: "lg-slider__face" }) }) }),
1838
2260
  input
1839
2261
  ]
1840
2262
  }
@@ -1844,22 +2266,22 @@ var GlassSlider = React8.forwardRef(
1844
2266
  GlassSlider.displayName = "GlassSlider";
1845
2267
 
1846
2268
  // src/components/GlassSwitch/GlassSwitch.tsx
1847
- import React9, { useEffect as useEffect6, useImperativeHandle as useImperativeHandle5, useRef as useRef8, useState as useState3 } from "react";
1848
- import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
2269
+ import React10, { useEffect as useEffect7, useImperativeHandle as useImperativeHandle5, useRef as useRef9, useState as useState4 } from "react";
2270
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1849
2271
  var SETTLE = springFrom(0.36, 0.68);
1850
2272
  var REST = 0.655;
1851
2273
  var TRAVEL = 22;
1852
- var GlassSwitch = React9.forwardRef(
2274
+ var GlassSwitch = React10.forwardRef(
1853
2275
  ({ checked: checkedProp, defaultChecked = false, onChange, tint, intensity = 5, className, style, disabled, ...rest }, forwardedRef) => {
1854
- const ref = useRef8(null);
1855
- const thumbRef = useRef8(null);
1856
- const fillRef = useRef8(null);
1857
- const faceRef = useRef8(null);
2276
+ const ref = useRef9(null);
2277
+ const thumbRef = useRef9(null);
2278
+ const fillRef = useRef9(null);
2279
+ const faceRef = useRef9(null);
1858
2280
  useImperativeHandle5(forwardedRef, () => ref.current);
1859
- const [inner, setInner] = useState3(defaultChecked);
2281
+ const [inner, setInner] = useState4(defaultChecked);
1860
2282
  const controlled = checkedProp !== void 0;
1861
2283
  const checked = controlled ? checkedProp : inner;
1862
- const latest = useRef8({ checked, set: (_) => {
2284
+ const latest = useRef9({ checked, set: (_) => {
1863
2285
  }, disabled });
1864
2286
  latest.current = {
1865
2287
  checked,
@@ -1869,15 +2291,15 @@ var GlassSwitch = React9.forwardRef(
1869
2291
  onChange?.(next);
1870
2292
  }
1871
2293
  };
1872
- const sync = useRef8(null);
2294
+ const sync = useRef9(null);
1873
2295
  useRefraction(
1874
2296
  thumbRef,
1875
- { kind: "lens", zoom: 1, dispersion: 0.5, strength: Math.max(1, Math.min(10, intensity)) / 5 },
2297
+ { kind: "lens", zoom: 0.72, zoomX: 1, dispersion: 0.5, copy: true, strength: Math.max(1, Math.min(10, intensity)) / 5 },
1876
2298
  true,
1877
2299
  ref,
1878
2300
  () => parseFloat(ref.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
1879
2301
  );
1880
- useEffect6(() => {
2302
+ useEffect7(() => {
1881
2303
  const el2 = ref.current;
1882
2304
  const thumb = thumbRef.current;
1883
2305
  const fill = fillRef.current;
@@ -1888,6 +2310,8 @@ var GlassSwitch = React9.forwardRef(
1888
2310
  const sy = s * (1 - v.stretch * 0.5);
1889
2311
  thumb.style.transform = `translate(${v.x * TRAVEL}px, -50%) scale(${sx}, ${sy})`;
1890
2312
  const l = clamp(v.lift, 0, 1);
2313
+ el2.style.setProperty("--lg-knob-x", `${(21 + v.x * TRAVEL).toFixed(2)}px`);
2314
+ el2.style.setProperty("--lg-hole", `${(l > 0.01 ? 23 * sx : 0).toFixed(2)}px`);
1891
2315
  el2.style.setProperty("--lg-lift", String(l));
1892
2316
  el2.toggleAttribute("data-lifted", l > 0.01);
1893
2317
  };
@@ -1977,6 +2401,7 @@ var GlassSwitch = React9.forwardRef(
1977
2401
  latest.current.set(next);
1978
2402
  sync.current?.(next);
1979
2403
  };
2404
+ const unguard = guardSelection(el2);
1980
2405
  el2.addEventListener("pointerdown", down);
1981
2406
  el2.addEventListener("pointermove", move);
1982
2407
  el2.addEventListener("pointerup", up);
@@ -1985,6 +2410,7 @@ var GlassSwitch = React9.forwardRef(
1985
2410
  return () => {
1986
2411
  clearTimeout(dropTimer);
1987
2412
  [position, lift, color].forEach((s) => s.stop());
2413
+ unguard();
1988
2414
  el2.removeEventListener("pointerdown", down);
1989
2415
  el2.removeEventListener("pointermove", move);
1990
2416
  el2.removeEventListener("pointerup", up);
@@ -1992,10 +2418,10 @@ var GlassSwitch = React9.forwardRef(
1992
2418
  el2.removeEventListener("click", click);
1993
2419
  };
1994
2420
  }, []);
1995
- useEffect6(() => {
2421
+ useEffect7(() => {
1996
2422
  sync.current?.(checked);
1997
2423
  }, [checked]);
1998
- return /* @__PURE__ */ jsxs8(
2424
+ return /* @__PURE__ */ jsxs9(
1999
2425
  "button",
2000
2426
  {
2001
2427
  ref,
@@ -2012,8 +2438,9 @@ var GlassSwitch = React9.forwardRef(
2012
2438
  rest.onKeyDown?.(event);
2013
2439
  },
2014
2440
  children: [
2015
- /* @__PURE__ */ jsx10("span", { ref: fillRef, className: "lg-switch__fill", "aria-hidden": "true" }),
2016
- /* @__PURE__ */ jsx10("span", { ref: thumbRef, className: "lg-glass lg-switch__thumb", "aria-hidden": "true", children: /* @__PURE__ */ jsx10("span", { ref: faceRef, className: "lg-switch__face" }) })
2441
+ /* @__PURE__ */ jsx11("span", { className: "lg-switch__track", "aria-hidden": "true" }),
2442
+ /* @__PURE__ */ jsx11("span", { ref: fillRef, className: "lg-switch__fill", "aria-hidden": "true" }),
2443
+ /* @__PURE__ */ jsx11("span", { ref: thumbRef, className: "lg-glass lg-switch__thumb", "aria-hidden": "true", children: /* @__PURE__ */ jsx11("span", { ref: faceRef, className: "lg-switch__face" }) })
2017
2444
  ]
2018
2445
  }
2019
2446
  );
@@ -2023,28 +2450,28 @@ GlassSwitch.displayName = "GlassSwitch";
2023
2450
 
2024
2451
  // src/filters/LiquidGlassFilter.tsx
2025
2452
  import { createContext, useContext } from "react";
2026
- import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
2453
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
2027
2454
  var GlassFilterContext = createContext(false);
2028
2455
  function LiquidGlassFilter({ children }) {
2029
- return /* @__PURE__ */ jsxs9(GlassFilterContext.Provider, { value: true, children: [
2030
- /* @__PURE__ */ jsx11(GlassFilterSVG, {}),
2456
+ return /* @__PURE__ */ jsxs10(GlassFilterContext.Provider, { value: true, children: [
2457
+ /* @__PURE__ */ jsx12(GlassFilterSVG, {}),
2031
2458
  children
2032
2459
  ] });
2033
2460
  }
2034
2461
  function GlassFilterSVG() {
2035
- return /* @__PURE__ */ jsx11(
2462
+ return /* @__PURE__ */ jsx12(
2036
2463
  "svg",
2037
2464
  {
2038
2465
  width: "0",
2039
2466
  height: "0",
2040
2467
  style: { position: "absolute", pointerEvents: "none" },
2041
2468
  "aria-hidden": "true",
2042
- children: /* @__PURE__ */ jsx11("defs", { children: Array.from({ length: 10 }, (_, i) => {
2469
+ children: /* @__PURE__ */ jsx12("defs", { children: Array.from({ length: 10 }, (_, i) => {
2043
2470
  const level = i + 1;
2044
2471
  const scale = level * 2;
2045
2472
  const freq1 = 0.012 + level * 1e-3;
2046
2473
  const freq2 = 0.01 + level * 8e-4;
2047
- return /* @__PURE__ */ jsxs9(
2474
+ return /* @__PURE__ */ jsxs10(
2048
2475
  "filter",
2049
2476
  {
2050
2477
  id: `liquid-glass-refract-${level}`,
@@ -2054,7 +2481,7 @@ function GlassFilterSVG() {
2054
2481
  height: "120%",
2055
2482
  colorInterpolationFilters: "sRGB",
2056
2483
  children: [
2057
- /* @__PURE__ */ jsx11(
2484
+ /* @__PURE__ */ jsx12(
2058
2485
  "feTurbulence",
2059
2486
  {
2060
2487
  type: "fractalNoise",
@@ -2064,7 +2491,7 @@ function GlassFilterSVG() {
2064
2491
  result: "noise"
2065
2492
  }
2066
2493
  ),
2067
- /* @__PURE__ */ jsx11(
2494
+ /* @__PURE__ */ jsx12(
2068
2495
  "feDisplacementMap",
2069
2496
  {
2070
2497
  in: "SourceGraphic",
@@ -2161,11 +2588,11 @@ function useGlassEffect(options = {}) {
2161
2588
  }
2162
2589
 
2163
2590
  // src/hooks/useGlassAnimation.ts
2164
- import { useCallback, useState as useState4 } from "react";
2591
+ import { useCallback, useState as useState5 } from "react";
2165
2592
  function useGlassAnimation() {
2166
- const [isHovered, setIsHovered] = useState4(false);
2167
- const [isPressed, setIsPressed] = useState4(false);
2168
- const [isFocused, setIsFocused] = useState4(false);
2593
+ const [isHovered, setIsHovered] = useState5(false);
2594
+ const [isPressed, setIsPressed] = useState5(false);
2595
+ const [isFocused, setIsFocused] = useState5(false);
2169
2596
  const handlers = {
2170
2597
  onPointerEnter: useCallback(() => setIsHovered(true), []),
2171
2598
  onPointerLeave: useCallback(() => {
@@ -2183,6 +2610,7 @@ export {
2183
2610
  GlassButton,
2184
2611
  GlassCard,
2185
2612
  GlassInput,
2613
+ GlassMenu,
2186
2614
  GlassNav,
2187
2615
  GlassSegmented,
2188
2616
  GlassSheet,