@zakisheriff/liquid-glass 0.2.6 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ __export(index_exports, {
34
34
  GlassButton: () => GlassButton,
35
35
  GlassCard: () => GlassCard,
36
36
  GlassInput: () => GlassInput,
37
+ GlassMenu: () => GlassMenu,
37
38
  GlassNav: () => GlassNav,
38
39
  GlassSegmented: () => GlassSegmented,
39
40
  GlassSheet: () => GlassSheet,
@@ -186,6 +187,37 @@ function rubberband(offset, dimension, constant = 0.55) {
186
187
  }
187
188
  var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
188
189
 
190
+ // src/engine/selection.ts
191
+ function guardSelection(el2) {
192
+ let held = false;
193
+ const block = (event) => {
194
+ if (held) event.preventDefault();
195
+ };
196
+ const clear = () => {
197
+ const selection = window.getSelection?.();
198
+ if (selection && !selection.isCollapsed) selection.removeAllRanges();
199
+ };
200
+ const down = () => {
201
+ held = true;
202
+ clear();
203
+ };
204
+ const up = () => {
205
+ if (!held) return;
206
+ held = false;
207
+ clear();
208
+ };
209
+ el2.addEventListener("pointerdown", down, true);
210
+ document.addEventListener("selectstart", block, true);
211
+ window.addEventListener("pointerup", up, true);
212
+ window.addEventListener("pointercancel", up, true);
213
+ return () => {
214
+ el2.removeEventListener("pointerdown", down, true);
215
+ document.removeEventListener("selectstart", block, true);
216
+ window.removeEventListener("pointerup", up, true);
217
+ window.removeEventListener("pointercancel", up, true);
218
+ };
219
+ }
220
+
189
221
  // src/engine/press.ts
190
222
  var FOLLOW = springFrom(0.2, 0.82);
191
223
  function usePress(ref, options = {}) {
@@ -215,18 +247,20 @@ function usePress(ref, options = {}) {
215
247
  };
216
248
  const track = (event) => {
217
249
  if (!pointer) return;
218
- const { box, base } = pointer;
250
+ const { box, base, w, h } = pointer;
219
251
  light(event, box);
220
252
  const dx = event.clientX - pointer.x;
221
253
  const dy = event.clientY - pointer.y;
222
- const tx = rubberband(dx, lean * 2.2, 0.5);
223
- const ty = rubberband(dy, lean * 2.2, 0.5);
224
254
  const dist = Math.hypot(dx, dy);
225
- const pull = 1 - 1 / (1 + dist / 55);
226
- const k = stretch * pull;
227
255
  const cx = dist ? (dx / dist) ** 2 : 0;
228
256
  const cy = dist ? (dy / dist) ** 2 : 0;
229
- to([base * (1 + k * cx - k * 0.5 * cy), base * (1 + k * cy - k * 0.5 * cx), tx, ty], FOLLOW);
257
+ const span = Math.min(w * cx + h * cy, 64);
258
+ const reach = rubberband(dist, span * stretch * 2, 0.55);
259
+ const ex = reach * cx / w;
260
+ const ey = reach * cy / h;
261
+ const tx = Math.sign(dx) * (reach * cx * base) / 2 + rubberband(dx, lean * 0.6, 0.4);
262
+ const ty = Math.sign(dy) * (reach * cy * base) / 2 + rubberband(dy, lean * 0.6, 0.4);
263
+ to([base * (1 + ex - ey * 0.35), base * (1 + ey - ex * 0.35), tx, ty], FOLLOW);
230
264
  };
231
265
  const move = (event) => {
232
266
  if (event.pointerId === pointer?.id) track(event);
@@ -249,7 +283,7 @@ function usePress(ref, options = {}) {
249
283
  const natural = Math.min(0.22, Math.max(0.07, 9 / Math.sqrt(w * h)));
250
284
  const amount = (grow ?? natural) * (event.pointerType === "mouse" ? 0.75 : 1);
251
285
  const base = 1 + amount;
252
- pointer = { id: event.pointerId, x: event.clientX, y: event.clientY, box, base };
286
+ pointer = { id: event.pointerId, x: event.clientX, y: event.clientY, box, base, w, h };
253
287
  el2.dataset.pressed = "";
254
288
  light(event, box);
255
289
  to([base, base, 0, 0], SPRINGS.press);
@@ -261,12 +295,14 @@ function usePress(ref, options = {}) {
261
295
  const hold = (event) => {
262
296
  if (pointer && event.cancelable) event.preventDefault();
263
297
  };
298
+ const unguard = guardSelection(el2);
264
299
  el2.addEventListener("touchmove", hold, { passive: false });
265
300
  el2.addEventListener("pointerdown", down);
266
301
  window.addEventListener("blur", blur);
267
302
  return () => {
268
303
  up();
269
304
  springs.forEach((s) => s.stop());
305
+ unguard();
270
306
  el2.removeEventListener("pointerdown", down);
271
307
  el2.removeEventListener("touchmove", hold);
272
308
  window.removeEventListener("blur", blur);
@@ -296,6 +332,7 @@ function clone(source) {
296
332
  });
297
333
  root.querySelectorAll(`[${SELF}], .lg-mirror, [data-lg-mirror-skip], input, textarea, select`).forEach((n) => n.remove());
298
334
  root.removeAttribute("data-mirror");
335
+ root.setAttribute("data-lg-copy", "");
299
336
  root.setAttribute("inert", "");
300
337
  root.setAttribute("aria-hidden", "true");
301
338
  return { root, pairs };
@@ -319,6 +356,7 @@ function backdropChain(glass, source) {
319
356
  }
320
357
  return chain;
321
358
  }
359
+ 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(" ");
322
360
  var BACKGROUND = ["background-color", "background-image", "background-size", "background-position", "background-repeat", "border-radius"];
323
361
  function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
324
362
  const layer = document.createElement("div");
@@ -402,6 +440,10 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
402
440
  root.style.margin = "0px";
403
441
  root.style.width = `${sw}px`;
404
442
  root.style.height = `${sh}px`;
443
+ root.style.maxWidth = "none";
444
+ root.style.maxHeight = "none";
445
+ root.style.minWidth = "0px";
446
+ root.style.minHeight = "0px";
405
447
  root.style.scale = "none";
406
448
  root.style.translate = "none";
407
449
  root.style.transformOrigin = "0 0";
@@ -424,10 +466,19 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
424
466
  pair.copy.className = cls;
425
467
  }
426
468
  }
469
+ const flags = stateOf(source);
470
+ if (flags !== copyFlags) {
471
+ const now = new Set(flags.split(" "));
472
+ for (const name of copyFlags.split(" ")) if (name && !now.has(name)) copy.root.removeAttribute(name);
473
+ for (const name of flags.split(" ")) if (name) copy.root.setAttribute(name, source.getAttribute(name) ?? "");
474
+ copyFlags = flags;
475
+ }
427
476
  };
477
+ let copyFlags = "";
428
478
  let zoomed = "";
429
479
  const applyZoom = () => {
430
- const value = `scale(${zoom()})`;
480
+ const z = zoom();
481
+ const value = Array.isArray(z) ? `scale(${z[0]}, ${z[1]})` : `scale(${z})`;
431
482
  if (value !== zoomed) zoomer.style.transform = zoomed = value;
432
483
  };
433
484
  const tick = () => {
@@ -453,6 +504,7 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
453
504
  const next = clone(source);
454
505
  copy.root.replaceWith(next.root);
455
506
  copy = next;
507
+ copyFlags = "";
456
508
  placed = "";
457
509
  buildUnder();
458
510
  align();
@@ -540,10 +592,17 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
540
592
  const rimA = new Float32Array(cw * ch);
541
593
  const rimHue = new Float32Array(cw * ch);
542
594
  const inside = new Float32Array(cw * ch);
595
+ const zone = new Float32Array(cw * ch);
543
596
  let max = 1e-4;
544
597
  const hw = width / 2;
545
598
  const hh = height / 2;
546
599
  const px1 = 1 / density;
600
+ const edge = hh - shape.inset;
601
+ const band = (py) => {
602
+ if (!shape.inset) return 1;
603
+ const t = clamp((Math.abs(py) - (edge - 2)) / 3, 0, 1);
604
+ return 1 - t * t * (3 - 2 * t);
605
+ };
547
606
  for (let y = 0; y < ch; y++) {
548
607
  for (let x = 0; x < cw; x++) {
549
608
  const px = (x + 0.5) * W / cw - W / 2;
@@ -567,18 +626,19 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
567
626
  ny = Math.sign(py);
568
627
  }
569
628
  const i = y * cw + x;
570
- const s = shift(d) * shape.strength * direction;
629
+ const s = shift(d) * shape.strength * direction * band(py);
571
630
  let vx = nx * s;
572
631
  let vy = ny * s;
573
632
  if (simple && magnify) {
574
- vx -= px * magnify;
575
- vy -= py * magnify;
633
+ vx -= px * magnify * band(py);
634
+ vy -= py * magnify * band(py);
576
635
  }
577
636
  dx[i] = vx;
578
637
  dy[i] = vy;
579
638
  const m = Math.max(Math.abs(vx), Math.abs(vy));
580
639
  if (m > max) max = m;
581
640
  inside[i] = clamp(d / px1 + 0.5, 0, 1);
641
+ zone[i] = (d <= 0 ? 1 : clamp(1 - d / Math.max(1, shape.bezel), 0, 1) ** 1.3) * band(py);
582
642
  if (d >= -px1) {
583
643
  const facing = -(nx + ny) * Math.SQRT1_2;
584
644
  const light = 0.22 + 0.78 * Math.abs(facing) ** 2.2 * (facing > 0 ? 1 : 0.62);
@@ -613,8 +673,9 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
613
673
  const o = (y * cw + x) * 4;
614
674
  const px = (x + 0.5) * W / cw - W / 2;
615
675
  const py = (y + 0.5) * H / ch - H / 2;
616
- ramp.data[o] = Math.round(127.5 - px / reach * 127.5);
617
- ramp.data[o + 1] = Math.round(127.5 - py / reach * 127.5);
676
+ const k = band(py);
677
+ ramp.data[o] = Math.round(127.5 - px / reach * 127.5 * k);
678
+ ramp.data[o + 1] = Math.round(127.5 - py / reach * 127.5 * k);
618
679
  ramp.data[o + 2] = 128;
619
680
  ramp.data[o + 3] = 255;
620
681
  }
@@ -650,6 +711,17 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
650
711
  }
651
712
  ctx.putImageData(shapeMask, 0, 0);
652
713
  const mask = canvas.toDataURL();
714
+ let smooth = "";
715
+ if (lens && !simple) {
716
+ const soft = ctx.createImageData(cw, ch);
717
+ for (let i = 0; i < cw * ch; i++) {
718
+ const o = i * 4;
719
+ soft.data[o] = soft.data[o + 1] = soft.data[o + 2] = 255;
720
+ soft.data[o + 3] = Math.round(zone[i] * 255);
721
+ }
722
+ ctx.putImageData(soft, 0, 0);
723
+ smooth = canvas.toDataURL();
724
+ }
653
725
  const id = `lg-refract-${++counter}`;
654
726
  const box = { x: 0, y: 0, width: W, height: H };
655
727
  const filter = el("filter", {
@@ -714,9 +786,20 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
714
786
  })
715
787
  );
716
788
  }
789
+ let out = "bent";
790
+ if (smooth) {
791
+ filter.append(
792
+ el("feGaussianBlur", { in: "bent", stdDeviation: 0.65, result: "bent-soft" }),
793
+ el("feImage", { href: smooth, ...box, preserveAspectRatio: "none", result: "rim-zone" }),
794
+ el("feComposite", { in: "bent-soft", in2: "rim-zone", operator: "in", result: "rim-soft" }),
795
+ el("feComposite", { in: "bent", in2: "rim-zone", operator: "out", result: "core" }),
796
+ el("feComposite", { in: "rim-soft", in2: "core", operator: "arithmetic", k2: 1, k3: 1, result: "smoothed" })
797
+ );
798
+ out = "smoothed";
799
+ }
717
800
  filter.append(
718
801
  el("feImage", { href: mask, ...box, preserveAspectRatio: "none", result: "shape" }),
719
- el("feComposite", { in: "bent", in2: "shape", operator: "in" })
802
+ el("feComposite", { in: out, in2: "shape", operator: "in" })
720
803
  );
721
804
  container().append(filter);
722
805
  return { filter: `url(#${id})`, rim: `url("${rim}")`, inner: `url("${mask}")` };
@@ -731,8 +814,11 @@ function resolve(shape, width, height) {
731
814
  thickness: shape.thickness ?? (lens ? short * 0.55 : clamp(short * 0.32, 8, 26)),
732
815
  ior: shape.ior ?? 1.5,
733
816
  zoom: shape.zoom ?? (lens ? 1.16 : 1),
817
+ zoomX: shape.zoomX ?? shape.zoom ?? (lens ? 1.16 : 1),
734
818
  dispersion: shape.dispersion ?? (lens ? 1 : 0),
735
- strength: shape.strength ?? 1
819
+ strength: shape.strength ?? 1,
820
+ inset: shape.inset ?? 0,
821
+ copy: shape.copy ?? false
736
822
  };
737
823
  }
