intergalactic 15.81.0-prerelease.2 → 15.81.0-prerelease.3
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/package.json +1 -1
- package/popper/lib/cjs/modifiers/cursorAnchoring.js +3 -4
- package/popper/lib/cjs/modifiers/cursorAnchoring.js.map +1 -1
- package/popper/lib/cjs/utils/getOffsetParent.js +59 -0
- package/popper/lib/cjs/utils/getOffsetParent.js.map +1 -0
- package/popper/lib/es6/modifiers/cursorAnchoring.js +1 -1
- package/popper/lib/es6/modifiers/cursorAnchoring.js.map +1 -1
- package/popper/lib/es6/utils/getOffsetParent.js +52 -0
- package/popper/lib/es6/utils/getOffsetParent.js.map +1 -0
package/package.json
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.cursorAnchoringModifier = void 0;
|
8
|
-
var _getOffsetParent =
|
7
|
+
var _getOffsetParent = require("../utils/getOffsetParent");
|
9
8
|
var clamp = function clamp(value, boundary1, boundary2) {
|
10
9
|
var min = Math.min(boundary1, boundary2);
|
11
10
|
var max = Math.max(boundary1, boundary2);
|
@@ -35,7 +34,7 @@ var cursorAnchoringModifier = {
|
|
35
34
|
if (!cursorAnchoring) return;
|
36
35
|
if (verticalPlacement) {
|
37
36
|
var _mouseEnterCursorPosi;
|
38
|
-
var offsetParent = (0, _getOffsetParent
|
37
|
+
var offsetParent = (0, _getOffsetParent.getOffsetParent)(elements.popper);
|
39
38
|
var offsetParentRect = offsetParent === window ? getWindowRect() : offsetParent.getBoundingClientRect();
|
40
39
|
var mouseX = mouseEnterCursorPositionRef === null || mouseEnterCursorPositionRef === void 0 ? void 0 : (_mouseEnterCursorPosi = mouseEnterCursorPositionRef.current) === null || _mouseEnterCursorPosi === void 0 ? void 0 : _mouseEnterCursorPosi.x;
|
41
40
|
if (mouseX === undefined) return;
|
@@ -45,7 +44,7 @@ var cursorAnchoringModifier = {
|
|
45
44
|
rects.reference.width = width;
|
46
45
|
} else {
|
47
46
|
var _mouseEnterCursorPosi2;
|
48
|
-
var _offsetParent = (0, _getOffsetParent
|
47
|
+
var _offsetParent = (0, _getOffsetParent.getOffsetParent)(elements.popper);
|
49
48
|
var _offsetParentRect = _offsetParent === window ? getWindowRect() : _offsetParent.getBoundingClientRect();
|
50
49
|
var mouseY = mouseEnterCursorPositionRef === null || mouseEnterCursorPositionRef === void 0 ? void 0 : (_mouseEnterCursorPosi2 = mouseEnterCursorPositionRef.current) === null || _mouseEnterCursorPosi2 === void 0 ? void 0 : _mouseEnterCursorPosi2.y;
|
51
50
|
if (mouseY === undefined) return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cursorAnchoring.js","names":["_getOffsetParent","
|
1
|
+
{"version":3,"file":"cursorAnchoring.js","names":["_getOffsetParent","require","clamp","value","boundary1","boundary2","min","Math","max","getWindowRect","x","y","width","window","innerWidth","height","innerHeight","cursorAnchoringModifier","name","phase","enabled","fn","_ref","state","options","placement","verticalPlacement","startsWith","cursorAnchoring","mouseEnterCursorPositionRef","rects","elements","_mouseEnterCursorPosi","offsetParent","getOffsetParent","popper","offsetParentRect","getBoundingClientRect","mouseX","current","undefined","reference","_mouseEnterCursorPosi2","mouseY","exports"],"sources":["../../../src/modifiers/cursorAnchoring.ts"],"sourcesContent":["import { getOffsetParent } from '../utils/getOffsetParent';\nimport { Modifier } from '@popperjs/core';\n\nconst clamp = (value: number, boundary1: number, boundary2: number) => {\n const min = Math.min(boundary1, boundary2);\n const max = Math.max(boundary1, boundary2);\n return Math.min(Math.max(value, min), max);\n};\n\ntype Options = {\n cursorAnchoring: true;\n mouseEnterCursorPositionRef: { current: { x: number; y: number } };\n};\n\nconst getWindowRect = () => ({ x: 0, y: 0, width: window.innerWidth, height: window.innerHeight });\n\nexport const cursorAnchoringModifier: Modifier<'cursorAnchoring', Options> = {\n name: 'cursorAnchoring',\n phase: 'beforeRead',\n enabled: true,\n fn: ({ state, options }) => {\n const { placement } = state.options;\n\n const verticalPlacement =\n !placement || placement.startsWith('top') || placement.startsWith('bottom');\n\n const { cursorAnchoring, mouseEnterCursorPositionRef } = options;\n const { rects, elements } = state;\n if (!cursorAnchoring) return;\n if (verticalPlacement) {\n const offsetParent = getOffsetParent(elements.popper);\n const offsetParentRect =\n offsetParent === window ? getWindowRect() : offsetParent.getBoundingClientRect();\n const mouseX = mouseEnterCursorPositionRef?.current?.x;\n if (mouseX === undefined) return;\n const width = Math.min(rects.reference.width, rects.popper.width);\n const x = clamp(\n mouseX - offsetParentRect.x - width / 2,\n rects.reference.x,\n rects.reference.x + rects.reference.width - width,\n );\n rects.reference.x = x;\n rects.reference.width = width;\n } else {\n const offsetParent = getOffsetParent(elements.popper);\n const offsetParentRect =\n offsetParent === window ? getWindowRect() : offsetParent.getBoundingClientRect();\n const mouseY = mouseEnterCursorPositionRef?.current?.y;\n if (mouseY === undefined) return;\n const height = Math.min(rects.reference.height, rects.popper.height);\n const y = clamp(\n mouseY - offsetParentRect.y - height / 2,\n rects.reference.y,\n rects.reference.y + rects.reference.height - height,\n );\n rects.reference.y = y;\n rects.reference.height = height;\n }\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAGA,IAAMC,KAAK,GAAG,SAARA,KAAKA,CAAIC,KAAa,EAAEC,SAAiB,EAAEC,SAAiB,EAAK;EACrE,IAAMC,GAAG,GAAGC,IAAI,CAACD,GAAG,CAACF,SAAS,EAAEC,SAAS,CAAC;EAC1C,IAAMG,GAAG,GAAGD,IAAI,CAACC,GAAG,CAACJ,SAAS,EAAEC,SAAS,CAAC;EAC1C,OAAOE,IAAI,CAACD,GAAG,CAACC,IAAI,CAACC,GAAG,CAACL,KAAK,EAAEG,GAAG,CAAC,EAAEE,GAAG,CAAC;AAC5C,CAAC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CAACW,SAAS,CAAC1B,MAAM,GAAGA,MAAM,CACpD;MACDe,KAAK,CAACW,SAAS,CAAC9B,CAAC,GAAGA,CAAC;MACrBmB,KAAK,CAACW,SAAS,CAAC1B,MAAM,GAAGA,MAAM;IACjC;EACF;AACF,CAAC;AAAC6B,OAAA,CAAA3B,uBAAA,GAAAA,uBAAA"}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getOffsetParent = void 0;
|
7
|
+
// extracted from @popperjs/core@2.11.5 to make it buildable
|
8
|
+
|
9
|
+
var getWindow = function getWindow(node) {
|
10
|
+
if (node.toString() !== '[object Window]') {
|
11
|
+
var ownerDocument = node.ownerDocument;
|
12
|
+
return ownerDocument ? ownerDocument.defaultView : window;
|
13
|
+
}
|
14
|
+
return node;
|
15
|
+
};
|
16
|
+
var getNodeName = function getNodeName(element) {
|
17
|
+
return element ? (element.nodeName || '').toLowerCase() : null;
|
18
|
+
};
|
19
|
+
var getComputedStyle = function getComputedStyle(element) {
|
20
|
+
return getWindow(element).getComputedStyle(element);
|
21
|
+
};
|
22
|
+
var isHTMLElement = function isHTMLElement(node) {
|
23
|
+
var OwnElement = getWindow(node).HTMLElement;
|
24
|
+
return node instanceof OwnElement || node instanceof HTMLElement;
|
25
|
+
};
|
26
|
+
var isTableElement = function isTableElement(element) {
|
27
|
+
return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
28
|
+
};
|
29
|
+
|
30
|
+
// https://stackoverflow.com/a/9851769/2059996
|
31
|
+
var isFirefox = function isFirefox() {
|
32
|
+
return typeof window.InstallTrigger !== 'undefined';
|
33
|
+
};
|
34
|
+
var getTrueOffsetParent = function getTrueOffsetParent(element) {
|
35
|
+
var offsetParent;
|
36
|
+
if (!isHTMLElement(element) ||
|
37
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
38
|
+
!(offsetParent = element.offsetParent) ||
|
39
|
+
// https://github.com/popperjs/popper-core/issues/837
|
40
|
+
isFirefox() && getComputedStyle(offsetParent).position === 'fixed') {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
return offsetParent;
|
44
|
+
};
|
45
|
+
var getOffsetParent = function getOffsetParent(element) {
|
46
|
+
var window = getWindow(element);
|
47
|
+
var offsetParent = getTrueOffsetParent(element);
|
48
|
+
|
49
|
+
// Find the nearest non-table offsetParent
|
50
|
+
while (offsetParent && isTableElement(offsetParent)) {
|
51
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
52
|
+
}
|
53
|
+
if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {
|
54
|
+
return window;
|
55
|
+
}
|
56
|
+
return offsetParent || window;
|
57
|
+
};
|
58
|
+
exports.getOffsetParent = getOffsetParent;
|
59
|
+
//# sourceMappingURL=getOffsetParent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getOffsetParent.js","names":["getWindow","node","toString","ownerDocument","defaultView","window","getNodeName","element","nodeName","toLowerCase","getComputedStyle","isHTMLElement","OwnElement","HTMLElement","isTableElement","indexOf","isFirefox","InstallTrigger","getTrueOffsetParent","offsetParent","position","getOffsetParent","exports"],"sources":["../../../src/utils/getOffsetParent.ts"],"sourcesContent":["// extracted from @popperjs/core@2.11.5 to make it buildable\n\nconst getWindow = (node: any): any => {\n if (node.toString() !== '[object Window]') {\n const ownerDocument = node.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView : window;\n }\n\n return node;\n};\n\nconst getNodeName = (element?: Node | Window): string => {\n return element ? ((element as any).nodeName || '').toLowerCase() : null;\n};\n\nconst getComputedStyle = (element: Element): CSSStyleDeclaration => {\n return getWindow(element).getComputedStyle(element);\n};\n\nconst isHTMLElement = (node: any) => {\n const OwnElement = getWindow(node).HTMLElement;\n return node instanceof OwnElement || node instanceof HTMLElement;\n};\n\nconst isTableElement = (element: Element): boolean => {\n return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;\n};\n\n// https://stackoverflow.com/a/9851769/2059996\nconst isFirefox = () => typeof (window as any).InstallTrigger !== 'undefined';\n\nconst getTrueOffsetParent = (element: HTMLElement): HTMLElement | null => {\n let offsetParent;\n\n if (\n !isHTMLElement(element) ||\n // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>\n !(offsetParent = element.offsetParent) ||\n // https://github.com/popperjs/popper-core/issues/837\n (isFirefox() && getComputedStyle(offsetParent).position === 'fixed')\n ) {\n return null;\n }\n\n return offsetParent as HTMLElement;\n};\n\nexport const getOffsetParent = (element: HTMLElement) => {\n const window = getWindow(element);\n\n let offsetParent = getTrueOffsetParent(element);\n\n // Find the nearest non-table offsetParent\n while (offsetParent && isTableElement(offsetParent)) {\n offsetParent = getTrueOffsetParent(offsetParent);\n }\n\n if (\n offsetParent &&\n getNodeName(offsetParent) === 'body' &&\n getComputedStyle(offsetParent).position === 'static'\n ) {\n return window;\n }\n\n return offsetParent || window;\n};\n"],"mappings":";;;;;;AAAA;;AAEA,IAAMA,SAAS,GAAG,SAAZA,SAASA,CAAIC,IAAS,EAAU;EACpC,IAAIA,IAAI,CAACC,QAAQ,EAAE,KAAK,iBAAiB,EAAE;IACzC,IAAMC,aAAa,GAAGF,IAAI,CAACE,aAAa;IACxC,OAAOA,aAAa,GAAGA,aAAa,CAACC,WAAW,GAAGC,MAAM;EAC3D;EAEA,OAAOJ,IAAI;AACb,CAAC;AAED,IAAMK,WAAW,GAAG,SAAdA,WAAWA,CAAIC,OAAuB,EAAa;EACvD,OAAOA,OAAO,GAAG,CAAEA,OAAO,CAASC,QAAQ,IAAI,EAAE,EAAEC,WAAW,EAAE,GAAG,IAAI;AACzE,CAAC;AAED,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIH,OAAgB,EAA0B;EAClE,OAAOP,SAAS,CAACO,OAAO,CAAC,CAACG,gBAAgB,CAACH,OAAO,CAAC;AACrD,CAAC;A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AOf,MAAM;EACf;EAEA,OAAOc,YAAY,IAAId,MAAM;AAC/B,CAAC;AAACiB,OAAA,CAAAD,eAAA,GAAAA,eAAA"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import getOffsetParent from '
|
1
|
+
import { getOffsetParent } from '../utils/getOffsetParent';
|
2
2
|
var clamp = function clamp(value, boundary1, boundary2) {
|
3
3
|
var min = Math.min(boundary1, boundary2);
|
4
4
|
var max = Math.max(boundary1, boundary2);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cursorAnchoring.js","names":["getOffsetParent","clamp","value","boundary1","boundary2","min","Math","max","getWindowRect","x","y","width","window","innerWidth","height","innerHeight","cursorAnchoringModifier","name","phase","enabled","fn","_ref","state","options","placement","verticalPlacement","startsWith","cursorAnchoring","mouseEnterCursorPositionRef","rects","elements","_mouseEnterCursorPosi","offsetParent","popper","offsetParentRect","getBoundingClientRect","mouseX","current","undefined","reference","_mouseEnterCursorPosi2","mouseY"],"sources":["../../../src/modifiers/cursorAnchoring.
|
1
|
+
{"version":3,"file":"cursorAnchoring.js","names":["getOffsetParent","clamp","value","boundary1","boundary2","min","Math","max","getWindowRect","x","y","width","window","innerWidth","height","innerHeight","cursorAnchoringModifier","name","phase","enabled","fn","_ref","state","options","placement","verticalPlacement","startsWith","cursorAnchoring","mouseEnterCursorPositionRef","rects","elements","_mouseEnterCursorPosi","offsetParent","popper","offsetParentRect","getBoundingClientRect","mouseX","current","undefined","reference","_mouseEnterCursorPosi2","mouseY"],"sources":["../../../src/modifiers/cursorAnchoring.ts"],"sourcesContent":["import { getOffsetParent } from '../utils/getOffsetParent';\nimport { Modifier } from '@popperjs/core';\n\nconst clamp = (value: number, boundary1: number, boundary2: number) => {\n const min = Math.min(boundary1, boundary2);\n const max = Math.max(boundary1, boundary2);\n return Math.min(Math.max(value, min), max);\n};\n\ntype Options = {\n cursorAnchoring: true;\n mouseEnterCursorPositionRef: { current: { x: number; y: number } };\n};\n\nconst getWindowRect = () => ({ x: 0, y: 0, width: window.innerWidth, height: window.innerHeight });\n\nexport const cursorAnchoringModifier: Modifier<'cursorAnchoring', Options> = {\n name: 'cursorAnchoring',\n phase: 'beforeRead',\n enabled: true,\n fn: ({ state, options }) => {\n const { placement } = state.options;\n\n const verticalPlacement =\n !placement || placement.startsWith('top') || placement.startsWith('bottom');\n\n const { cursorAnchoring, mouseEnterCursorPositionRef } = options;\n const { rects, elements } = state;\n if (!cursorAnchoring) return;\n if (verticalPlacement) {\n const offsetParent = getOffsetParent(elements.popper);\n const offsetParentRect =\n offsetParent === window ? getWindowRect() : offsetParent.getBoundingClientRect();\n const mouseX = mouseEnterCursorPositionRef?.current?.x;\n if (mouseX === undefined) return;\n const width = Math.min(rects.reference.width, rects.popper.width);\n const x = clamp(\n mouseX - offsetParentRect.x - width / 2,\n rects.reference.x,\n rects.reference.x + rects.reference.width - width,\n );\n rects.reference.x = x;\n rects.reference.width = width;\n } else {\n const offsetParent = getOffsetParent(elements.popper);\n const offsetParentRect =\n offsetParent === window ? getWindowRect() : offsetParent.getBoundingClientRect();\n const mouseY = mouseEnterCursorPositionRef?.current?.y;\n if (mouseY === undefined) return;\n const height = Math.min(rects.reference.height, rects.popper.height);\n const y = clamp(\n mouseY - offsetParentRect.y - height / 2,\n rects.reference.y,\n rects.reference.y + rects.reference.height - height,\n );\n rects.reference.y = y;\n rects.reference.height = height;\n }\n },\n};\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,0BAA0B;AAG1D,IAAMC,KAAK,GAAG,SAARA,KAAKA,CAAIC,KAAa,EAAEC,SAAiB,EAAEC,SAAiB,EAAK;EACrE,IAAMC,GAAG,GAAGC,IAAI,CAACD,GAAG,CAACF,SAAS,EAAEC,SAAS,CAAC;EAC1C,IAAMG,GAAG,GAAGD,IAAI,CAACC,GAAG,CAACJ,SAAS,EAAEC,SAAS,CAAC;EAC1C,OAAOE,IAAI,CAACD,GAAG,CAACC,IAAI,CAACC,GAAG,CAACL,KAAK,EAAEG,GAAG,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S,CAAC7B,CAAC,GAAGmB,KAAK,CAACU,SAAS,CAACzB,MAAM,GAAGA,MAAM,CACpD;MACDe,KAAK,CAACU,SAAS,CAAC7B,CAAC,GAAGA,CAAC;MACrBmB,KAAK,CAACU,SAAS,CAACzB,MAAM,GAAGA,MAAM;IACjC;EACF;AACF,CAAC"}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
// extracted from @popperjs/core@2.11.5 to make it buildable
|
2
|
+
|
3
|
+
var getWindow = function getWindow(node) {
|
4
|
+
if (node.toString() !== '[object Window]') {
|
5
|
+
var ownerDocument = node.ownerDocument;
|
6
|
+
return ownerDocument ? ownerDocument.defaultView : window;
|
7
|
+
}
|
8
|
+
return node;
|
9
|
+
};
|
10
|
+
var getNodeName = function getNodeName(element) {
|
11
|
+
return element ? (element.nodeName || '').toLowerCase() : null;
|
12
|
+
};
|
13
|
+
var getComputedStyle = function getComputedStyle(element) {
|
14
|
+
return getWindow(element).getComputedStyle(element);
|
15
|
+
};
|
16
|
+
var isHTMLElement = function isHTMLElement(node) {
|
17
|
+
var OwnElement = getWindow(node).HTMLElement;
|
18
|
+
return node instanceof OwnElement || node instanceof HTMLElement;
|
19
|
+
};
|
20
|
+
var isTableElement = function isTableElement(element) {
|
21
|
+
return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
22
|
+
};
|
23
|
+
|
24
|
+
// https://stackoverflow.com/a/9851769/2059996
|
25
|
+
var isFirefox = function isFirefox() {
|
26
|
+
return typeof window.InstallTrigger !== 'undefined';
|
27
|
+
};
|
28
|
+
var getTrueOffsetParent = function getTrueOffsetParent(element) {
|
29
|
+
var offsetParent;
|
30
|
+
if (!isHTMLElement(element) ||
|
31
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
32
|
+
!(offsetParent = element.offsetParent) ||
|
33
|
+
// https://github.com/popperjs/popper-core/issues/837
|
34
|
+
isFirefox() && getComputedStyle(offsetParent).position === 'fixed') {
|
35
|
+
return null;
|
36
|
+
}
|
37
|
+
return offsetParent;
|
38
|
+
};
|
39
|
+
export var getOffsetParent = function getOffsetParent(element) {
|
40
|
+
var window = getWindow(element);
|
41
|
+
var offsetParent = getTrueOffsetParent(element);
|
42
|
+
|
43
|
+
// Find the nearest non-table offsetParent
|
44
|
+
while (offsetParent && isTableElement(offsetParent)) {
|
45
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
46
|
+
}
|
47
|
+
if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {
|
48
|
+
return window;
|
49
|
+
}
|
50
|
+
return offsetParent || window;
|
51
|
+
};
|
52
|
+
//# sourceMappingURL=getOffsetParent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getOffsetParent.js","names":["getWindow","node","toString","ownerDocument","defaultView","window","getNodeName","element","nodeName","toLowerCase","getComputedStyle","isHTMLElement","OwnElement","HTMLElement","isTableElement","indexOf","isFirefox","InstallTrigger","getTrueOffsetParent","offsetParent","position","getOffsetParent"],"sources":["../../../src/utils/getOffsetParent.ts"],"sourcesContent":["// extracted from @popperjs/core@2.11.5 to make it buildable\n\nconst getWindow = (node: any): any => {\n if (node.toString() !== '[object Window]') {\n const ownerDocument = node.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView : window;\n }\n\n return node;\n};\n\nconst getNodeName = (element?: Node | Window): string => {\n return element ? ((element as any).nodeName || '').toLowerCase() : null;\n};\n\nconst getComputedStyle = (element: Element): CSSStyleDeclaration => {\n return getWindow(element).getComputedStyle(element);\n};\n\nconst isHTMLElement = (node: any) => {\n const OwnElement = getWindow(node).HTMLElement;\n return node instanceof OwnElement || node instanceof HTMLElement;\n};\n\nconst isTableElement = (element: Element): boolean => {\n return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;\n};\n\n// https://stackoverflow.com/a/9851769/2059996\nconst isFirefox = () => typeof (window as any).InstallTrigger !== 'undefined';\n\nconst getTrueOffsetParent = (element: HTMLElement): HTMLElement | null => {\n let offsetParent;\n\n if (\n !isHTMLElement(element) ||\n // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>\n !(offsetParent = element.offsetParent) ||\n // https://github.com/popperjs/popper-core/issues/837\n (isFirefox() && getComputedStyle(offsetParent).position === 'fixed')\n ) {\n return null;\n }\n\n return offsetParent as HTMLElement;\n};\n\nexport const getOffsetParent = (element: HTMLElement) => {\n const window = getWindow(element);\n\n let offsetParent = getTrueOffsetParent(element);\n\n // Find the nearest non-table offsetParent\n while (offsetParent && isTableElement(offsetParent)) {\n offsetParent = getTrueOffsetParent(offsetParent);\n }\n\n if (\n offsetParent &&\n getNodeName(offsetParent) === 'body' &&\n getComputedStyle(offsetParent).position === 'static'\n ) {\n return window;\n }\n\n return offsetParent || window;\n};\n"],"mappings":"AAAA;;AAEA,IAAMA,SAAS,GAAG,SAAZA,SAASA,CAAIC,IAAS,EAAU;EACpC,IAAIA,IAAI,CAACC,QAAQ,EAAE,KAAK,iBAAiB,EAAE;IACzC,IAAMC,aAAa,GAAGF,IAAI,CAACE,aAAa;IACxC,OAAOA,aAAa,GAAGA,aAAa,CAACC,WAAW,GAAGC,MAAM;EAC3D;EAEA,OAAOJ,IAAI;AACb,CAAC;AAED,IAAMK,WAAW,GAAG,SAAdA,WAAWA,CAAIC,OAAuB,EAAa;EACvD,OAAOA,OAAO,GAAG,CAAEA,OAAO,CAASC,QAAQ,IAAI,EAAE,EAAEC,WAAW,EAAE,GAAG,IAAI;AACzE,CAAC;AAED,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIH,OAAgB,EAA0B;EAClE,OAAOP,SAAS,CAACO,OAAO,CAAC,CAACG,gBAAgB,CAACH,OAAO,CAAC;AACrD,CAAC;AAED,IAAMI,aAAa,GAAG,SAAhBA,aAAaA,CAAIV,IAAS,EAAK;EACnC,IAAMW,UAAU,GAAGZ,SAAS,CAACC,IAAI,CAAC,CAACY,WAAW;EAC9C,OAAOZ,IAAI,YAAYW,UAAU,IAAIX,IAAI,YAA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