@zag-js/rect-utils 0.2.0 → 0.2.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.
Files changed (68) hide show
  1. package/dist/align.d.ts +12 -0
  2. package/dist/align.js +71 -0
  3. package/dist/align.mjs +6 -0
  4. package/dist/chunk-2QYJISFU.mjs +21 -0
  5. package/dist/chunk-AYR2YRSU.mjs +49 -0
  6. package/dist/chunk-BGAHRJ6S.mjs +41 -0
  7. package/dist/chunk-BPWQOPHU.mjs +32 -0
  8. package/dist/chunk-C2OCKGLJ.mjs +27 -0
  9. package/dist/chunk-DBR73IMM.mjs +54 -0
  10. package/dist/chunk-IFHTGH3H.mjs +29 -0
  11. package/dist/chunk-LCJDCPGN.mjs +56 -0
  12. package/dist/chunk-NGMCS5TG.mjs +33 -0
  13. package/dist/chunk-QXXKPYP2.mjs +47 -0
  14. package/dist/chunk-R24UTBJ3.mjs +52 -0
  15. package/dist/chunk-S3HXSPS7.mjs +21 -0
  16. package/dist/chunk-T4IEPEZY.mjs +41 -0
  17. package/dist/chunk-TPU7B3ZS.mjs +18 -0
  18. package/dist/chunk-WBQAMGXK.mjs +0 -0
  19. package/dist/chunk-YDYJCJQZ.mjs +56 -0
  20. package/dist/closest.d.ts +8 -0
  21. package/dist/closest.js +83 -0
  22. package/dist/closest.mjs +13 -0
  23. package/dist/contains.d.ts +8 -0
  24. package/dist/contains.js +60 -0
  25. package/dist/contains.mjs +11 -0
  26. package/dist/distance.d.ts +12 -0
  27. package/dist/distance.js +79 -0
  28. package/dist/distance.mjs +14 -0
  29. package/dist/from-element.d.ts +16 -0
  30. package/dist/from-element.js +99 -0
  31. package/dist/from-element.mjs +7 -0
  32. package/dist/from-points.d.ts +6 -0
  33. package/dist/from-points.js +61 -0
  34. package/dist/from-points.mjs +7 -0
  35. package/dist/from-range.d.ts +6 -0
  36. package/dist/from-range.js +155 -0
  37. package/dist/from-range.mjs +10 -0
  38. package/dist/from-rotation.d.ts +8 -0
  39. package/dist/from-rotation.js +92 -0
  40. package/dist/from-rotation.mjs +11 -0
  41. package/dist/from-window.d.ts +24 -0
  42. package/dist/from-window.js +71 -0
  43. package/dist/from-window.mjs +9 -0
  44. package/dist/get-polygon.d.ts +8 -0
  45. package/dist/get-polygon.js +70 -0
  46. package/dist/get-polygon.mjs +7 -0
  47. package/dist/index.d.ts +16 -186
  48. package/dist/index.js +7 -7
  49. package/dist/index.mjs +67 -453
  50. package/dist/intersection.d.ts +17 -0
  51. package/dist/intersection.js +74 -0
  52. package/dist/intersection.mjs +11 -0
  53. package/dist/operations.d.ts +10 -0
  54. package/dist/operations.js +88 -0
  55. package/dist/operations.mjs +15 -0
  56. package/dist/polygon.d.ts +6 -0
  57. package/dist/polygon.js +77 -0
  58. package/dist/polygon.mjs +8 -0
  59. package/dist/rect.d.ts +64 -0
  60. package/dist/rect.js +86 -0
  61. package/dist/rect.mjs +14 -0
  62. package/dist/types.d.ts +32 -0
  63. package/dist/types.js +18 -0
  64. package/dist/types.mjs +1 -0
  65. package/dist/union.d.ts +6 -0
  66. package/dist/union.js +87 -0
  67. package/dist/union.mjs +8 -0
  68. package/package.json +18 -8
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/from-rotation.ts
21
+ var from_rotation_exports = {};
22
+ __export(from_rotation_exports, {
23
+ getRotationRect: () => getRotationRect,
24
+ rotate: () => rotate,
25
+ toRad: () => toRad
26
+ });
27
+ module.exports = __toCommonJS(from_rotation_exports);
28
+
29
+ // src/rect.ts
30
+ var point = (x, y) => ({ x, y });
31
+ function createRect(r) {
32
+ const { x, y, width, height } = r;
33
+ const midX = x + width / 2;
34
+ const midY = y + height / 2;
35
+ return {
36
+ x,
37
+ y,
38
+ width,
39
+ height,
40
+ minX: x,
41
+ minY: y,
42
+ maxX: x + width,
43
+ maxY: y + height,
44
+ midX,
45
+ midY,
46
+ center: point(midX, midY)
47
+ };
48
+ }
49
+ function getRectCorners(v) {
50
+ const top = point(v.minX, v.minY);
51
+ const right = point(v.maxX, v.minY);
52
+ const bottom = point(v.maxX, v.maxY);
53
+ const left = point(v.minX, v.maxY);
54
+ return { top, right, bottom, left };
55
+ }
56
+
57
+ // src/from-rotation.ts
58
+ function toRad(d) {
59
+ return d % 360 * Math.PI / 180;
60
+ }
61
+ function rotate(a, d, c) {
62
+ const r = toRad(d);
63
+ const sin = Math.sin(r);
64
+ const cos = Math.cos(r);
65
+ const x = a.x - c.x;
66
+ const y = a.y - c.y;
67
+ return {
68
+ x: c.x + x * cos - y * sin,
69
+ y: c.y + x * sin + y * cos
70
+ };
71
+ }
72
+ function getRotationRect(r, deg) {
73
+ const rr = Object.values(getRectCorners(r)).map((p) => rotate(p, deg, r.center));
74
+ const xs = rr.map((p) => p.x);
75
+ const ys = rr.map((p) => p.y);
76
+ const minX = Math.min(...xs);
77
+ const minY = Math.min(...ys);
78
+ const maxX = Math.max(...xs);
79
+ const maxY = Math.max(...ys);
80
+ return createRect({
81
+ x: minX,
82
+ y: minY,
83
+ width: maxX - minX,
84
+ height: maxY - minY
85
+ });
86
+ }
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ getRotationRect,
90
+ rotate,
91
+ toRad
92
+ });
@@ -0,0 +1,11 @@
1
+ import {
2
+ getRotationRect,
3
+ rotate,
4
+ toRad
5
+ } from "./chunk-BGAHRJ6S.mjs";
6
+ import "./chunk-YDYJCJQZ.mjs";
7
+ export {
8
+ getRotationRect,
9
+ rotate,
10
+ toRad
11
+ };
@@ -0,0 +1,24 @@
1
+ import { Rect } from './rect.js';
2
+ import './types.js';
3
+
4
+ type WindowRectOptions = {
5
+ /**
6
+ * Whether to exclude the element's scrollbar size from the calculation.
7
+ */
8
+ excludeScrollbar?: boolean;
9
+ };
10
+ /**
11
+ * Creates a rectange from window object
12
+ */
13
+ declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
14
+ /**
15
+ * Get the rect of the window with the option to exclude the scrollbar
16
+ */
17
+ declare function getViewportRect(win: Window, opts: WindowRectOptions): {
18
+ x: number;
19
+ y: number;
20
+ width: number;
21
+ height: number;
22
+ };
23
+
24
+ export { WindowRectOptions, getViewportRect, getWindowRect };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/from-window.ts
21
+ var from_window_exports = {};
22
+ __export(from_window_exports, {
23
+ getViewportRect: () => getViewportRect,
24
+ getWindowRect: () => getWindowRect
25
+ });
26
+ module.exports = __toCommonJS(from_window_exports);
27
+
28
+ // src/rect.ts
29
+ var point = (x, y) => ({ x, y });
30
+ function createRect(r) {
31
+ const { x, y, width, height } = r;
32
+ const midX = x + width / 2;
33
+ const midY = y + height / 2;
34
+ return {
35
+ x,
36
+ y,
37
+ width,
38
+ height,
39
+ minX: x,
40
+ minY: y,
41
+ maxX: x + width,
42
+ maxY: y + height,
43
+ midX,
44
+ midY,
45
+ center: point(midX, midY)
46
+ };
47
+ }
48
+
49
+ // src/from-window.ts
50
+ function getWindowRect(win, opts = {}) {
51
+ return createRect(getViewportRect(win, opts));
52
+ }
53
+ function getViewportRect(win, opts) {
54
+ const { excludeScrollbar = false } = opts;
55
+ const { innerWidth, innerHeight, document: doc, visualViewport } = win;
56
+ const width = (visualViewport == null ? void 0 : visualViewport.width) || innerWidth;
57
+ const height = (visualViewport == null ? void 0 : visualViewport.height) || innerHeight;
58
+ const rect = { x: 0, y: 0, width, height };
59
+ if (excludeScrollbar) {
60
+ const scrollbarWidth = innerWidth - doc.documentElement.clientWidth;
61
+ const scrollbarHeight = innerHeight - doc.documentElement.clientHeight;
62
+ rect.width -= scrollbarWidth;
63
+ rect.height -= scrollbarHeight;
64
+ }
65
+ return rect;
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ getViewportRect,
70
+ getWindowRect
71
+ });
@@ -0,0 +1,9 @@
1
+ import {
2
+ getViewportRect,
3
+ getWindowRect
4
+ } from "./chunk-C2OCKGLJ.mjs";
5
+ import "./chunk-YDYJCJQZ.mjs";
6
+ export {
7
+ getViewportRect,
8
+ getWindowRect
9
+ };
@@ -0,0 +1,8 @@
1
+ import { RectValue } from './types.js';
2
+
3
+ declare function getElementPolygon(rectValue: RectValue, placement: string): {
4
+ x: number;
5
+ y: number;
6
+ }[] | undefined;
7
+
8
+ export { getElementPolygon };
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/get-polygon.ts
21
+ var get_polygon_exports = {};
22
+ __export(get_polygon_exports, {
23
+ getElementPolygon: () => getElementPolygon
24
+ });
25
+ module.exports = __toCommonJS(get_polygon_exports);
26
+
27
+ // src/rect.ts
28
+ var point = (x, y) => ({ x, y });
29
+ function createRect(r) {
30
+ const { x, y, width, height } = r;
31
+ const midX = x + width / 2;
32
+ const midY = y + height / 2;
33
+ return {
34
+ x,
35
+ y,
36
+ width,
37
+ height,
38
+ minX: x,
39
+ minY: y,
40
+ maxX: x + width,
41
+ maxY: y + height,
42
+ midX,
43
+ midY,
44
+ center: point(midX, midY)
45
+ };
46
+ }
47
+ function getRectCorners(v) {
48
+ const top = point(v.minX, v.minY);
49
+ const right = point(v.maxX, v.minY);
50
+ const bottom = point(v.maxX, v.maxY);
51
+ const left = point(v.minX, v.maxY);
52
+ return { top, right, bottom, left };
53
+ }
54
+
55
+ // src/get-polygon.ts
56
+ function getElementPolygon(rectValue, placement) {
57
+ const rect = createRect(rectValue);
58
+ const { top, right, left, bottom } = getRectCorners(rect);
59
+ const [base] = placement.split("-");
60
+ return {
61
+ top: [left, top, right, bottom],
62
+ right: [top, right, bottom, left],
63
+ bottom: [top, left, bottom, right],
64
+ left: [right, top, left, bottom]
65
+ }[base];
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ getElementPolygon
70
+ });
@@ -0,0 +1,7 @@
1
+ import {
2
+ getElementPolygon
3
+ } from "./chunk-S3HXSPS7.mjs";
4
+ import "./chunk-YDYJCJQZ.mjs";
5
+ export {
6
+ getElementPolygon
7
+ };
package/dist/index.d.ts CHANGED
@@ -1,186 +1,16 @@
1
- declare type Point = {
2
- x: number;
3
- y: number;
4
- };
5
- declare type RectValue = {
6
- x: number;
7
- y: number;
8
- width: number;
9
- height: number;
10
- };
11
- declare type RectSide = "top" | "right" | "bottom" | "left";
12
- declare type RectPoint = "top-left" | "top-center" | "top-right" | "right-center" | "left-center" | "bottom-left" | "bottom-right" | "bottom-center" | "center";
13
- declare type RectEdge = [Point, Point];
14
- declare type RectPoints = [Point, Point, Point, Point];
15
- declare type RectEdges = Record<RectSide, RectEdge> & {
16
- value: RectEdge[];
17
- };
18
- declare type RectCorner = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
19
- declare type RectCorners = Record<RectCorner, Point> & {
20
- value: RectPoints;
21
- };
22
- declare type RectCenter = "topCenter" | "rightCenter" | "leftCenter" | "bottomCenter";
23
- declare type RectCenters = Record<RectCenter, Point> & {
24
- value: RectPoints;
25
- };
26
- declare type RectInset = Partial<Record<RectSide, number>>;
27
- declare type SymmetricRectInset = {
28
- dx?: number;
29
- dy?: number;
30
- };
31
-
32
- declare function createRect(r: RectValue): {
33
- x: number;
34
- y: number;
35
- width: number;
36
- height: number;
37
- minX: number;
38
- minY: number;
39
- maxX: number;
40
- maxY: number;
41
- midX: number;
42
- midY: number;
43
- center: {
44
- x: number;
45
- y: number;
46
- };
47
- };
48
- declare type Rect = ReturnType<typeof createRect>;
49
- declare function isRect(v: any): v is Rect;
50
- declare function getRectCenters(v: Rect): {
51
- top: {
52
- x: number;
53
- y: number;
54
- };
55
- right: {
56
- x: number;
57
- y: number;
58
- };
59
- bottom: {
60
- x: number;
61
- y: number;
62
- };
63
- left: {
64
- x: number;
65
- y: number;
66
- };
67
- };
68
- declare function getRectCorners(v: Rect): {
69
- top: {
70
- x: number;
71
- y: number;
72
- };
73
- right: {
74
- x: number;
75
- y: number;
76
- };
77
- bottom: {
78
- x: number;
79
- y: number;
80
- };
81
- left: {
82
- x: number;
83
- y: number;
84
- };
85
- };
86
- declare function getRectEdges(v: Rect): {
87
- top: RectEdge;
88
- right: RectEdge;
89
- bottom: RectEdge;
90
- left: RectEdge;
91
- };
92
-
93
- declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
94
- declare type AlignOptions = {
95
- h: HAlign;
96
- v: VAlign;
97
- };
98
- declare type HAlign = "left-inside" | "left-outside" | "center" | "right-inside" | "right-outside";
99
- declare type VAlign = "top-inside" | "top-outside" | "center" | "bottom-inside" | "bottom-outside";
100
-
101
- declare function closest(...pts: Point[]): (a: Point) => Point;
102
- declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
103
- declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
104
-
105
- declare function containsPoint(r: Rect, p: Point): boolean;
106
- declare function containsRect(a: Rect, b: Rect): boolean;
107
- declare function contains(r: Rect, v: Rect | Point): boolean;
108
-
109
- declare type DistanceValue = Point & {
110
- value: number;
111
- };
112
- declare function distance(a: Point, b?: Point): number;
113
- declare function distanceFromPoint(r: Rect, p: Point): DistanceValue;
114
- declare function distanceFromRect(a: Rect, b: Rect): DistanceValue;
115
- declare function distanceBtwEdges(a: Rect, b: Rect): Record<RectSide, number>;
116
-
117
- declare function getElementRect(el: HTMLElement, opts?: ElementRectOptions): Rect;
118
- declare type ElementRectOptions = {
119
- /**
120
- * Whether to exclude the element's scrollbar size from the calculation.
121
- */
122
- excludeScrollbar?: boolean;
123
- /**
124
- * Whether to exclude the element's borders from the calculation.
125
- */
126
- excludeBorders?: boolean;
127
- };
128
-
129
- declare function getRectFromPoints(...pts: Point[]): Rect;
130
-
131
- declare function fromRange(range: Range): Rect;
132
-
133
- declare function toRad(d: number): number;
134
- declare function rotate(a: Point, d: number, c: Point): Point;
135
- declare function getRotationRect(r: Rect, deg: number): Rect;
136
-
137
- declare type WindowRectOptions = {
138
- /**
139
- * Whether to exclude the element's scrollbar size from the calculation.
140
- */
141
- excludeScrollbar?: boolean;
142
- };
143
- /**
144
- * Creates a rectange from window object
145
- */
146
- declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
147
- /**
148
- * Get the rect of the window with the option to exclude the scrollbar
149
- */
150
- declare function getViewportRect(win: Window, opts: WindowRectOptions): {
151
- x: number;
152
- y: number;
153
- width: number;
154
- height: number;
155
- };
156
-
157
- declare function getElementPolygon(rectValue: RectValue, placement: string): {
158
- x: number;
159
- y: number;
160
- }[] | undefined;
161
-
162
- /**
163
- * Checks if a Rect intersects another Rect
164
- */
165
- declare function intersects(a: Rect, b: Rect): boolean;
166
- /**
167
- * Returns a new Rect that represents the intersection between two Rects
168
- */
169
- declare function intersection(a: Rect, b: Rect): Rect;
170
- /**
171
- * Returns whether two rects collide along each edge
172
- */
173
- declare function collisions(a: Rect, b: Rect): Record<RectSide, boolean>;
174
-
175
- declare const isSymmetric: (v: any) => v is SymmetricRectInset;
176
- declare function inset(r: Rect, i: RectInset | SymmetricRectInset): Rect;
177
- declare function expand(r: Rect, v: number | SymmetricRectInset): Rect;
178
- declare function shrink(r: Rect, v: number | SymmetricRectInset): Rect;
179
- declare function shift(r: Rect, o: Partial<Point>): Rect;
180
-
181
- declare function isPointInPolygon(polygon: Point[], point: Point): boolean;
182
- declare function debugPolygon(polygon: Point[]): () => void;
183
-
184
- declare function union(...rs: Rect[]): Rect;
185
-
186
- export { AlignOptions, DistanceValue, ElementRectOptions, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInset, RectPoint, RectPoints, RectSide, RectValue, SymmetricRectInset, VAlign, WindowRectOptions, alignRect, closest, closestSideToPoint, closestSideToRect, collisions, contains, containsPoint, containsRect, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getElementPolygon, getElementRect, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPointInPolygon, isRect, isSymmetric, rotate, shift, shrink, toRad, union };
1
+ export { AlignOptions, HAlign, VAlign, alignRect } from './align.js';
2
+ export { closest, closestSideToPoint, closestSideToRect } from './closest.js';
3
+ export { contains, containsPoint, containsRect } from './contains.js';
4
+ export { DistanceValue, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect } from './distance.js';
5
+ export { ElementRectOptions, getElementRect } from './from-element.js';
6
+ export { getRectFromPoints } from './from-points.js';
7
+ export { fromRange } from './from-range.js';
8
+ export { getRotationRect, rotate, toRad } from './from-rotation.js';
9
+ export { WindowRectOptions, getViewportRect, getWindowRect } from './from-window.js';
10
+ export { getElementPolygon } from './get-polygon.js';
11
+ export { collisions, intersection, intersects } from './intersection.js';
12
+ export { expand, inset, isSymmetric, shift, shrink } from './operations.js';
13
+ export { debugPolygon, isPointInPolygon } from './polygon.js';
14
+ export { Rect, createRect, getRectCenters, getRectCorners, getRectEdges, isRect } from './rect.js';
15
+ export { Point, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInset, RectPoint, RectPoints, RectSide, RectValue, SymmetricRectInset } from './types.js';
16
+ export { union } from './union.js';
package/dist/index.js CHANGED
@@ -103,7 +103,7 @@ function alignRect(a, ref, options) {
103
103
  return vAlign(hAlign(a, ref, h), ref, v);
104
104
  }