738
824
  function glassFor(width, height, radius, shape = {}, pad = 0, simple = false) {
@@ -740,7 +826,7 @@ function glassFor(width, height, radius, shape = {}, pad = 0, simple = false) {
740
826
  const h = Math.round(height);
741
827
  const r = Math.min(w / 2, h / 2, Math.max(0, radius));
742
828
  const full = resolve(shape, w, h);
743
- 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("|");
829
+ 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("|");
744
830
  let baked = cache.get(key);
745
831
  if (!baked) {
746
832
  baked = bake(w, h, r, full, pad, simple);
@@ -767,11 +853,18 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
767
853
  (0, import_react2.useEffect)(() => {
768
854
  const element = ref.current;
769
855
  if (!element || !enabled) return;
770
- const live = canRefractBackdrop();
856
+ const live = canRefractBackdrop() && !(shape.copy && mirror);
771
857
  let cancel;
772
858
  let filter = "";
773
859
  let pad = 0;
774
860
  let zoom = 1;
861
+ let zoomX = 1;
862
+ const bendCopy = shape.copy === "refract" && canRefractBackdrop() && !!mirror;
863
+ let copyFilter = "";
864
+ const applyCopyFilter = () => {
865
+ const viewport = element.querySelector(":scope > .lg-mirror > .lg-mirror__viewport");
866
+ if (viewport && copyFilter) viewport.style.filter = copyFilter;
867
+ };
775
868
  const fit = () => {
776
869
  const width = element.offsetWidth;
777
870
  const height = element.offsetHeight;
@@ -781,10 +874,17 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
781
874
  filter = baked.filter;
782
875
  if (!live && mirror?.current) {
783
876
  pad = Math.ceil(Math.min(width, height) * 0.45 + 6);
784
- zoom = resolve(shape, width, height).zoom;
877
+ ({ zoom, zoomX } = resolve(shape, width, height));
785
878
  element.style.setProperty("--lg-inner-mask", baked.inner);
879
+ if (bendCopy) {
880
+ copyFilter = glassFor(width, height, radius, { ...shape, zoom: 1, zoomX: 1, dispersion: 0 }, pad).filter;
881
+ applyCopyFilter();
882
+ }
883
+ }
884
+ if (live) {
885
+ element.style.setProperty("--lg-filter", baked.filter);
886
+ element.setAttribute("data-lg-refract", "");
786
887
  }
787
- if (live) element.style.setProperty("--lg-filter", baked.filter);
788
888
  element.style.setProperty("--lg-rim", baked.rim);
789
889
  };
790
890
  const observer = new ResizeObserver(() => {
@@ -794,13 +894,15 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
794
894
  observer.observe(element);
795
895
  fit();
796
896
  const source = mirror?.current;
797
- const unmirror = !live && source ? mirrorBackdrop(element, source, () => pad, () => zoom, mirrorActive) : void 0;
897
+ const unmirror = !live && source ? mirrorBackdrop(element, source, () => pad, () => [zoomX, zoom], mirrorActive) : void 0;
898
+ applyCopyFilter();
798
899
  return () => {
799
900
  cancel?.();
800
901
  unmirror?.();
801
902
  observer.disconnect();
802
903
  element.style.removeProperty("--lg-filter");
803
904
  element.style.removeProperty("--lg-rim");
905
+ element.removeAttribute("data-lg-refract");
804
906
  };
805
907
  }, [ref, signature, enabled, mirror]);
806
908
  }
@@ -1024,105 +1126,138 @@ var import_react_dom = require("react-dom");
1024
1126
  var import_jsx_runtime5 = require("react/jsx-runtime");
1025
1127
  var OPEN = springFrom(0.42, 0.86);
1026
1128
  var CLOSE = springFrom(0.34, 1);
1027
- var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label": ariaLabel }) => {
1129
+ var SNAP = springFrom(0.4, 0.84);
1130
+ var GlassSheet = ({ open, onClose, intensity = 5, tint, container: container2, detents, children, "aria-label": ariaLabel }) => {
1028
1131
  const [mounted, setMounted] = (0, import_react6.useState)(open);
1029
1132
  const sheetRef = (0, import_react6.useRef)(null);
1030
1133
  const scrimRef = (0, import_react6.useRef)(null);
1031
- const progress = (0, import_react6.useRef)(null);
1134
+ const api = (0, import_react6.useRef)(null);
1135
+ const stopsKey = detents?.join(",") ?? "";
1032
1136
  const closeRef = (0, import_react6.useRef)(onClose);
1033
1137
  closeRef.current = onClose;
1034
1138
  (0, import_react6.useEffect)(() => {
1035
1139
  if (open) setMounted(true);
1036
- else progress.current?.set(0);
1140
+ else api.current?.close();
1037
1141
  }, [open]);
1038
1142
  useRefraction(sheetRef, { kind: "surface", strength: Math.max(1, Math.min(10, intensity)) / 5, bezel: 20, thickness: 28 }, mounted);
1039
1143
  (0, import_react6.useEffect)(() => {
1040
1144
  if (!mounted) return;
1041
1145
  const sheet = sheetRef.current;
1042
1146
  const scrim = scrimRef.current;
1043
- let height = sheet.offsetHeight || 400;
1044
- let drag = 0;
1045
- const paint = (p) => {
1046
- const y = (1 - p) * (height + 24) + drag;
1147
+ const layer = sheet.parentElement;
1148
+ const wanted = stopsKey ? stopsKey.split(",") : [];
1149
+ let height = 0;
1150
+ let hidden = 0;
1151
+ let stops = [0];
1152
+ let rest = 0;
1153
+ let medium = 0;
1154
+ const measure = () => {
1155
+ height = sheet.offsetHeight || 400;
1156
+ hidden = height + 24;
1157
+ medium = Math.max(0, height - layer.clientHeight * 0.5);
1158
+ stops = wanted.length ? wanted.map((d) => d === "large" ? 0 : medium).sort((x, y) => x - y) : [0];
1159
+ rest = wanted.includes("medium") ? medium : stops[0];
1160
+ };
1161
+ measure();
1162
+ const paint = (y) => {
1047
1163
  sheet.style.transform = `translateY(${y}px)`;
1048
- scrim.style.opacity = String(clamp(p, 0, 1) * clamp(1 - drag / height, 0, 1));
1164
+ const dim = wanted.includes("medium") && medium > 0 ? clamp(1 - y / medium, 0, 1) : clamp(1 - y / Math.max(1, height), 0, 1);
1165
+ scrim.style.opacity = String(dim);
1166
+ const raised = y <= 1;
1167
+ if (wanted.length && sheet.hasAttribute("data-raised") !== raised) sheet.toggleAttribute("data-raised", raised);
1049
1168
  };
1050
- const spring = createSpring(0, OPEN, (p) => {
1051
- paint(p);
1052
- if (p <= 1e-3 && spring.target === 0) setMounted(false);
1169
+ let closing = false;
1170
+ const position = createSpring(hidden, OPEN, (y) => {
1171
+ paint(y);
1172
+ if (closing && y >= hidden - 1) setMounted(false);
1053
1173
  });
1054
- progress.current = {
1055
- ...spring,
1056
- set(target, instant) {
1057
- spring.tune(target ? OPEN : CLOSE);
1058
- spring.set(target, instant);
1174
+ const go = (y, feel) => {
1175
+ position.tune(feel);
1176
+ position.set(y);
1177
+ };
1178
+ api.current = {
1179
+ close() {
1180
+ closing = true;
1181
+ go(hidden, CLOSE);
1059
1182
  }
1060
1183
  };
1061
- paint(0);
1184
+ paint(hidden);
1062
1185
  requestAnimationFrame(() => {
1063
- height = sheet.offsetHeight || height;
1064
- if (open) progress.current?.set(1);
1186
+ measure();
1187
+ position.set(hidden, true);
1188
+ if (open) go(rest, OPEN);
1065
1189
  });
1066
1190
  let gesture = null;
1067
1191
  const down = (event) => {
1192
+ if (event.defaultPrevented || closing) return;
1068
1193
  const target = event.target;
1069
- if (!target.closest(".lg-sheet__grabber-zone") && sheet.scrollTop > 0) return;
1194
+ const raised = position.value <= 1;
1195
+ if (raised && !target.closest(".lg-sheet__grabber-zone") && sheet.scrollTop > 0) return;
1070
1196
  if (target.closest('input, textarea, button, a, [role="slider"], [role="switch"]')) return;
1071
- gesture = { id: event.pointerId, y: event.clientY, t: event.timeStamp, v: 0 };
1197
+ position.stop();
1198
+ gesture = { id: event.pointerId, y: event.clientY, from: position.value, t: event.timeStamp, v: 0, last: position.value };
1072
1199
  sheet.setPointerCapture(event.pointerId);
1073
1200
  };
1074
1201
  const move = (event) => {
1075
1202
  if (event.pointerId !== gesture?.id) return;
1076
- const dy = event.clientY - gesture.y;
1203
+ const raw = gesture.from + event.clientY - gesture.y;
1204
+ const y = raw < 0 ? rubberband(raw, height, 0.3) : raw;
1077
1205
  const dt = Math.max(1, event.timeStamp - gesture.t);
1078
- gesture.v = (dy - drag) / dt;
1206
+ gesture.v = gesture.v * 0.2 + (y - gesture.last) / dt * 0.8;
1079
1207
  gesture.t = event.timeStamp;
1080
- drag = dy > 0 ? dy : rubberband(dy, height, 0.3);
1081
- paint(spring.value);
1208
+ gesture.last = y;
1209
+ position.set(y, true);
1210
+ paint(y);
1082
1211
  };
1083
1212
  const up = (event) => {
1084
1213
  if (event.pointerId !== gesture?.id) return;
1085
- const flick = gesture.v > 0.6;
1214
+ const { v, last: last2 } = gesture;
1086
1215
  gesture = null;
1087
- const settle = createSpring(drag, SPRINGS.snap, (value) => {
1088
- drag = value;
1089
- paint(spring.value);
1090
- });
1091
- if (flick || drag > height * 0.3) {
1092
- settle.stop();
1093
- const p = 1 - clamp(drag / (height + 24), 0, 1);
1094
- drag = 0;
1095
- spring.set(p, true);
1216
+ const projected = last2 + v * 180;
1217
+ const lowest = stops[stops.length - 1];
1218
+ if (projected > lowest + (hidden - lowest) * 0.45 || v > 0.9 && last2 >= lowest - 4) {
1219
+ closing = true;
1220
+ go(hidden, CLOSE);
1096
1221
  closeRef.current?.();
1097
- } else {
1098
- settle.set(0);
1222
+ return;
1099
1223
  }
1224
+ const target = stops.reduce((best, stop) => Math.abs(stop - projected) < Math.abs(best - projected) ? stop : best, stops[0]);
1225
+ go(target, SNAP);
1100
1226
  };
1101
1227
  const key = (event) => {
1102
1228
  if (event.key === "Escape") closeRef.current?.();
1103
1229
  };
1230
+ const resize = () => {
1231
+ const at = position.target;
1232
+ const was = stops.indexOf(at);
1233
+ measure();
1234
+ if (!closing) go(was >= 0 ? stops[Math.min(was, stops.length - 1)] : rest, SNAP);
1235
+ };
1236
+ const observer = new ResizeObserver(resize);
1237
+ observer.observe(layer);
1104
1238
  sheet.addEventListener("pointerdown", down);
1105
1239
  sheet.addEventListener("pointermove", move);
1106
1240
  sheet.addEventListener("pointerup", up);
1107
1241
  sheet.addEventListener("pointercancel", up);
1108
1242
  window.addEventListener("keydown", key);
1109
1243
  const overflow = document.body.style.overflow;
1110
- document.body.style.overflow = "hidden";
1244
+ if (!container2) document.body.style.overflow = "hidden";
1111
1245
  sheet.focus({ preventScroll: true });
1112
1246
  return () => {
1113
- spring.stop();
1114
- progress.current = null;
1247
+ position.stop();
1248
+ api.current = null;
1249
+ observer.disconnect();
1115
1250
  sheet.removeEventListener("pointerdown", down);
1116
1251
  sheet.removeEventListener("pointermove", move);
1117
1252
  sheet.removeEventListener("pointerup", up);
1118
1253
  sheet.removeEventListener("pointercancel", up);
1119
1254
  window.removeEventListener("keydown", key);
1120
- document.body.style.overflow = overflow;
1255
+ if (!container2) document.body.style.overflow = overflow;
1121
1256
  };
1122
- }, [mounted]);
1257
+ }, [mounted, container2, stopsKey]);
1123
1258
  if (!mounted || typeof document === "undefined") return null;
1124
1259
  return (0, import_react_dom.createPortal)(
1125
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "lg-sheet-layer", "data-liquid-glass": "", children: [
1260
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "lg-sheet-layer", "data-liquid-glass": "", style: container2 ? { position: "absolute" } : void 0, children: [
1126
1261
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: scrimRef, className: "lg-sheet__scrim", onClick: () => onClose?.(), "aria-hidden": "true" }),
1127
1262
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1128
1263
  "div",
@@ -1132,7 +1267,7 @@ var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label":
1132
1267
  "aria-modal": "true",
1133
1268
  "aria-label": ariaLabel,
1134
1269
  tabIndex: -1,
1135
- className: "lg-glass lg-glass--host lg-sheet",
1270
+ className: ["lg-glass", "lg-glass--host", "lg-sheet", detents?.length ? "lg-sheet--detents" : ""].filter(Boolean).join(" "),
1136
1271
  style: tint ? { "--lg-host-tint": tint } : void 0,
1137
1272
  children: [
1138
1273
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-sheet__grabber-zone", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lg-sheet__grabber" }) }),
@@ -1141,24 +1276,263 @@ var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label":
1141
1276
  }
1142
1277
  )
1143
1278
  ] }),
1144
- document.body
1279
+ container2 ?? document.body
1145
1280
  );
1146
1281
  };
1147
1282
  GlassSheet.displayName = "GlassSheet";
1148
1283
 
1284
+ // src/components/GlassMenu/GlassMenu.tsx
1285
+ var import_react7 = require("react");
1286
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1287
+ var OPEN2 = springFrom(0.36, 0.74);
1288
+ var CLOSE2 = springFrom(0.34, 0.9);
1289
+ var FADE = springFrom(0.24, 1);
1290
+ var FADE_OUT = springFrom(0.14, 1);
1291
+ var JELLY = springFrom(0.42, 0.4);
1292
+ var Tick = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M3.5 8.5l3 3 6-7", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) });
1293
+ var GlassMenu = ({
1294
+ icon,
1295
+ items,
1296
+ "aria-label": ariaLabel,
1297
+ align = "end",
1298
+ size = "md",
1299
+ width = 230,
1300
+ check,
1301
+ className
1302
+ }) => {
1303
+ const [open, setOpen] = (0, import_react7.useState)(false);
1304
+ const [mounted, setMounted] = (0, import_react7.useState)(false);
1305
+ const anchorRef = (0, import_react7.useRef)(null);
1306
+ const triggerRef = (0, import_react7.useRef)(null);
1307
+ const surfaceRef = (0, import_react7.useRef)(null);
1308
+ const panelRef = (0, import_react7.useRef)(null);
1309
+ const contentRef = (0, import_react7.useRef)(null);
1310
+ const spring = (0, import_react7.useRef)(null);
1311
+ const itemsRef = (0, import_react7.useRef)(items);
1312
+ itemsRef.current = items;
1313
+ usePress(surfaceRef, { grow: 0.035, lean: 6, stretch: 0.1, disabled: !mounted });
1314
+ (0, import_react7.useEffect)(() => {
1315
+ if (open) setMounted(true);
1316
+ else if (spring.current) {
1317
+ spring.current.tune(CLOSE2);
1318
+ spring.current.set(0);
1319
+ }
1320
+ }, [open]);
1321
+ (0, import_react7.useLayoutEffect)(() => {
1322
+ if (!mounted) return;
1323
+ const surface = surfaceRef.current;
1324
+ const panel = panelRef.current;
1325
+ const content = contentRef.current;
1326
+ const trigger = triggerRef.current;
1327
+ const w = trigger.offsetWidth;
1328
+ const h = trigger.offsetHeight;
1329
+ const W = Math.max(w, Math.min(width, window.innerWidth - 24));
1330
+ content.style.width = `${W}px`;
1331
+ const H = Math.max(h, content.offsetHeight);
1332
+ surface.style.width = `${W}px`;
1333
+ surface.style.height = `${H}px`;
1334
+ const end = align === "end";
1335
+ const box = { cw: w, ch: h, r: h / 2 };
1336
+ let scaleNow = 1;
1337
+ const clipContent = () => {
1338
+ const k = scaleNow;
1339
+ const right = Math.max(0, W - box.cw / k);
1340
+ const bottom = Math.max(0, H - box.ch / k);
1341
+ 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)`;
1342
+ };
1343
+ const shape = (p) => {
1344
+ const cw = Math.max(1, w + (W - w) * p);
1345
+ const ch = Math.max(1, h + (H - h) * p);
1346
+ const sx = cw / W;
1347
+ const sy = ch / H;
1348
+ panel.style.transform = `scale(${sx}, ${sy})`;
1349
+ const land = clamp((p - 0.5) / 0.5, 0, 1);
1350
+ const r = Math.min(cw, ch) / 2 * (1 - land) + 24 * land;
1351
+ panel.style.borderRadius = `${r / sx}px / ${r / sy}px`;
1352
+ box.cw = cw;
1353
+ box.ch = ch;
1354
+ box.r = r;
1355
+ clipContent();
1356
+ const k = clamp(p / 0.35, 0, 1);
1357
+ panel.style.opacity = String(k);
1358
+ trigger.style.opacity = String(1 - k);
1359
+ };
1360
+ const reveal = (q) => {
1361
+ const t = clamp(q, 0, 1);
1362
+ const blur = 9 * (1 - t) ** 2.5;
1363
+ content.style.opacity = String(t);
1364
+ scaleNow = t < 0.999 ? 0.82 + 0.18 * t : 1;
1365
+ content.style.scale = scaleNow === 1 ? "" : String(scaleNow);
1366
+ clipContent();
1367
+ content.style.filter = blur > 0.05 ? `blur(${blur.toFixed(2)}px)` : "none";
1368
+ };
1369
+ shape(0);
1370
+ reveal(0);
1371
+ const s = createSpring(0, OPEN2, (p) => {
1372
+ shape(p);
1373
+ if (p <= 0.02 && s.target === 0) {
1374
+ trigger.style.opacity = "";
1375
+ const jelly = createSpring(0.07, JELLY, (v) => {
1376
+ trigger.style.scale = Math.abs(v) < 5e-4 ? "" : `${1 - v} ${1 + v}`;
1377
+ });
1378
+ jelly.set(0);
1379
+ setMounted(false);
1380
+ }
1381
+ });
1382
+ const fade = createSpring(0, FADE, reveal);
1383
+ spring.current = {
1384
+ ...s,
1385
+ tune: s.tune,
1386
+ set(target, instant) {
1387
+ fade.tune(target ? FADE : FADE_OUT);
1388
+ fade.set(target, instant);
1389
+ s.set(target, instant);
1390
+ }
1391
+ };
1392
+ spring.current.set(1);
1393
+ content.querySelector('[role="menuitem"]:not([disabled])')?.focus({ preventScroll: true });
1394
+ return () => {
1395
+ s.stop();
1396
+ fade.stop();
1397
+ spring.current = null;
1398
+ trigger.style.opacity = "";
1399
+ };
1400
+ }, [mounted]);
1401
+ (0, import_react7.useEffect)(() => {
1402
+ if (!mounted) return;
1403
+ const panel = surfaceRef.current;
1404
+ let held = null;
1405
+ let hot = null;
1406
+ const itemAt = (x, y) => document.elementFromPoint(x, y)?.closest(".lg-menu__item:not(:disabled)") ?? null;
1407
+ const light = (next) => {
1408
+ if (next === hot) return;
1409
+ hot?.removeAttribute("data-active");
1410
+ hot = next;
1411
+ if (hot) {
1412
+ hot.setAttribute("data-active", "");
1413
+ haptic();
1414
+ }
1415
+ };
1416
+ const down = (event) => {
1417
+ if (!event.isPrimary || event.button !== 0) return;
1418
+ held = event.pointerId;
1419
+ hot = null;
1420
+ light(itemAt(event.clientX, event.clientY));
1421
+ };
1422
+ const move = (event) => {
1423
+ if (event.pointerId === held) light(itemAt(event.clientX, event.clientY));
1424
+ };
1425
+ const up = (event) => {
1426
+ if (event.pointerId !== held) return;
1427
+ held = null;
1428
+ const target = hot;
1429
+ light(null);
1430
+ const index = target ? Number(target.dataset.index) : -1;
1431
+ const item = itemsRef.current[index];
1432
+ if (item && !item.disabled) {
1433
+ event.preventDefault();
1434
+ haptic();
1435
+ item.onSelect?.();
1436
+ setOpen(false);
1437
+ }
1438
+ };
1439
+ const cancel = (event) => {
1440
+ if (event.pointerId !== held) return;
1441
+ held = null;
1442
+ light(null);
1443
+ };
1444
+ const hold = (event) => {
1445
+ if (held !== null && event.cancelable) event.preventDefault();
1446
+ };
1447
+ panel.addEventListener("pointerdown", down);
1448
+ window.addEventListener("pointermove", move);
1449
+ window.addEventListener("pointerup", up);
1450
+ window.addEventListener("pointercancel", cancel);
1451
+ panel.addEventListener("touchmove", hold, { passive: false });
1452
+ return () => {
1453
+ panel.removeEventListener("pointerdown", down);
1454
+ window.removeEventListener("pointermove", move);
1455
+ window.removeEventListener("pointerup", up);
1456
+ window.removeEventListener("pointercancel", cancel);
1457
+ panel.removeEventListener("touchmove", hold);
1458
+ };
1459
+ }, [mounted]);
1460
+ (0, import_react7.useEffect)(() => {
1461
+ if (!open) return;
1462
+ const outside = (event) => {
1463
+ if (!anchorRef.current?.contains(event.target)) setOpen(false);
1464
+ };
1465
+ const key = (event) => {
1466
+ if (event.key === "Escape") {
1467
+ setOpen(false);
1468
+ triggerRef.current?.focus({ preventScroll: true });
1469
+ }
1470
+ };
1471
+ document.addEventListener("pointerdown", outside, true);
1472
+ window.addEventListener("keydown", key);
1473
+ return () => {
1474
+ document.removeEventListener("pointerdown", outside, true);
1475
+ window.removeEventListener("keydown", key);
1476
+ };
1477
+ }, [open]);
1478
+ const select = (item) => {
1479
+ haptic();
1480
+ item.onSelect?.();
1481
+ setOpen(false);
1482
+ };
1483
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { ref: anchorRef, className: ["lg-menu-anchor", className].filter(Boolean).join(" "), "data-align": align, children: [
1484
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1485
+ GlassButton,
1486
+ {
1487
+ ref: triggerRef,
1488
+ size,
1489
+ icon,
1490
+ "aria-label": ariaLabel,
1491
+ "aria-haspopup": "menu",
1492
+ "aria-expanded": open,
1493
+ onClick: () => setOpen((value) => !value)
1494
+ }
1495
+ ),
1496
+ mounted && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: surfaceRef, className: "lg-menu-surface", children: [
1497
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: panelRef, className: "lg-glass lg-menu", "data-liquid-glass": "", "aria-hidden": "true" }),
1498
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: contentRef, className: "lg-menu__content", role: "menu", "aria-label": ariaLabel, children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1499
+ "button",
1500
+ {
1501
+ type: "button",
1502
+ role: "menuitem",
1503
+ className: "lg-menu__item",
1504
+ "data-destructive": item.destructive ? "" : void 0,
1505
+ "data-index": index,
1506
+ disabled: item.disabled,
1507
+ onClick: (event) => {
1508
+ if (event.detail === 0) select(item);
1509
+ },
1510
+ children: [
1511
+ item.icon != null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-menu__icon", children: item.icon }),
1512
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-menu__label", children: item.label }),
1513
+ item.checked && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-menu__check", children: check ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tick, {}) })
1514
+ ]
1515
+ },
1516
+ index
1517
+ )) })
1518
+ ] })
1519
+ ] });
1520
+ };
1521
+ GlassMenu.displayName = "GlassMenu";
1522
+
1149
1523
  // src/components/GlassNav/GlassNav.tsx
1150
- var import_react9 = __toESM(require("react"));
1524
+ var import_react10 = __toESM(require("react"));
1151
1525
 
1152
1526
  // src/components/internal/LensTrack.tsx
1153
- var import_react8 = require("react");
1527
+ var import_react9 = require("react");
1154
1528
 
1155
1529
  // src/engine/lensTrack.ts
1156
- var import_react7 = require("react");
1530
+ var import_react8 = require("react");
1157
1531
  function useLensTrack(refs, options) {
1158
- const latest = (0, import_react7.useRef)(options);
1532
+ const latest = (0, import_react8.useRef)(options);
1159
1533
  latest.current = options;
1160
- const api = (0, import_react7.useRef)(null);
1161
- (0, import_react7.useEffect)(() => {
1534
+ const api = (0, import_react8.useRef)(null);
1535
+ (0, import_react8.useEffect)(() => {
1162
1536
  const bar = refs.bar.current;
1163
1537
  const lens = refs.lens.current;
1164
1538
  const glass = refs.glass.current;
@@ -1175,7 +1549,7 @@ function useLensTrack(refs, options) {
1175
1549
  let gesture = null;
1176
1550
  let dropTimer = 0;
1177
1551
  let suppressClick = false;
1178
- const buttons = Array.from(bar.querySelectorAll("[data-lg-item]"));
1552
+ const buttons = Array.from(bar.querySelectorAll(":scope > [data-lg-item]"));
1179
1553
  let glyphs = [];
1180
1554
  const preview = (index) => {
1181
1555
  if (index === void 0) delete bar.dataset.previewing;
@@ -1198,14 +1572,23 @@ function useLensTrack(refs, options) {
1198
1572
  select.style.width = `${slot}px`;
1199
1573
  select.style.left = `${pad}px`;
1200
1574
  glyphs = buttons.flatMap(
1201
- (button) => Array.from(button.querySelectorAll(".lg-nav__label, .lg-nav__icon > .lg-symbol")).map((node) => ({
1202
- node,
1203
- x: button.offsetLeft + node.offsetLeft - pad,
1204
- y: node.offsetTop,
1205
- width: node.offsetWidth,
1206
- height: node.offsetHeight,
1207
- label: node.classList.contains("lg-nav__label")
1208
- }))
1575
+ (button) => Array.from(button.querySelectorAll(".lg-nav__label, .lg-nav__icon > .lg-symbol")).map((node) => {
1576
+ const label2 = node.classList.contains("lg-nav__label");
1577
+ const host = label2 ? node : node.parentElement;
1578
+ const n = node.getBoundingClientRect();
1579
+ const h = host.getBoundingClientRect();
1580
+ return {
1581
+ node,
1582
+ x: button.offsetLeft + node.offsetLeft - pad,
1583
+ y: node.offsetTop,
1584
+ width: node.offsetWidth,
1585
+ height: node.offsetHeight,
1586
+ label: label2,
1587
+ host,
1588
+ dx: n.left - h.left,
1589
+ dy: n.top - h.top
1590
+ };
1591
+ })
1209
1592
  );
1210
1593
  };
1211
1594
  const paint = () => {
@@ -1227,8 +1610,24 @@ function useLensTrack(refs, options) {
1227
1610
  if (lift2 <= 0.02 && !gesture) {
1228
1611
  glyph.node.style.removeProperty("--lg-content-tint");
1229
1612
  glyph.node.style.removeProperty("transform");
1613
+ glyph.host.style.removeProperty("--lg-content-hide");
1230
1614
  continue;
1231
1615
  }
1616
+ if (latest.current.copied) {
1617
+ const hy = H * ky / 2;
1618
+ const hx = H * kx / 2;
1619
+ const run = Math.max(0, (W - H) * kx / 2);
1620
+ const ccx = x2 + slot / 2 - glyph.x + glyph.dx;
1621
+ const ccy = height / 2 - glyph.y + glyph.dy;
1622
+ const fade = clamp(lift2 * 3, 0, 1);
1623
+ const solid = `rgb(0 0 0 / ${fade})`;
1624
+ glyph.host.style.setProperty("--lg-content-hide", [
1625
+ "linear-gradient(#000, #000)",
1626
+ `radial-gradient(ellipse ${hx}px ${hy}px at ${ccx - run}px ${ccy}px, ${solid} calc(100% - 1px), transparent 100%)`,
1627
+ `radial-gradient(ellipse ${hx}px ${hy}px at ${ccx + run}px ${ccy}px, ${solid} calc(100% - 1px), transparent 100%)`,
1628
+ `linear-gradient(${solid}, ${solid}) ${ccx - run}px ${ccy - hy}px / ${run * 2}px ${hy * 2}px no-repeat`
1629
+ ].join(", "));
1630
+ }
1232
1631
  const zoom = latest.current.contentZoom ?? 1;
1233
1632
  const ry = H * ky / (2 * zoom);
1234
1633
  const rx = H * kx / (2 * zoom);
@@ -1421,6 +1820,7 @@ function useLensTrack(refs, options) {
1421
1820
  x.set(current * slot, true);
1422
1821
  bar.dataset.ready = "";
1423
1822
  observer.observe(bar);
1823
+ const unguard = guardSelection(bar);
1424
1824
  bar.addEventListener("pointerdown", onDown);
1425
1825
  window.addEventListener("pointermove", onMove);
1426
1826
  window.addEventListener("pointerup", onUp);
@@ -1434,6 +1834,7 @@ function useLensTrack(refs, options) {
1434
1834
  clearTimeout(dropTimer);
1435
1835
  api.current = null;
1436
1836
  [x, lift, swell].forEach((s) => s.stop());
1837
+ unguard();
1437
1838
  observer.disconnect();
1438
1839
  bar.removeEventListener("pointerdown", onDown);
1439
1840
  window.removeEventListener("pointermove", onMove);
@@ -1446,19 +1847,20 @@ function useLensTrack(refs, options) {
1446
1847
  delete bar.dataset.ready;
1447
1848
  delete bar.dataset.lifted;
1448
1849
  preview();
1449
- glyphs.forEach(({ node }) => {
1850
+ glyphs.forEach(({ node, host }) => {
1450
1851
  node.style.removeProperty("--lg-content-tint");
1451
1852
  node.style.removeProperty("transform");
1853
+ host.style.removeProperty("--lg-content-hide");
1452
1854
  });
1453
1855
  };
1454
1856
  }, [options.count]);
1455
- (0, import_react7.useEffect)(() => {
1857
+ (0, import_react8.useEffect)(() => {
1456
1858
  api.current?.setIndex(options.index);
1457
1859
  }, [options.index]);
1458
1860
  }
1459
1861
 
1460
1862
  // src/components/internal/LensTrack.tsx
1461
- var import_jsx_runtime6 = require("react/jsx-runtime");
1863
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1462
1864
  function LensTrack({
1463
1865
  items,
1464
1866
  labels,
@@ -1470,28 +1872,36 @@ function LensTrack({
1470
1872
  style,
1471
1873
  "aria-label": ariaLabel
1472
1874
  }) {
1473
- const bar = (0, import_react8.useRef)(null);
1474
- const glass = (0, import_react8.useRef)(null);
1475
- const lens = (0, import_react8.useRef)(null);
1476
- const select = (0, import_react8.useRef)(null);
1875
+ const bar = (0, import_react9.useRef)(null);
1876
+ const glass = (0, import_react9.useRef)(null);
1877
+ const lens = (0, import_react9.useRef)(null);
1878
+ const select = (0, import_react9.useRef)(null);
1477
1879
  const strength = Math.max(1, Math.min(10, intensity)) / 5;
1478
1880
  const tabbar = variant === "tabbar";
1479
1881
  const zoom = tabbar ? 1.14 : 1.1;
1480
1882
  useRefraction(glass, { kind: "surface", strength });
1481
- useRefraction(lens, { kind: "lens", strength: 0, zoom, dispersion: 0, bezel: 2 });
1883
+ const overhang = tabbar ? 14 : 12;
1884
+ useRefraction(
1885
+ lens,
1886
+ { kind: "lens", strength: 0.85, zoom, dispersion: 0.25, inset: overhang / 2, copy: "refract" },
1887
+ true,
1888
+ bar,
1889
+ () => bar.current?.hasAttribute("data-lifted") ?? false
1890
+ );
1482
1891
  useLensTrack(
1483
1892
  { bar, glass, lens, select },
1484
1893
  {
1485
1894
  count: items.length,
1486
1895
  index,
1487
1896
  onSelect: (next) => onChange?.(next),
1488
- overhang: tabbar ? 14 : 12,
1897
+ overhang,
1489
1898
  spread: tabbar ? 0.3 : 0.16,
1490
- contentZoom: canRefractBackdrop() ? zoom : 1,
1899
+ contentZoom: zoom,
1900
+ copied: true,
1491
1901
  swell: tabbar ? 8 : 14
1492
1902
  }
1493
1903
  );
1494
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1904
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1495
1905
  "div",
1496
1906
  {
1497
1907
  ref: bar,
@@ -1501,9 +1911,9 @@ function LensTrack({
1501
1911
  "data-liquid-glass": "",
1502
1912
  style: { ...style, "--lg-count": items.length, "--lg-index": index },
1503
1913
  children: [
1504
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ref: glass, className: "lg-glass lg-track__glass", "aria-hidden": "true" }),
1505
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ref: select, className: "lg-track__select", "aria-hidden": "true" }),
1506
- items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1914
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: glass, className: "lg-glass lg-track__glass", "aria-hidden": "true" }),
1915
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: select, className: "lg-track__select", "aria-hidden": "true" }),
1916
+ items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1507
1917
  "button",
1508
1918
  {
1509
1919
  type: "button",
@@ -1517,38 +1927,40 @@ function LensTrack({
1517
1927
  },
1518
1928
  i
1519
1929
  )),
1520
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ref: lens, className: "lg-glass lg-track__lens", "aria-hidden": "true" })
1930
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: lens, className: "lg-glass lg-track__lens", "data-lg-mirror-bare": "", "aria-hidden": "true" })
1521
1931
  ]
1522
1932
  }
1523
1933
  );
1524
1934
  }
1525
1935
 
1526
1936
  // src/components/GlassNav/GlassNav.tsx
1527
- var import_jsx_runtime7 = require("react/jsx-runtime");
1937
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1528
1938
  var GlassNav = ({
1529
1939
  items,
1530
1940
  activeIndex = 0,
1531
1941
  onChange,
1532
1942
  intensity = 5,
1943
+ showLabels = true,
1533
1944
  className,
1534
1945
  style,
1535
1946
  "aria-label": ariaLabel = "Tabs"
1536
1947
  }) => {
1537
1948
  const hasIcons = items.some((item) => item.icon != null);
1538
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1949
+ const iconsOnly = hasIcons && !showLabels;
1950
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1539
1951
  LensTrack,
1540
1952
  {
1541
1953
  variant: "tabbar",
1542
- className: ["lg-nav", hasIcons ? "" : "lg-track--labels-only", className].filter(Boolean).join(" "),
1954
+ className: ["lg-nav", hasIcons ? "" : "lg-track--labels-only", iconsOnly ? "lg-track--icons-only" : "", className].filter(Boolean).join(" "),
1543
1955
  style,
1544
1956
  "aria-label": ariaLabel,
1545
1957
  intensity,
1546
1958
  index: activeIndex,
1547
1959
  onChange,
1548
1960
  labels: items.map((item) => item.label),
1549
- items: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react9.default.Fragment, { children: [
1550
- item.icon != null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "lg-nav__icon", children: item.icon }),
1551
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "lg-nav__label", children: item.label })
1961
+ items: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react10.default.Fragment, { children: [
1962
+ item.icon != null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-nav__icon", children: item.icon }),
1963
+ !iconsOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-nav__label", children: item.label })
1552
1964
  ] }, i))
1553
1965
  }
1554
1966
  );
@@ -1556,8 +1968,8 @@ var GlassNav = ({
1556
1968
  GlassNav.displayName = "GlassNav";
1557
1969
 
1558
1970
  // src/components/GlassSegmented/GlassSegmented.tsx
1559
- var import_react10 = __toESM(require("react"));
1560
- var import_jsx_runtime8 = require("react/jsx-runtime");
1971
+ var import_react11 = __toESM(require("react"));
1972
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1561
1973
  var GlassSegmented = ({
1562
1974
  options,
1563
1975
  value,
@@ -1569,7 +1981,7 @@ var GlassSegmented = ({
1569
1981
  "aria-label": ariaLabel
1570
1982
  }) => {
1571
1983
  const normalized = options.map((option) => typeof option === "string" ? { label: option } : option);
1572
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1984
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1573
1985
  LensTrack,
1574
1986
  {
1575
1987
  variant: "segmented",
@@ -1580,9 +1992,9 @@ var GlassSegmented = ({
1580
1992
  index: value,
1581
1993
  onChange,
1582
1994
  labels: normalized.map((option) => option.label),
1583
- items: normalized.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react10.default.Fragment, { children: [
1995
+ items: normalized.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react11.default.Fragment, { children: [
1584
1996
  option.icon,
1585
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: option.label })
1997
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-nav__label", children: option.label })
1586
1998
  ] }, i))
1587
1999
  }
1588
2000
  );
@@ -1590,9 +2002,9 @@ var GlassSegmented = ({
1590
2002
  GlassSegmented.displayName = "GlassSegmented";
1591
2003
 
1592
2004
  // src/components/GlassSlider/GlassSlider.tsx
1593
- var import_react11 = __toESM(require("react"));
1594
- var import_jsx_runtime9 = require("react/jsx-runtime");
1595
- var GlassSlider = import_react11.default.forwardRef(
2005
+ var import_react12 = __toESM(require("react"));
2006
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2007
+ var GlassSlider = import_react12.default.forwardRef(
1596
2008
  ({
1597
2009
  value = 0,
1598
2010
  min = 0,
@@ -1611,22 +2023,23 @@ var GlassSlider = import_react11.default.forwardRef(
1611
2023
  disabled,
1612
2024
  ...rest
1613
2025
  }, forwardedRef) => {
1614
- const rootRef = (0, import_react11.useRef)(null);
1615
- const inputRef = (0, import_react11.useRef)(null);
1616
- const thumbRef = (0, import_react11.useRef)(null);
1617
- const faceRef = (0, import_react11.useRef)(null);
1618
- const blockRef = (0, import_react11.useRef)(null);
1619
- (0, import_react11.useImperativeHandle)(forwardedRef, () => inputRef.current);
1620
- (0, import_react11.useEffect)(() => {
2026
+ const rootRef = (0, import_react12.useRef)(null);
2027
+ const inputRef = (0, import_react12.useRef)(null);
2028
+ const thumbRef = (0, import_react12.useRef)(null);
2029
+ const faceRef = (0, import_react12.useRef)(null);
2030
+ const blockRef = (0, import_react12.useRef)(null);
2031
+ const pastRef = (0, import_react12.useRef)(0);
2032
+ (0, import_react12.useImperativeHandle)(forwardedRef, () => inputRef.current);
2033
+ (0, import_react12.useEffect)(() => {
1621
2034
  const input2 = inputRef.current;
1622
2035
  const root = rootRef.current;
1623
2036
  const setValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set;
1624
2037
  let drag = null;
1625
2038
  const update = (clientX) => {
1626
2039
  if (!drag || max <= min) return;
1627
- const inset = showThumb ? 19 * drag.width / root.offsetWidth : 0;
1628
- const travel = Math.max(1, drag.width - inset * 2);
1629
- const fraction = clamp((clientX - drag.left - inset - drag.offset) / travel, 0, 1);
2040
+ const raw = drag.from + (clientX - drag.x) / drag.travel;
2041
+ const fraction = clamp(raw, 0, 1);
2042
+ pastRef.current = (raw - fraction) * drag.travel;
1630
2043
  let next = min + fraction * (max - min);
1631
2044
  const increment = Number(step2);
1632
2045
  if (step2 !== "any" && Number.isFinite(increment) && increment > 0) {
@@ -1641,16 +2054,15 @@ var GlassSlider = import_react11.default.forwardRef(
1641
2054
  const down = (event) => {
1642
2055
  if (input2.disabled || !event.isPrimary || event.button !== 0 || drag) return;
1643
2056
  event.preventDefault();
1644
- input2.focus({ preventScroll: true });
2057
+ delete root.dataset.keyboard;
2058
+ if (event.pointerType !== "touch") input2.focus({ preventScroll: true });
1645
2059
  const box = root.getBoundingClientRect();
1646
2060
  const inset = showThumb ? 19 * box.width / root.offsetWidth : 0;
1647
- const current = max > min ? clamp((input2.valueAsNumber - min) / (max - min), 0, 1) : 0;
1648
- const center = box.left + inset + current * (box.width - inset * 2);
1649
- const offset = showThumb && Math.abs(event.clientX - center) <= inset ? event.clientX - center : 0;
1650
- drag = { id: event.pointerId, left: box.left, width: box.width, offset };
2061
+ const from = max > min ? clamp((input2.valueAsNumber - min) / (max - min), 0, 1) : 0;
2062
+ drag = { id: event.pointerId, x: event.clientX, from, travel: Math.max(1, box.width - inset * 2) };
2063
+ pastRef.current = 0;
1651
2064
  root.dataset.dragging = "";
1652
- input2.setPointerCapture(event.pointerId);
1653
- update(event.clientX);
2065
+ root.setPointerCapture(event.pointerId);
1654
2066
  };
1655
2067
  const move = (event) => {
1656
2068
  if (event.pointerId !== drag?.id) return;
@@ -1661,33 +2073,36 @@ var GlassSlider = import_react11.default.forwardRef(
1661
2073
  if (!drag) return;
1662
2074
  const id = drag.id;
1663
2075
  drag = null;
2076
+ pastRef.current = 0;
1664
2077
  delete root.dataset.dragging;
1665
- if (input2.hasPointerCapture(id)) input2.releasePointerCapture(id);
2078
+ if (root.hasPointerCapture(id)) root.releasePointerCapture(id);
1666
2079
  };
1667
2080
  const up = (event) => {
1668
2081
  if (event.pointerId !== drag?.id) return;
1669
2082
  update(event.clientX);
1670
2083
  release();
1671
2084
  };
1672
- input2.addEventListener("pointerdown", down);
1673
- input2.addEventListener("pointermove", move);
1674
- input2.addEventListener("pointerup", up);
1675
- input2.addEventListener("pointercancel", release);
1676
- input2.addEventListener("lostpointercapture", release);
2085
+ const unguard = guardSelection(root);
2086
+ root.addEventListener("pointerdown", down);
2087
+ root.addEventListener("pointermove", move);
2088
+ root.addEventListener("pointerup", up);
2089
+ root.addEventListener("pointercancel", release);
2090
+ root.addEventListener("lostpointercapture", release);
1677
2091
  window.addEventListener("blur", release);
1678
2092
  return () => {
1679
2093
  release();
1680
- input2.removeEventListener("pointerdown", down);
1681
- input2.removeEventListener("pointermove", move);
1682
- input2.removeEventListener("pointerup", up);
1683
- input2.removeEventListener("pointercancel", release);
1684
- input2.removeEventListener("lostpointercapture", release);
2094
+ unguard();
2095
+ root.removeEventListener("pointerdown", down);
2096
+ root.removeEventListener("pointermove", move);
2097
+ root.removeEventListener("pointerup", up);
2098
+ root.removeEventListener("pointercancel", release);
2099
+ root.removeEventListener("lostpointercapture", release);
1685
2100
  window.removeEventListener("blur", release);
1686
2101
  };
1687
2102
  }, [min, max, step2, showThumb]);
1688
2103
  const strength = Math.max(1, Math.min(10, intensity)) / 5;
1689
- const [mirrored, setMirrored] = import_react11.default.useState(false);
1690
- (0, import_react11.useEffect)(() => setMirrored(!canRefractBackdrop()), []);
2104
+ const [mirrored, setMirrored] = import_react12.default.useState(false);
2105
+ (0, import_react12.useEffect)(() => setMirrored(!canRefractBackdrop()), []);
1691
2106
  const progress = max > min ? clamp((Number(value) - min) / (max - min), 0, 1) : 0;
1692
2107
  useRefraction(
1693
2108
  thumbRef,
@@ -1697,18 +2112,20 @@ var GlassSlider = import_react11.default.forwardRef(
1697
2112
  () => parseFloat(rootRef.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
1698
2113
  );
1699
2114
  useRefraction(blockRef, { kind: "surface", strength }, !showThumb);
1700
- (0, import_react11.useEffect)(() => {
2115
+ (0, import_react12.useEffect)(() => {
1701
2116
  if (!showThumb) return;
1702
2117
  const input2 = inputRef.current;
1703
2118
  const thumb = thumbRef.current;
1704
2119
  const face = faceRef.current;
1705
2120
  const root = rootRef.current;
1706
- const v = { lift: 0, stretch: 0 };
2121
+ const v = { lift: 0, stretch: 0, over: 0 };
1707
2122
  const paint = () => {
1708
2123
  const s = 0.655 + 0.345 * v.lift;
1709
- thumb.style.scale = `${s * (1 + v.stretch)} ${s * (1 - v.stretch * 0.5)}`;
2124
+ const pull = Math.abs(v.over) / 58 * 0.6;
2125
+ thumb.style.scale = `${s * (1 + v.stretch + pull)} ${s * (1 - v.stretch * 0.5 - pull * 0.4)}`;
1710
2126
  face.style.opacity = String(1 - clamp(v.lift, 0, 1) * 0.92);
1711
2127
  root.style.setProperty("--lg-lift", String(clamp(v.lift, 0, 1)));
2128
+ root.style.setProperty("--lg-over", `${v.over.toFixed(2)}px`);
1712
2129
  if (v.lift < 0.01 && lift.target === 0) delete root.dataset.lifted;
1713
2130
  };
1714
2131
  const lift = createSpring(0, SPRINGS.lift, (x) => {
@@ -1719,11 +2136,15 @@ var GlassSlider = import_react11.default.forwardRef(
1719
2136
  v.stretch = x;
1720
2137
  paint();
1721
2138
  });
2139
+ const over = createSpring(0, SPRINGS.release, (x) => {
2140
+ v.over = x;
2141
+ paint();
2142
+ });
1722
2143
  paint();
1723
2144
  let lastX = 0;
1724
2145
  let lastT = 0;
1725
2146
  const down = (event) => {
1726
- if (input2.disabled) return;
2147
+ if (input2.disabled || !event.isPrimary || event.button !== 0) return;
1727
2148
  lastX = event.clientX;
1728
2149
  lastT = event.timeStamp;
1729
2150
  root.dataset.lifted = "";
@@ -1739,6 +2160,8 @@ var GlassSlider = import_react11.default.forwardRef(
1739
2160
  lastT = event.timeStamp;
1740
2161
  stretch.tune(SPRINGS.drag);
1741
2162
  stretch.set(clamp(speed * 0.015, 0, 0.035));
2163
+ over.tune(SPRINGS.drag);
2164
+ over.set(rubberband(pastRef.current, 12, 0.5));
1742
2165
  };
1743
2166
  const up = () => {
1744
2167
  if (lift.target === 0) return;
@@ -1746,29 +2169,33 @@ var GlassSlider = import_react11.default.forwardRef(
1746
2169
  lift.set(0);
1747
2170
  stretch.tune(SPRINGS.release);
1748
2171
  stretch.set(0);
2172
+ over.tune(SPRINGS.release);
2173
+ over.set(0);
1749
2174
  };
1750
- input2.addEventListener("pointerdown", down);
2175
+ root.addEventListener("pointerdown", down);
1751
2176
  window.addEventListener("pointermove", move);
1752
2177
  window.addEventListener("pointerup", up);
1753
2178
  window.addEventListener("pointercancel", up);
1754
- input2.addEventListener("blur", up);
2179
+ root.addEventListener("lostpointercapture", up);
1755
2180
  window.addEventListener("blur", up);
1756
2181
  return () => {
1757
2182
  lift.stop();
1758
2183
  stretch.stop();
1759
- input2.removeEventListener("pointerdown", down);
2184
+ over.stop();
2185
+ root.removeEventListener("pointerdown", down);
1760
2186
  window.removeEventListener("pointermove", move);
1761
2187
  window.removeEventListener("pointerup", up);
1762
2188
  window.removeEventListener("pointercancel", up);
1763
- input2.removeEventListener("blur", up);
2189
+ root.removeEventListener("lostpointercapture", up);
1764
2190
  window.removeEventListener("blur", up);
1765
2191
  delete root.dataset.lifted;
1766
2192
  };
1767
2193
  }, [showThumb]);
1768
- (0, import_react11.useEffect)(() => {
2194
+ (0, import_react12.useEffect)(() => {
1769
2195
  if (showThumb) return;
1770
2196
  const input2 = inputRef.current;
1771
2197
  const block = blockRef.current;
2198
+ const root = rootRef.current;
1772
2199
  const v = { swell: 0, over: 0 };
1773
2200
  const paint = () => {
1774
2201
  const w = block.offsetWidth || 1;
@@ -1787,41 +2214,46 @@ var GlassSlider = import_react11.default.forwardRef(
1787
2214
  });
1788
2215
  let active2 = null;
1789
2216
  const down = (event) => {
1790
- if (input2.disabled) return;
1791
- active2 = { id: event.pointerId, box: block.getBoundingClientRect() };
2217
+ if (input2.disabled || !event.isPrimary || event.button !== 0) return;
2218
+ active2 = { id: event.pointerId };
1792
2219
  swell.tune(SPRINGS.press);
1793
2220
  swell.set(1);
1794
2221
  haptic();
1795
2222
  };
1796
2223
  const move = (event) => {
1797
2224
  if (event.pointerId !== active2?.id) return;
1798
- const { box } = active2;
1799
- const past = event.clientX < box.left ? event.clientX - box.left : event.clientX > box.right ? event.clientX - box.right : 0;
1800
2225
  over.tune(SPRINGS.drag);
1801
- over.set(rubberband(past, 26, 0.6));
2226
+ over.set(rubberband(pastRef.current, 26, 0.6));
1802
2227
  };
1803
- const up = (event) => {
1804
- if (event.pointerId !== active2?.id) return;
2228
+ const reset = () => {
2229
+ if (!active2) return;
1805
2230
  active2 = null;
1806
2231
  swell.tune(SPRINGS.release);
1807
2232
  swell.set(0);
1808
2233
  over.tune(SPRINGS.release);
1809
2234
  over.set(0);
1810
2235
  };
1811
- input2.addEventListener("pointerdown", down);
2236
+ const up = (event) => {
2237
+ if (event.pointerId === active2?.id) reset();
2238
+ };
2239
+ root.addEventListener("pointerdown", down);
2240
+ root.addEventListener("lostpointercapture", reset);
2241
+ window.addEventListener("blur", reset);
1812
2242
  window.addEventListener("pointermove", move);
1813
2243
  window.addEventListener("pointerup", up);
1814
2244
  window.addEventListener("pointercancel", up);
1815
2245
  return () => {
1816
2246
  swell.stop();
1817
2247
  over.stop();
1818
- input2.removeEventListener("pointerdown", down);
2248
+ root.removeEventListener("pointerdown", down);
2249
+ root.removeEventListener("lostpointercapture", reset);
2250
+ window.removeEventListener("blur", reset);
1819
2251
  window.removeEventListener("pointermove", move);
1820
2252
  window.removeEventListener("pointerup", up);
1821
2253
  window.removeEventListener("pointercancel", up);
1822
2254
  };
1823
2255
  }, [showThumb]);
1824
- const input = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2256
+ const input = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1825
2257
  "input",
1826
2258
  {
1827
2259
  ref: inputRef,
@@ -1841,7 +2273,7 @@ var GlassSlider = import_react11.default.forwardRef(
1841
2273
  );
1842
2274
  const vars = { "--lg-progress": progress, ...tint ? { "--lg-slider-fill": tint } : {}, ...style };
1843
2275
  if (!showThumb) {
1844
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2276
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1845
2277
  "div",
1846
2278
  {
1847
2279
  ref: rootRef,
@@ -1849,16 +2281,16 @@ var GlassSlider = import_react11.default.forwardRef(
1849
2281
  "data-liquid-glass": "",
1850
2282
  style: vars,
1851
2283
  children: [
1852
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref: blockRef, className: "lg-glass lg-slider__block", children: [
1853
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "lg-slider__block-content", "aria-hidden": "true", children: [
1854
- icon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__icon", children: icon }),
1855
- label2 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__label", children: label2 }),
1856
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
2284
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { ref: blockRef, className: "lg-glass lg-slider__block", children: [
2285
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "lg-slider__block-content", "aria-hidden": "true", children: [
2286
+ icon && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__icon", children: icon }),
2287
+ label2 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__label", children: label2 }),
2288
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
1857
2289
  ] }),
1858
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__block-fill", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "lg-slider__block-content lg-slider__block-content--lit", children: [
1859
- icon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__icon", children: icon }),
1860
- label2 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__label", children: label2 }),
1861
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
2290
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__block-fill", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "lg-slider__block-content lg-slider__block-content--lit", children: [
2291
+ icon && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__icon", children: icon }),
2292
+ label2 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__label", children: label2 }),
2293
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
1862
2294
  ] }) })
1863
2295
  ] }),
1864
2296
  input
@@ -1866,7 +2298,7 @@ var GlassSlider = import_react11.default.forwardRef(
1866
2298
  }
1867
2299
  );
1868
2300
  }
1869
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2301
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1870
2302
  "div",
1871
2303
  {
1872
2304
  ref: rootRef,
@@ -1875,8 +2307,8 @@ var GlassSlider = import_react11.default.forwardRef(
1875
2307
  "data-mirror": mirrored ? "" : void 0,
1876
2308
  style: vars,
1877
2309
  children: [
1878
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__rail", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__fill" }) }),
1879
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-slider__thumb-slot", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { ref: thumbRef, className: "lg-glass lg-slider__thumb", "data-lg-mirror-bare": "", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { ref: faceRef, className: "lg-slider__face" }) }) }),
2310
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__rail", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__fill" }) }),
2311
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__thumb-slot", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ref: thumbRef, className: "lg-glass lg-slider__thumb", "data-lg-mirror-bare": "", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ref: faceRef, className: "lg-slider__face" }) }) }),
1880
2312
  input
1881
2313
  ]
1882
2314
  }
@@ -1886,22 +2318,22 @@ var GlassSlider = import_react11.default.forwardRef(
1886
2318
  GlassSlider.displayName = "GlassSlider";
1887
2319
 
1888
2320
  // src/components/GlassSwitch/GlassSwitch.tsx
1889
- var import_react12 = __toESM(require("react"));
1890
- var import_jsx_runtime10 = require("react/jsx-runtime");
2321
+ var import_react13 = __toESM(require("react"));
2322
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1891
2323
  var SETTLE = springFrom(0.36, 0.68);
1892
2324
  var REST = 0.655;
1893
2325
  var TRAVEL = 22;
1894
- var GlassSwitch = import_react12.default.forwardRef(
2326
+ var GlassSwitch = import_react13.default.forwardRef(
1895
2327
  ({ checked: checkedProp, defaultChecked = false, onChange, tint, intensity = 5, className, style, disabled, ...rest }, forwardedRef) => {
1896
- const ref = (0, import_react12.useRef)(null);
1897
- const thumbRef = (0, import_react12.useRef)(null);
1898
- const fillRef = (0, import_react12.useRef)(null);
1899
- const faceRef = (0, import_react12.useRef)(null);
1900
- (0, import_react12.useImperativeHandle)(forwardedRef, () => ref.current);
1901
- const [inner, setInner] = (0, import_react12.useState)(defaultChecked);
2328
+ const ref = (0, import_react13.useRef)(null);
2329
+ const thumbRef = (0, import_react13.useRef)(null);
2330
+ const fillRef = (0, import_react13.useRef)(null);
2331
+ const faceRef = (0, import_react13.useRef)(null);
2332
+ (0, import_react13.useImperativeHandle)(forwardedRef, () => ref.current);
2333
+ const [inner, setInner] = (0, import_react13.useState)(defaultChecked);
1902
2334
  const controlled = checkedProp !== void 0;
1903
2335
  const checked = controlled ? checkedProp : inner;
1904
- const latest = (0, import_react12.useRef)({ checked, set: (_) => {
2336
+ const latest = (0, import_react13.useRef)({ checked, set: (_) => {
1905
2337
  }, disabled });
1906
2338
  latest.current = {
1907
2339
  checked,
@@ -1911,15 +2343,15 @@ var GlassSwitch = import_react12.default.forwardRef(
1911
2343
  onChange?.(next);
1912
2344
  }
1913
2345
  };
1914
- const sync = (0, import_react12.useRef)(null);
2346
+ const sync = (0, import_react13.useRef)(null);
1915
2347
  useRefraction(
1916
2348
  thumbRef,
1917
- { kind: "lens", zoom: 1, dispersion: 0.5, strength: Math.max(1, Math.min(10, intensity)) / 5 },
2349
+ { kind: "lens", zoom: 0.72, zoomX: 1, dispersion: 0.5, copy: true, strength: Math.max(1, Math.min(10, intensity)) / 5 },
1918
2350
  true,
1919
2351
  ref,
1920
2352
  () => parseFloat(ref.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
1921
2353
  );
1922
- (0, import_react12.useEffect)(() => {
2354
+ (0, import_react13.useEffect)(() => {
1923
2355
  const el2 = ref.current;
1924
2356
  const thumb = thumbRef.current;
1925
2357
  const fill = fillRef.current;
@@ -1930,6 +2362,8 @@ var GlassSwitch = import_react12.default.forwardRef(
1930
2362
  const sy = s * (1 - v.stretch * 0.5);
1931
2363
  thumb.style.transform = `translate(${v.x * TRAVEL}px, -50%) scale(${sx}, ${sy})`;
1932
2364
  const l = clamp(v.lift, 0, 1);
2365
+ el2.style.setProperty("--lg-knob-x", `${(21 + v.x * TRAVEL).toFixed(2)}px`);
2366
+ el2.style.setProperty("--lg-hole", `${(l > 0.01 ? 23 * sx : 0).toFixed(2)}px`);
1933
2367
  el2.style.setProperty("--lg-lift", String(l));
1934
2368
  el2.toggleAttribute("data-lifted", l > 0.01);
1935
2369
  };
@@ -2019,6 +2453,7 @@ var GlassSwitch = import_react12.default.forwardRef(
2019
2453
  latest.current.set(next);
2020
2454
  sync.current?.(next);
2021
2455
  };
2456
+ const unguard = guardSelection(el2);
2022
2457
  el2.addEventListener("pointerdown", down);
2023
2458
  el2.addEventListener("pointermove", move);
2024
2459
  el2.addEventListener("pointerup", up);
@@ -2027,6 +2462,7 @@ var GlassSwitch = import_react12.default.forwardRef(
2027
2462
  return () => {
2028
2463
  clearTimeout(dropTimer);
2029
2464
  [position, lift, color].forEach((s) => s.stop());
2465
+ unguard();
2030
2466
  el2.removeEventListener("pointerdown", down);
2031
2467
  el2.removeEventListener("pointermove", move);
2032
2468
  el2.removeEventListener("pointerup", up);
@@ -2034,10 +2470,10 @@ var GlassSwitch = import_react12.default.forwardRef(
2034
2470
  el2.removeEventListener("click", click);
2035
2471
  };
2036
2472
  }, []);
2037
- (0, import_react12.useEffect)(() => {
2473
+ (0, import_react13.useEffect)(() => {
2038
2474
  sync.current?.(checked);
2039
2475
  }, [checked]);
2040
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
2476
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2041
2477
  "button",
2042
2478
  {
2043
2479
  ref,
@@ -2054,8 +2490,9 @@ var GlassSwitch = import_react12.default.forwardRef(
2054
2490
  rest.onKeyDown?.(event);
2055
2491
  },
2056
2492
  children: [
2057
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ref: fillRef, className: "lg-switch__fill", "aria-hidden": "true" }),
2058
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ref: thumbRef, className: "lg-glass lg-switch__thumb", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ref: faceRef, className: "lg-switch__face" }) })
2493
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "lg-switch__track", "aria-hidden": "true" }),
2494
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { ref: fillRef, className: "lg-switch__fill", "aria-hidden": "true" }),
2495
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { ref: thumbRef, className: "lg-glass lg-switch__thumb", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { ref: faceRef, className: "lg-switch__face" }) })
2059
2496
  ]
2060
2497
  }
2061
2498
  );
@@ -2064,29 +2501,29 @@ var GlassSwitch = import_react12.default.forwardRef(
2064
2501
  GlassSwitch.displayName = "GlassSwitch";
2065
2502
 
2066
2503
  // src/filters/LiquidGlassFilter.tsx
2067
- var import_react13 = require("react");
2068
- var import_jsx_runtime11 = require("react/jsx-runtime");
2069
- var GlassFilterContext = (0, import_react13.createContext)(false);
2504
+ var import_react14 = require("react");
2505
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2506
+ var GlassFilterContext = (0, import_react14.createContext)(false);
2070
2507
  function LiquidGlassFilter({ children }) {
2071
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(GlassFilterContext.Provider, { value: true, children: [
2072
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(GlassFilterSVG, {}),
2508
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(GlassFilterContext.Provider, { value: true, children: [
2509
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(GlassFilterSVG, {}),
2073
2510
  children
2074
2511
  ] });
2075
2512
  }
2076
2513
  function GlassFilterSVG() {
2077
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2514
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2078
2515
  "svg",
2079
2516
  {
2080
2517
  width: "0",
2081
2518
  height: "0",
2082
2519
  style: { position: "absolute", pointerEvents: "none" },
2083
2520
  "aria-hidden": "true",
2084
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("defs", { children: Array.from({ length: 10 }, (_, i) => {
2521
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("defs", { children: Array.from({ length: 10 }, (_, i) => {
2085
2522
  const level = i + 1;
2086
2523
  const scale = level * 2;
2087
2524
  const freq1 = 0.012 + level * 1e-3;
2088
2525
  const freq2 = 0.01 + level * 8e-4;
2089
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2526
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2090
2527
  "filter",
2091
2528
  {
2092
2529
  id: `liquid-glass-refract-${level}`,
@@ -2096,7 +2533,7 @@ function GlassFilterSVG() {
2096
2533
  height: "120%",
2097
2534
  colorInterpolationFilters: "sRGB",
2098
2535
  children: [
2099
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2536
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2100
2537
  "feTurbulence",
2101
2538
  {
2102
2539
  type: "fractalNoise",
@@ -2106,7 +2543,7 @@ function GlassFilterSVG() {
2106
2543
  result: "noise"
2107
2544
  }
2108
2545
  ),
2109
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2546
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2110
2547
  "feDisplacementMap",
2111
2548
  {
2112
2549
  in: "SourceGraphic",
@@ -2126,7 +2563,7 @@ function GlassFilterSVG() {
2126
2563
  }
2127
2564
 
2128
2565
  // src/hooks/useGlassEffect.ts
2129
- var import_react14 = require("react");
2566
+ var import_react15 = require("react");
2130
2567
  function parseTintColor(tint) {
2131
2568
  const defaults = { h: 0, s: 0, l: 100, a: 0.1 };
2132
2569
  if (!tint) return defaults;
@@ -2178,7 +2615,7 @@ function useGlassEffect(options = {}) {
2178
2615
  thickness,
2179
2616
  blur
2180
2617
  } = options;
2181
- return (0, import_react14.useMemo)(() => {
2618
+ return (0, import_react15.useMemo)(() => {
2182
2619
  const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
2183
2620
  const filterId = `liquid-glass-refract-${clampedIntensity}`;
2184
2621
  const style = {
@@ -2203,21 +2640,21 @@ function useGlassEffect(options = {}) {
2203
2640
  }
2204
2641
 
2205
2642
  // src/hooks/useGlassAnimation.ts
2206
- var import_react15 = require("react");
2643
+ var import_react16 = require("react");
2207
2644
  function useGlassAnimation() {
2208
- const [isHovered, setIsHovered] = (0, import_react15.useState)(false);
2209
- const [isPressed, setIsPressed] = (0, import_react15.useState)(false);
2210
- const [isFocused, setIsFocused] = (0, import_react15.useState)(false);
2645
+ const [isHovered, setIsHovered] = (0, import_react16.useState)(false);
2646
+ const [isPressed, setIsPressed] = (0, import_react16.useState)(false);
2647
+ const [isFocused, setIsFocused] = (0, import_react16.useState)(false);
2211
2648
  const handlers = {
2212
- onPointerEnter: (0, import_react15.useCallback)(() => setIsHovered(true), []),
2213
- onPointerLeave: (0, import_react15.useCallback)(() => {
2649
+ onPointerEnter: (0, import_react16.useCallback)(() => setIsHovered(true), []),
2650
+ onPointerLeave: (0, import_react16.useCallback)(() => {
2214
2651
  setIsHovered(false);
2215
2652
  setIsPressed(false);
2216
2653
  }, []),
2217
- onPointerDown: (0, import_react15.useCallback)(() => setIsPressed(true), []),
2218
- onPointerUp: (0, import_react15.useCallback)(() => setIsPressed(false), []),
2219
- onFocus: (0, import_react15.useCallback)(() => setIsFocused(true), []),
2220
- onBlur: (0, import_react15.useCallback)(() => setIsFocused(false), [])
2654
+ onPointerDown: (0, import_react16.useCallback)(() => setIsPressed(true), []),
2655
+ onPointerUp: (0, import_react16.useCallback)(() => setIsPressed(false), []),
2656
+ onFocus: (0, import_react16.useCallback)(() => setIsFocused(true), []),
2657
+ onBlur: (0, import_react16.useCallback)(() => setIsFocused(false), [])
2221
2658
  };
2222
2659
  return { isHovered, isPressed, isFocused, handlers };
2223
2660
  }
@@ -2226,6 +2663,7 @@ function useGlassAnimation() {
2226
2663
  GlassButton,
2227
2664
  GlassCard,
2228
2665
  GlassInput,
2666
+ GlassMenu,
2229
2667
  GlassNav,
2230
2668
  GlassSegmented,
2231
2669
  GlassSheet,