105
105
 
106
- // ../core/dist/index.mjs
106
+ // ../core/src/guard.ts
107
107
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
108
108
 
109
109
  // src/rect.ts
@@ -267,7 +267,7 @@ function contains(r, v) {
267
267
  return isRect(v) ? containsRect(r, v) : containsPoint(r, v);
268
268
  }
269
269
 
270
- // ../dom/dist/index.mjs
270
+ // ../dom/src/get-computed-style.ts
271
271
  function getCache() {
272
272
  const g = globalThis;
273
273
  g.__styleCache = g.__styleCache || /* @__PURE__ */ new WeakMap();
@@ -409,13 +409,13 @@ function getWindowRect(win, opts = {}) {
409
409
  }
410
410
  function getViewportRect(win, opts) {
411
411
  const { excludeScrollbar = false } = opts;
412
- const { innerWidth: innerWidth2, innerHeight: innerHeight2, document: doc, visualViewport } = win;
413
- const width = (visualViewport == null ? void 0 : visualViewport.width) || innerWidth2;
414
- const height = (visualViewport == null ? void 0 : visualViewport.height) || innerHeight2;
412
+ const { innerWidth, innerHeight, document: doc, visualViewport } = win;
413
+ const width = (visualViewport == null ? void 0 : visualViewport.width) || innerWidth;
414
+ const height = (visualViewport == null ? void 0 : visualViewport.height) || innerHeight;
415
415
  const rect = { x: 0, y: 0, width, height };
416
416
  if (excludeScrollbar) {
417
- const scrollbarWidth = innerWidth2 - doc.documentElement.clientWidth;
418
- const scrollbarHeight = innerHeight2 - doc.documentElement.clientHeight;
417
+ const scrollbarWidth = innerWidth - doc.documentElement.clientWidth;
418
+ const scrollbarHeight = innerHeight - doc.documentElement.clientHeight;
419
419
  rect.width -= scrollbarWidth;
420
420
  rect.height -= scrollbarHeight;
421
421
  }