js.foresight 2.2.0 → 2.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.
- package/README.md +17 -10
- package/dist/index.d.ts +8 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
[](https://opensource.org/licenses/MIT)
|
|
11
11
|
[](https://foresightjs.com/)
|
|
12
12
|
|
|
13
|
-
ForesightJS is a lightweight JavaScript library with full TypeScript support that predicts user intent based on mouse movements and keyboard navigation. By analyzing cursor trajectory and tab sequences, it anticipates which elements a user is likely to interact with, allowing developers to trigger actions before the actual hover or click occurs (for example prefetching).
|
|
13
|
+
ForesightJS is a lightweight JavaScript library with full TypeScript support that predicts user intent based on mouse movements, scroll and keyboard navigation. By analyzing cursor/scroll trajectory and tab sequences, it anticipates which elements a user is likely to interact with, allowing developers to trigger actions before the actual hover or click occurs (for example prefetching).
|
|
14
14
|
|
|
15
15
|
### Understanding ForesightJS's Role:
|
|
16
16
|
|
|
@@ -54,11 +54,11 @@ Many routers rely on hover-based prefetching, but this approach completely exclu
|
|
|
54
54
|
|
|
55
55
|
### The ForesightJS Solution
|
|
56
56
|
|
|
57
|
-
ForesightJS bridges the gap between wasteful viewport prefetching and basic hover prefetching. The `ForesightManager` predicts user interactions by analyzing mouse trajectory patterns and keyboard navigation sequences. This allows you to prefetch resources at the optimal time to improve performance, but targeted enough to avoid waste.
|
|
57
|
+
ForesightJS bridges the gap between wasteful viewport prefetching and basic hover prefetching. The `ForesightManager` predicts user interactions by analyzing mouse trajectory patterns, scroll direction and keyboard navigation sequences. This allows you to prefetch resources at the optimal time to improve performance, but targeted enough to avoid waste.
|
|
58
58
|
|
|
59
59
|
## Basic Usage Example
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
This basic example is in vanilla JS, ofcourse most people will use ForesightJS with a framework. You can read about framework integrations in the [docs](https://foresightjs.com/docs/integrations).
|
|
62
62
|
|
|
63
63
|
```javascript
|
|
64
64
|
import { ForesightManager } from "foresightjs"
|
|
@@ -85,15 +85,9 @@ const { isTouchDevice, unregister } = ForesightManager.instance.register({
|
|
|
85
85
|
unregister()
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
## What About Touch Devices?
|
|
89
|
-
|
|
90
|
-
ForesightJS focuses on using mouse movement for prefetching, so you'll need your own approach for touch devices like phones and tablets. The `ForesightManager.instance.register()` method returns an `isTouchDevice` boolean that you can use to create this separate logic. You can safely call `register()` even on touch devices, as the Foresight manager will bounce touch devices to avoid unnecessary processing.
|
|
91
|
-
|
|
92
|
-
An example of what to do with touch devices can be found in the [Next.js](https://foresightjs.com/docs/integrations/nextjs) or [React Router](https://foresightjs.com/docs/integrations/react) ForesightLink components.
|
|
93
|
-
|
|
94
88
|
## Integrations
|
|
95
89
|
|
|
96
|
-
Since ForesightJS is framework agnostic, it can be integrated with any JavaScript framework. While I haven't yet built integrations for every framework, ready-to-use implementations for [Next.js](https://foresightjs.com/docs/integrations/nextjs) and [React Router](https://foresightjs.com/docs/integrations/react) are already available. Sharing integrations for other frameworks/packages is highly appreciated!
|
|
90
|
+
Since ForesightJS is framework agnostic, it can be integrated with any JavaScript framework. While I haven't yet built [integrations](https://foresightjs.com/docs/integrations) for every framework, ready-to-use implementations for [Next.js](https://foresightjs.com/docs/integrations/react/nextjs) and [React Router](https://foresightjs.com/docs/integrations/react/react-router) are already available. Sharing integrations for other frameworks/packages is highly appreciated!
|
|
97
91
|
|
|
98
92
|
## Configuration
|
|
99
93
|
|
|
@@ -103,6 +97,19 @@ ForesightJS can be used bare-bones but also can be configured. For all configura
|
|
|
103
97
|
|
|
104
98
|
ForesightJS includes a [Visual Debugging](https://foresightjs.com/docs/getting_started/debug) system that helps you understand and tune how foresight is working in your application. This is particularly helpful when setting up ForesightJS for the first time or when fine-tuning for specific UI components.
|
|
105
99
|
|
|
100
|
+
## What About Touch Devices and Slow Connections?
|
|
101
|
+
|
|
102
|
+
Since ForesightJS relies on the keyboard/mouse it will not register elements for touch devices. For limited connections (2G or data-saver mode), we respect the user's preference to minimize data usage and skip registration aswell.
|
|
103
|
+
|
|
104
|
+
The `ForesightManager.instance.register()` method returns these properties:
|
|
105
|
+
|
|
106
|
+
- `isTouchDevice` - true if user is on a touch device
|
|
107
|
+
- `isLimitedConnection` - true when user is on a 2G connection or has data-saver enabled
|
|
108
|
+
- `isRegistered` - true if element was actually registered
|
|
109
|
+
|
|
110
|
+
With these properties you could create your own fallback prefetching methods if required. For example if the user is on a touch device you could prefetch based on viewport.
|
|
111
|
+
An example of this can be found in the [Next.js](https://foresightjs.com/docs/integrations/react/nextjs) or [React Router](https://foresightjs.com/docs/integrations/react/react-router) ForesightLink components.
|
|
112
|
+
|
|
106
113
|
## How Does ForesightJS Work?
|
|
107
114
|
|
|
108
115
|
For a detailed technical explanation of its prediction algorithms and internal architecture, see the **[Behind the Scenes documentation](https://foresightjs.com/docs/Behind_the_Scenes)**.
|
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ type DebuggerSettings = {
|
|
|
50
50
|
* with a secondary documentOrder sort.
|
|
51
51
|
* - `'documentOrder'`: Sorts elements based on their order of appearance in the
|
|
52
52
|
* document's structure (matching the HTML source).
|
|
53
|
+
* - `'insertionOrder'`: Sorts by registration order.
|
|
54
|
+
*
|
|
53
55
|
*
|
|
54
56
|
* @link https://foresightjs.com/docs/getting_started/debug
|
|
55
57
|
*
|
|
@@ -73,7 +75,11 @@ type TrajectoryHitData = {
|
|
|
73
75
|
type ForesightRegisterResult = {
|
|
74
76
|
/** Whether the current device is a touch device. This is important as ForesightJS only works based on cursor movement. If the user is using a touch device you should handle prefetching differently */
|
|
75
77
|
isTouchDevice: boolean;
|
|
76
|
-
/**
|
|
78
|
+
/** Whether the user has connection limitations (slow network (2g) or data saver enabled) that should prevent prefetching */
|
|
79
|
+
isLimitedConnection: boolean;
|
|
80
|
+
/** Whether ForesightJS will actively track this element. False if touch device or limited connection, true otherwise */
|
|
81
|
+
isRegistered: boolean;
|
|
82
|
+
/** Function to unregister the element */
|
|
77
83
|
unregister: () => void;
|
|
78
84
|
};
|
|
79
85
|
/**
|
|
@@ -121,7 +127,7 @@ type CallbackHits = {
|
|
|
121
127
|
* Snapshot of the current ForesightManager state
|
|
122
128
|
*/
|
|
123
129
|
type ForesightManagerData = {
|
|
124
|
-
registeredElements:
|
|
130
|
+
registeredElements: ReadonlyMap<ForesightElement, ForesightElementData>;
|
|
125
131
|
globalSettings: Readonly<ForesightManagerSettings>;
|
|
126
132
|
globalCallbackHits: Readonly<CallbackHits>;
|
|
127
133
|
};
|
package/dist/index.js
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* tabbable 6.2.0
|
|
4
4
|
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
5
5
|
*/
|
|
6
|
-
var e=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"].join(","),n="undefined"==typeof Element,i=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,o=!n&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},r=function t(e,n){var i;void 0===n&&(n=!0);var o=null==e||null===(i=e.getAttribute)||void 0===i?void 0:i.call(e,"inert");return""===o||"true"===o||n&&e&&t(e.parentNode)},s=function t(n,o,s){for(var a=[],l=Array.from(n);l.length;){var c=l.shift();if(!r(c,!1))if("SLOT"===c.tagName){var d=c.assignedElements(),u=t(d.length?d:c.children,!0,s);s.flatten?a.push.apply(a,u):a.push({scopeParent:c,candidates:u})}else{i.call(c,e)&&s.filter(c)&&(o||!n.includes(c))&&a.push(c);var h=c.shadowRoot||"function"==typeof s.getShadowRoot&&s.getShadowRoot(c),g=!r(h,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(c));if(h&&g){var p=t(!0===h?c.children:h.children,!0,s);s.flatten?a.push.apply(a,p):a.push({scopeParent:c,candidates:p})}else l.unshift.apply(l,c.children)}}return a},a=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},l=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&!a(t)?0:t.tabIndex},c=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},d=function(t){return"INPUT"===t.tagName},u=function(t){return function(t){return d(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||o(t),i=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=i(window.CSS.escape(t.name));else try{e=i(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var r=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!r||r===t}(t)},h=function(t){var e=t.getBoundingClientRect(),n=e.width,i=e.height;return 0===n&&0===i},g=function(t,e){var n=e.displayCheck,r=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var s=i.call(t,"details>summary:first-of-type")?t.parentElement:t;if(i.call(s,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return h(t)}else{if("function"==typeof r){for(var a=t;t;){var l=t.parentElement,c=o(t);if(l&&!l.shadowRoot&&!0===r(l))return h(t);t=t.assignedSlot?t.assignedSlot:l||c===t.ownerDocument?l:c.host}t=a}if(function(t){var e,n,i,r,s=t&&o(t),a=null===(e=s)||void 0===e?void 0:e.host,l=!1;if(s&&s!==t)for(l=!!(null!==(n=a)&&void 0!==n&&null!==(i=n.ownerDocument)&&void 0!==i&&i.contains(a)||null!=t&&null!==(r=t.ownerDocument)&&void 0!==r&&r.contains(t));!l&&a;){var c,d,u;l=!(null===(d=a=null===(c=s=o(a))||void 0===c?void 0:c.host)||void 0===d||null===(u=d.ownerDocument)||void 0===u||!u.contains(a))}return l}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},p=function(t,e){return!(e.disabled||r(e)||function(t){return d(t)&&"hidden"===t.type}(e)||g(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var o=e.children.item(n);if("LEGEND"===o.tagName)return!!i.call(e,"fieldset[disabled] *")||!o.contains(t)}return!0}e=e.parentElement}return!1}(e))},b=function(t,e){return!(u(e)||l(e)<0||!p(t,e))},m=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},f=function t(e){var n=[],i=[];return e.forEach((function(e,o){var r=!!e.scopeParent,s=r?e.scopeParent:e,c=function(t,e){var n=l(t);return n<0&&e&&!a(t)?0:n}(s,r),d=r?t(e.candidates):s;0===c?r?n.push.apply(n,d):n.push(s):i.push({documentOrder:o,tabIndex:c,item:e,isScope:r,content:d})})),i.sort(c).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},v=function(t,n){var o;return o=(n=n||{}).getShadowRoot?s([t],n.includeContainer,{filter:b.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:m}):function(t,n,o){if(r(t))return[];var s=Array.prototype.slice.apply(t.querySelectorAll(e));return n&&i.call(t,e)&&s.unshift(t),s.filter(o)}(t,n.includeContainer,b.bind(null,n)),f(o)},y="ms",S="points",x="tabs",w=2e3,C=!1,k=!0;var E=function(t,e){void 0===e&&(e=2);var n=" ".repeat(e);if("object"==typeof t&&null!==t&&!Array.isArray(t)){var i=Object.entries(t);if(0===i.length)return"{}";var o=i.map((function(t){var i=t[0],o=t[1];return"".concat(n," ").concat(i,": ").concat(E(o,e+2))})).join(",\n");return"{\n".concat(o,"\n").concat(n,"}")}return"string"==typeof t?"'".concat(t,"'"):"boolean"==typeof t||"number"==typeof t?String(t):null===t?"null":void 0===t?"undefined":Array.isArray(t)?JSON.stringify(t):String(t)};function M(t,e,n){var i=document.createElement(t);return n.id&&(i.id=n.id),n.className&&(i.className=n.className),n.data&&i.setAttribute("data-value",n.data),e.appendChild(i)}function O(t,e,n){var i=document.createElement("style");return i.textContent=t,i.id=n,e.appendChild(i)}var j=function(t){return t?"👁️":"🚫"},T='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>',P="<em>No elements registered.</em>",I=function(){function t(t){this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems=new Map,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.scrollEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.scrollMarginSlider=null,this.scrollMarginValueSpan=null,this.showNameTagsCheckbox=null,this.sortOptionsPopup=null,this.sortButton=null,this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.isContainerMinimized=!1,this.isMouseSettingsMinimized=!0,this.isKeyboardSettingsMinimized=!0,this.isScrollSettingsMinimized=!0,this.isGeneralSettingsMinimized=!0,this.SESSION_STORAGE_KEY="jsforesightDebuggerSectionStates",this.copySettingsButton=null,this.copyTimeoutId=null,this.closeSortDropdownHandler=null,this.foresightManagerInstance=t}return t.prototype._setupDOMAndListeners=function(t,e){var n;this.controlsContainer||(this.shadowRoot=t,this.isContainerMinimized=null!==(n=e.isControlPanelDefaultMinimized)&&void 0!==n?n:C,this.controlsContainer=this.createControlContainer(),this.shadowRoot.appendChild(this.controlsContainer),this.controlPanelStyleElement=O(this.getStyles(),this.shadowRoot,"debug-control-panel"),this.queryDOMElements(),this.originalSectionStates(),this.setupEventListeners(),this.updateContainerVisibilityState())},t.initialize=function(e,n,i){t.isInitiated||(t.debuggerControlPanelInstance=new t(e));var o=t.debuggerControlPanelInstance;return o._setupDOMAndListeners(n,i),o},Object.defineProperty(t,"isInitiated",{get:function(){return!!t.debuggerControlPanelInstance},enumerable:!1,configurable:!0}),t.prototype.loadSectionStatesFromSessionStorage=function(){var t,e,n,i,o=sessionStorage.getItem(this.SESSION_STORAGE_KEY),r={};return o&&(r=JSON.parse(o)),this.isMouseSettingsMinimized=null===(t=r.mouse)||void 0===t||t,this.isKeyboardSettingsMinimized=null===(e=r.keyboard)||void 0===e||e,this.isScrollSettingsMinimized=null===(n=r.scroll)||void 0===n||n,this.isGeneralSettingsMinimized=null===(i=r.general)||void 0===i||i,r},t.prototype.saveSectionStatesToSessionStorage=function(){var t={mouse:this.isMouseSettingsMinimized,keyboard:this.isKeyboardSettingsMinimized,scroll:this.isScrollSettingsMinimized,general:this.isGeneralSettingsMinimized};try{sessionStorage.setItem(this.SESSION_STORAGE_KEY,JSON.stringify(t))}catch(t){console.error("Foresight Debugger: Could not save section states to session storage.",t)}},t.prototype.queryDOMElements=function(){this.trajectoryEnabledCheckbox=this.controlsContainer.querySelector("#trajectory-enabled"),this.tabEnabledCheckbox=this.controlsContainer.querySelector("#tab-enabled"),this.scrollEnabledCheckbox=this.controlsContainer.querySelector("#scroll-enabled"),this.historySizeSlider=this.controlsContainer.querySelector("#history-size"),this.historyValueSpan=this.controlsContainer.querySelector("#history-value"),this.predictionTimeSlider=this.controlsContainer.querySelector("#prediction-time"),this.predictionValueSpan=this.controlsContainer.querySelector("#prediction-value"),this.tabOffsetSlider=this.controlsContainer.querySelector("#tab-offset"),this.tabOffsetValueSpan=this.controlsContainer.querySelector("#tab-offset-value"),this.scrollMarginSlider=this.controlsContainer.querySelector("#scroll-margin"),this.scrollMarginValueSpan=this.controlsContainer.querySelector("#scroll-margin-value"),this.elementListItemsContainer=this.controlsContainer.querySelector("#element-list-items-container"),this.showNameTagsCheckbox=this.controlsContainer.querySelector("#toggle-name-tags"),this.sortOptionsPopup=this.controlsContainer.querySelector("#sort-options-popup"),this.sortButton=this.controlsContainer.querySelector(".sort-button"),this.elementCountSpan=this.controlsContainer.querySelector("#element-count"),this.callbackCountSpan=this.controlsContainer.querySelector("#callback-count"),this.containerMinimizeButton=this.controlsContainer.querySelector(".minimize-button"),this.allSettingsSectionsContainer=this.controlsContainer.querySelector(".all-settings-sections-container"),this.debuggerElementsSection=this.controlsContainer.querySelector(".debugger-elements"),this.copySettingsButton=this.controlsContainer.querySelector(".copy-settings-button")},t.prototype.handleCopySettings=function(){var t,e,n,i=this;this.copySettingsButton&&navigator.clipboard.writeText((t=this.foresightManagerInstance.getManagerData.globalSettings,e="ForesightManager.initialize",n=Object.entries(t).filter((function(t){var e=t[0];return"resizeScrollThrottleDelay"!==String(e)})).map((function(t){var e=t[0],n=t[1];return" ".concat(String(e),": ").concat(E(n))})).join(",\n"),"".concat(e,"({\n").concat(n,"\n})"))).then((function(){i.copySettingsButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',i.copyTimeoutId&&clearTimeout(i.copyTimeoutId),i.copyTimeoutId=setTimeout((function(){i.copySettingsButton&&(i.copySettingsButton.innerHTML=T),i.copyTimeoutId=null}),3e3)})).catch((function(t){console.error("Foresight Debugger: Could not copy settings to clipboard",t)}))},t.prototype.createInputEventListener=function(t,e,n,i){var o=this;t&&e&&t.addEventListener("input",(function(t){var r,s=parseInt(t.target.value,10);e.textContent="".concat(s," ").concat(n),o.foresightManagerInstance.alterGlobalSettings(((r={})[i]=s,r))}))},t.prototype.createChangeEventListener=function(t,e){var n=this;t&&t.addEventListener("change",(function(t){var i;"name-tag"===e?n.foresightManagerInstance.alterGlobalSettings({debuggerSettings:{showNameTags:t.target.checked}}):n.foresightManagerInstance.alterGlobalSettings(((i={})[e]=t.target.checked,i))}))},t.prototype.createSectionVisibilityToggleEventListener=function(t,e){var n=this,i=null==t?void 0:t.querySelector(".debugger-section-header");null==i||i.addEventListener("click",(function(i){i.stopPropagation(),n.toggleMinimizeSection(t,n[e]=!n[e])}))},t.prototype.setupEventListeners=function(){var t,e,n,i,o=this;this.createChangeEventListener(this.trajectoryEnabledCheckbox,"enableMousePrediction"),this.createChangeEventListener(this.tabEnabledCheckbox,"enableTabPrediction"),this.createChangeEventListener(this.scrollEnabledCheckbox,"enableScrollPrediction"),this.createChangeEventListener(this.showNameTagsCheckbox,"name-tag"),this.createInputEventListener(this.historySizeSlider,this.historyValueSpan,S,"positionHistorySize"),this.createInputEventListener(this.predictionTimeSlider,this.predictionValueSpan,y,"trajectoryPredictionTime"),this.createInputEventListener(this.tabOffsetSlider,this.tabOffsetValueSpan,x,"tabOffset"),this.createInputEventListener(this.scrollMarginSlider,this.scrollMarginValueSpan,"px","scrollMargin"),null===(t=this.sortButton)||void 0===t||t.addEventListener("click",(function(t){var e;t.stopPropagation(),null===(e=o.sortOptionsPopup)||void 0===e||e.classList.toggle("active")})),null===(e=this.sortOptionsPopup)||void 0===e||e.addEventListener("click",(function(t){var e,n=t.target.closest("[data-sort]");if(n){var i=n.dataset.sort;o.foresightManagerInstance.alterGlobalSettings({debuggerSettings:{sortElementList:i}}),console.log("here"),o.sortAndReorderElements(),o.updateSortOptionUI(i),null===(e=o.sortOptionsPopup)||void 0===e||e.classList.remove("active")}})),this.closeSortDropdownHandler=function(t){var e,n;(null===(e=o.sortOptionsPopup)||void 0===e?void 0:e.classList.contains("active"))&&!(null===(n=o.sortButton)||void 0===n?void 0:n.contains(t.target))&&o.sortOptionsPopup.classList.remove("active")},document.addEventListener("click",this.closeSortDropdownHandler),null===(n=this.containerMinimizeButton)||void 0===n||n.addEventListener("click",(function(){o.isContainerMinimized=!o.isContainerMinimized,o.updateContainerVisibilityState()})),null===(i=this.copySettingsButton)||void 0===i||i.addEventListener("click",this.handleCopySettings.bind(this)),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".mouse-settings-section"),"isMouseSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".keyboard-settings-section"),"isKeyboardSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".scroll-settings-section"),"isScrollSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".general-settings-section"),"isGeneralSettingsMinimized")},t.prototype.toggleMinimizeSection=function(t,e){if(t){var n=t.querySelector(".debugger-section-content"),i=t.querySelector(".section-minimize-button");n&&i&&(e?(n.style.display="none",i.textContent="+"):(n.style.display="flex",i.textContent="-")),this.saveSectionStatesToSessionStorage()}},t.prototype.originalSectionStates=function(){var t,e,n,i,o,r=this.loadSectionStatesFromSessionStorage();this.toggleMinimizeSection(this.controlsContainer.querySelector(".mouse-settings-section"),null===(t=r.mouse)||void 0===t||t),this.toggleMinimizeSection(this.controlsContainer.querySelector(".keyboard-settings-section"),null===(e=r.keyboard)||void 0===e||e),this.toggleMinimizeSection(this.controlsContainer.querySelector(".scroll-settings-section"),null===(n=r.scroll)||void 0===n||n),this.toggleMinimizeSection(this.controlsContainer.querySelector(".general-settings-section"),null===(i=r.general)||void 0===i||i);var s=null===(o=this.debuggerElementsSection)||void 0===o?void 0:o.querySelector(".debugger-section-content");s&&(s.style.display="flex")},t.prototype.updateContainerVisibilityState=function(){this.containerMinimizeButton&&(this.isContainerMinimized?(this.controlsContainer.classList.add("minimized"),this.containerMinimizeButton.textContent="+",this.allSettingsSectionsContainer&&(this.allSettingsSectionsContainer.style.display="none"),this.debuggerElementsSection&&(this.debuggerElementsSection.style.display="none"),this.copySettingsButton&&(this.copySettingsButton.style.display="none")):(this.controlsContainer.classList.remove("minimized"),this.containerMinimizeButton.textContent="-",this.allSettingsSectionsContainer&&(this.allSettingsSectionsContainer.style.display=""),this.debuggerElementsSection&&(this.debuggerElementsSection.style.display=""),this.copySettingsButton&&(this.copySettingsButton.style.display="")))},t.prototype.updateSortOptionUI=function(t){var e;null===(e=this.sortOptionsPopup)||void 0===e||e.querySelectorAll("[data-sort]").forEach((function(e){var n=e;n.dataset.sort===t?n.classList.add("active-sort-option"):n.classList.remove("active-sort-option")}))},t.prototype.updateControlsState=function(t){var e,n;this.trajectoryEnabledCheckbox&&(this.trajectoryEnabledCheckbox.checked=t.enableMousePrediction),this.tabEnabledCheckbox&&(this.tabEnabledCheckbox.checked=t.enableTabPrediction),this.scrollEnabledCheckbox&&(this.scrollEnabledCheckbox.checked=t.enableScrollPrediction),this.showNameTagsCheckbox&&(this.showNameTagsCheckbox.checked=null!==(e=t.debuggerSettings.showNameTags)&&void 0!==e?e:k),this.updateSortOptionUI(null!==(n=t.debuggerSettings.sortElementList)&&void 0!==n?n:"visibility"),this.historySizeSlider&&this.historyValueSpan&&(this.historySizeSlider.value=t.positionHistorySize.toString(),this.historyValueSpan.textContent="".concat(t.positionHistorySize," ").concat(S)),this.predictionTimeSlider&&this.predictionValueSpan&&(this.predictionTimeSlider.value=t.trajectoryPredictionTime.toString(),this.predictionValueSpan.textContent="".concat(t.trajectoryPredictionTime," ").concat(y)),this.tabOffsetSlider&&this.tabOffsetValueSpan&&(this.tabOffsetSlider.value=t.tabOffset.toString(),this.tabOffsetValueSpan.textContent="".concat(t.tabOffset," ").concat(x)),this.scrollMarginSlider&&this.scrollMarginValueSpan&&(this.scrollMarginSlider.value=t.scrollMargin.toString(),this.scrollMarginValueSpan.textContent="".concat(t.scrollMargin," ").concat("px"))},t.prototype.refreshRegisteredElementCountDisplay=function(t){if(this.elementCountSpan&&this.callbackCountSpan){var e=0;t.forEach((function(t){t.isIntersectingWithViewport&&e++}));var n=t.size,i=this.foresightManagerInstance.getManagerData.globalCallbackHits,o=i.tab,r=i.mouse,s=i.scroll,a=i.total;this.elementCountSpan.textContent="Visible: ".concat(e,"/").concat(n," ~ "),this.elementCountSpan.title=["Element Visibility Status","━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Visible in Viewport: ".concat(e),"Not in Viewport: ".concat(n-e),"Total Registered Elements: ".concat(n),"","Note: Only elements visible in the viewport","are actively tracked by intersection observers."].join("\n"),this.callbackCountSpan.textContent="Mouse: ".concat(r.hover+r.trajectory," Tab: ").concat(o.forwards+o.reverse," Scroll: ").concat(s.down+s.left+s.right+s.up),this.callbackCountSpan.title=["Callback Execution Stats","━━━━━━━━━━━━━━━━━━━━━━━━","Mouse Callbacks"," • Trajectory: ".concat(r.trajectory)," • Hover: ".concat(r.hover)," • Subtotal: ".concat(r.hover+r.trajectory),"","Keyboard Callbacks:"," • Tab Forward: ".concat(o.forwards)," • Tab Reverse: ".concat(o.reverse)," • Subtotal: ".concat(o.forwards+o.reverse),"","Scroll Callbacks:"," • Up: ".concat(s.up," | Down: ").concat(s.down)," • Left: ".concat(s.left," | Right: ").concat(s.right)," • Subtotal: ".concat(s.up+s.down+s.left+s.right),"","Total Callbacks: "+a].join("\n")}},t.prototype.removeElementFromList=function(t){if(this.elementListItemsContainer){var e=this.elementListItems.get(t.element);if(e){e.remove(),this.elementListItems.delete(t.element);var n=this.foresightManagerInstance.registeredElements;this.refreshRegisteredElementCountDisplay(n),0===this.elementListItems.size&&(this.elementListItemsContainer.innerHTML=P)}}},t.prototype.updateElementVisibilityStatus=function(t){if(this.elementListItemsContainer){var e=this.elementListItems.get(t.element);if(e){e.classList.toggle("not-in-viewport",!t.isIntersectingWithViewport);var n=e.querySelector(".intersecting-indicator");if(n){var i=j(t.isIntersectingWithViewport);n.textContent=i}this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements),this.sortAndReorderElements()}else this.addElementToList(t)}},t.prototype.sortAndReorderElements=function(){var t,e=this;if(this.elementListItemsContainer){var n=null!==(t=this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.sortElementList)&&void 0!==t?t:"visibility",i=Array.from(this.foresightManagerInstance.registeredElements.values());if("insertionOrder"!==n){var o=function(t,e){var n=t.element.compareDocumentPosition(e.element);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0};"visibility"===n?i.sort((function(t,e){return t.isIntersectingWithViewport!==e.isIntersectingWithViewport?t.isIntersectingWithViewport?-1:1:o(t,e)})):"documentOrder"===n&&i.sort(o)}var r=document.createDocumentFragment();i.length&&(i.forEach((function(t){var n=e.elementListItems.get(t.element);n&&r.appendChild(n)})),this.elementListItemsContainer.innerHTML="",this.elementListItemsContainer.appendChild(r))}},t.prototype.addElementToList=function(t,e){if(void 0===e&&(e=!0),this.elementListItemsContainer&&(this.elementListItemsContainer.innerHTML===P&&(this.elementListItemsContainer.innerHTML=""),!this.elementListItems.has(t.element))){var n=document.createElement("div");n.className="element-list-item",this.updateListItemContent(n,t),this.elementListItemsContainer.appendChild(n),this.elementListItems.set(t.element,n),this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements),e&&this.sortAndReorderElements()}},t.prototype.updateListItemContent=function(t,e){var n=j(e.isIntersectingWithViewport);t.classList.toggle("not-in-viewport",!e.isIntersectingWithViewport);var i=e.unregisterOnCallback?"Single":"Multi",o="N/A";if(e.elementBounds.hitSlop){var r=e.elementBounds.hitSlop,s=r.top,a=r.right,l=r.bottom,c=r.left;o="T:".concat(s," R:").concat(a," B:").concat(l," L:").concat(c)}var d=["".concat(e.name||"Unnamed Element"),"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Viewport Status:",e.isIntersectingWithViewport?" ✓ In viewport - actively tracked by observers":" ✗ Not in viewport - not being tracked","","Hit Behavior:",e.unregisterOnCallback?" • Single: Callback triggers once":" • Multi: Callback can trigger multiple times","","Hit Slop:",e.elementBounds.hitSlop?[" Top: ".concat(e.elementBounds.hitSlop.top,"px, Bottom: ").concat(e.elementBounds.hitSlop.bottom,"px ")," Right: ".concat(e.elementBounds.hitSlop.right,"px, Left: ").concat(e.elementBounds.hitSlop.left,"px")].join("\n"):" • Not defined - using element's natural boundaries",""].join("\n");t.title=d,t.innerHTML='\n <span class="intersecting-indicator">'.concat(n,'</span>\n <span class="element-name">').concat(e.name||"Unnamed Element",'</span>\n <span class="hit-slop">').concat(o,'</span>\n <span class="hit-behavior">').concat(i,"</span>\n ")},t.prototype.cleanup=function(){var t,e;null===(t=this.controlsContainer)||void 0===t||t.remove(),null===(e=this.controlPanelStyleElement)||void 0===e||e.remove(),this.copyTimeoutId&&(clearTimeout(this.copyTimeoutId),this.copyTimeoutId=null),this.closeSortDropdownHandler&&(document.removeEventListener("click",this.closeSortDropdownHandler),this.closeSortDropdownHandler=null),this.controlsContainer=null,this.controlPanelStyleElement=null,this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems.clear(),this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.scrollEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.scrollMarginSlider=null,this.scrollMarginValueSpan=null,this.showNameTagsCheckbox=null,this.sortOptionsPopup=null,this.sortButton=null,this.copySettingsButton=null},t.prototype.createControlContainer=function(){var t=document.createElement("div");return t.id="debug-controls",t.innerHTML='\n <div class="debugger-title-container">\n <button class="minimize-button">-</button>\n <div class="title-group">\n <h2>Foresight Debugger</h2>\n <span class="info-icon" title="'.concat(["Foresight Debugger Information","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Session-Only Changes:","All adjustments made here apply only to the","current browser session and won't persist.","","Permanent Configuration:","To make lasting changes, update the initial","values in your ForesightManager.initialize().","","You can copy the current debugger settings","with the button on the right"].join("\n"),'">i</span>\n </div>\n <button class="copy-settings-button" title="').concat(["Copy Settings to Clipboard","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Copies the current configuration as a","formatted method call that you can paste","directly into your code."].join("\n"),'">\n ').concat(T,'\n </button>\n </div>\n\n <div class="all-settings-sections-container">\n <div class="debugger-section mouse-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>Mouse Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content mouse-settings-content">\n <div class="control-row">\n <label for="trajectory-enabled">\n Enable Mouse Prediction\n <span class="info-icon" title="').concat(["Mouse Prediction Control","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","When enabled: Predicts mouse movement","trajectory and triggers callbacks before","the cursor reaches the target element.","","When disabled: Only direct hover events","trigger actions (next to tab/scroll).","","Property: enableMousePrediction"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="trajectory-enabled">\n </div>\n <div class="control-row">\n <label for="history-size">\n History Size\n <span class="info-icon" title="').concat(["Position History","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Controls how many past mouse positions","are stored for velocity calculations.","","Higher values:"," • More accurate trajectory predictions"," • Smoother movement detection"," • Slightly increased processing overhead","","Lower values:"," • Faster response to direction changes"," • Less memory usage"," • May be less accurate for fast movements","","Property: positionHistorySize"].join("\n"),'">i</span>\n </label>\n <input type="range" id="history-size" min="').concat(2,'" max="').concat(30,'">\n <span id="history-value"></span>\n </div>\n <div class="control-row">\n <label for="prediction-time">\n Prediction Time\n <span class="info-icon" title="').concat(["Trajectory Prediction Time","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","How far into the future (in ".concat(y,")"),"to calculate the mouse trajectory path.","","Larger values:"," • Elements are detected sooner"," • More time for preloading/preparation"," • May trigger false positives for curved paths","","Smaller values:"," • More precise targeting"," • Reduced false positive rate"," • Less time for preparation","","Property: trajectoryPredictionTime"].join("\n"),'">i</span>\n </label>\n <input type="range" id="prediction-time" min="').concat(10,'" max="').concat(200,'" step="10">\n <span id="prediction-value"></span>\n </div>\n </div>\n </div>\n\n <div class="debugger-section keyboard-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>Keyboard Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content keyboard-settings-content">\n <div class="control-row">\n <label for="tab-enabled">\n Enable Tab Prediction\n <span class="info-icon" title="').concat(["Tab Navigation Prediction","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","When enabled: Callbacks are executed when","the user is ".concat(this.foresightManagerInstance.getManagerData.globalSettings.tabOffset," (tabOffset) ").concat(x," away from"),"a registered element during tab navigation.","","(works with Shift+Tab too).","","Property: enableTabPrediction"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="tab-enabled">\n </div>\n <div class="control-row">\n <label for="tab-offset">\n Tab Offset\n <span class="info-icon" title="').concat(["Tab Offset","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Number of tabbable elements to look ahead","when predicting tab navigation targets.","","How it works:"," • Tracks the current focused element"," • Looks ahead by the specified offset"," • Triggers callbacks for registered elements"," within that range","","Property: tabOffset"].join("\n"),'">i</span>\n </label>\n <input type="range" id="tab-offset" min="').concat(0,'" max="').concat(20,'" step="1">\n <span id="tab-offset-value"></span>\n </div>\n </div>\n </div>\n\n <div class="debugger-section scroll-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>Scroll Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content scroll-settings-content">\n <div class="control-row">\n <label for="scroll-enabled">\n Enable Scroll Prediction\n <span class="info-icon" title="').concat(["Scroll Prediction","━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Enables predictive scrolling based on mouse","position and scroll direction.","","When enabled, calculates scroll direction from","mouse movement and triggers callbacks for","elements that intersect the predicted path.","","Property: enableScrollPrediction"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="scroll-enabled">\n </div>\n <div class="control-row">\n <label for="scroll-margin">\n Scroll Margin\n <span class="info-icon" title="').concat(["Scroll Margin","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sets the pixel distance to check from the","mouse position in the scroll direction.","","Higher values check further ahead, allowing","earlier detection of elements that will come","into view during scrolling.","","Property: scrollMargin"].join("\n"),'">i</span>\n </label>\n <input type="range" id="scroll-margin" min="').concat(30,'" max="').concat(300,'" step="10">\n <span id="scroll-margin-value"></span>\n </div>\n </div>\n\n <div class="debugger-section general-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>General Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content general-settings-content">\n <div class="control-row">\n <label for="toggle-name-tags">\n Show Name Tags\n <span class="info-icon" title="').concat(["Visual Debug Name Tags","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","When enabled: Displays name tags over","each registered element in debug mode.","","Property: debuggerSettings.showNameTags"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="toggle-name-tags">\n </div>\n </div>\n </div>\n </div>\n\n <div class="debugger-section debugger-elements">\n <div class="debugger-section-header elements-list-header">\n <h3>Elements <span id="element-count"></span> <span id="callback-count"></span></h3>\n <div class="header-controls">\n <div class="sort-control-container">\n <button class="sort-button" title="Change element list sort order">\n ').concat('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon></svg>','\n </button>\n <div id="sort-options-popup">\n <button\n data-sort="visibility"\n title="').concat(["Sort by Visibility","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sorts elements by their viewport visibility","(visible elements first), with a secondary","sort by their order in the document.","","Property: debuggerSettings.sortElementList","Value: 'visibility'"].join("\n"),'"\n>\n Visibility\n</button>\n<button\n data-sort="documentOrder"\n title="').concat(["Sort by Document Order","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sorts elements based on their order of","appearance in the document's structure","(matching the HTML source).","","Property: debuggerSettings.sortElementList","Value: 'documentOrder'"].join("\n"),'"\n>\n Document Order\n</button>\n<button\n data-sort="insertionOrder"\n title="').concat(["Sort by Insertion Order","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sorts elements based on the order they","were registered with the ForesightManager.","","Property: debuggerSettings.sortElementList","Value: 'insertionOrder'"].join("\n"),'"\n>\n Insertion Order\n</button>\n </div>\n </div>\n </div>\n </div>\n <div class="debugger-section-content element-list">\n <div id="element-list-items-container">\n </div>\n </div>\n </div>\n '),t},t.prototype.getStyles=function(){return'\n #debug-controls {\n position: fixed; bottom: 10px; right: 10px;\n background-color: rgba(0, 0, 0, 0.90); color: white; padding: 12px;\n border-radius: 5px; font-family: Arial, sans-serif; font-size: 13px;\n z-index: 10001; pointer-events: auto; display: flex; flex-direction: column; gap: 8px;\n width: 400px;\n transition: width 0.3s ease, height 0.3s ease;\n }\n #debug-controls.minimized {\n width: 220px;\n overflow: hidden;\n padding: 12px 0; \n }\n #debug-controls.minimized .debugger-title-container {\n justify-content: flex-start; \n padding-left: 10px; \n padding-right: 10px;\n gap: 10px; \n }\n #debug-controls.minimized .debugger-title-container h2 {\n display: inline;\n font-size: 14px;\n margin: 0;\n white-space: nowrap;\n }\n #debug-controls.minimized .info-icon {\n display: none;\n }\n\n #element-count,#callback-count {\n font-size: 12px;\n color: #9e9e9e;\n }\n\n .debugger-title-container {\n display: flex;\n align-items: center;\n justify-content: space-between; \n padding: 0 0px; \n }\n .title-group { \n display: flex;\n align-items: center;\n gap: 8px; \n\n }\n .minimize-button {\n background: none; border: none; color: white;\n font-size: 22px; cursor: pointer;\n line-height: 1;\n }\n .debugger-title-container h2 { margin: 0; font-size: 15px; }\n\n .copy-settings-button {\n background: none; border: none; color: white;\n cursor: pointer; padding: 0;\n display: flex; align-items: center; justify-content: center;\n }\n .copy-settings-button svg {\n width: 16px; height: 16px;\n stroke: white;\n }\n\n .all-settings-sections-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n\n .debugger-section-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-top: 5px;\n margin-bottom: 2px;\n padding-bottom: 2px;\n border-bottom: 1px solid #444;\n }\n .debugger-section-header.collapsible {\n cursor: pointer;\n }\n .debugger-section-header h3 {\n margin: 0;\n font-size: 14px;\n font-weight: bold;\n color: #b0c4de;\n flex-grow: 1;\n }\n\n .section-minimize-button {\n background: none;\n border: none;\n color: white;\n font-size: 18px;\n cursor: pointer;\n padding: 0;\n line-height: 1;\n }\n\n #debug-controls .control-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n #debug-controls label {\n display: flex;\n align-items: center;\n gap: 5px;\n cursor: pointer;\n }\n #debug-controls .control-row:has(input[type="checkbox"]) label {\n flex-grow: 1;\n }\n #debug-controls .control-row input[type="checkbox"] {\n appearance: none; -webkit-appearance: none; -moz-appearance: none;\n position: relative; width: 40px; height: 18px;\n background-color: #555; border-radius: 10px; cursor: pointer;\n outline: none; transition: background-color 0.2s ease;\n vertical-align: middle; flex-shrink: 0; margin: 0;\n }\n #debug-controls .control-row input[type="checkbox"]::before {\n content: ""; position: absolute; width: 14px; height: 14px;\n border-radius: 50%; background-color: white; top: 2px; left: 2px;\n transition: transform 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.4);\n }\n #debug-controls .control-row input[type="checkbox"]:checked {\n background-color: #b0c4de;\n }\n #debug-controls .control-row input[type="checkbox"]:checked::before {\n transform: translateX(22px);\n }\n #debug-controls .control-row:has(input[type="range"]) label {\n flex-basis: 170px; flex-shrink: 0;\n }\n #debug-controls input[type="range"] {\n flex-grow: 1; margin: 0; cursor: pointer; -webkit-appearance: none;\n appearance: none; background: transparent; height: 18px; vertical-align: middle;\n }\n #debug-controls input[type="range"]::-webkit-slider-runnable-track {\n height: 6px; background: #555; border-radius: 3px;\n }\n #debug-controls input[type="range"]::-moz-range-track {\n height: 6px; background: #555; border-radius: 3px;\n }\n #debug-controls input[type="range"]::-webkit-slider-thumb {\n -webkit-appearance: none; appearance: none; margin-top: -5px;\n background: #b0c4de; height: 16px; width: 16px;\n border-radius: 50%; border: 1px solid #333;\n }\n #debug-controls input[type="range"]::-moz-range-thumb {\n background: #b0c4de; height: 16px; width: 16px;\n border-radius: 50%; border: 1px solid #333; border: none;\n }\n #debug-controls .control-row:has(input[type="range"]) span:not(.info-icon) {\n width: 55px; min-width: 55px; text-align: right; flex-shrink: 0;\n }\n .info-icon {\n display: inline-flex; align-items: center; justify-content: center;\n width: 16px; height: 16px; border-radius: 50%;\n background-color: #555; color: white; font-size: 10px;\n font-style: italic; font-weight: bold; font-family: \'Georgia\', serif;\n cursor: help; user-select: none; flex-shrink: 0;\n }\n .debugger-section {\n display: flex; flex-direction: column; gap: 6px;\n }\n .debugger-section-content {\n display: none; flex-direction: column; gap: 8px;\n }\n\n /* Element List Styles */\n .elements-list-header { cursor: default; }\n .header-controls {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n .sort-control-container {\n position: relative;\n }\n .sort-button {\n background: none; border: none; color: white; cursor: pointer;\n padding: 0; display: flex; align-items: center; justify-content: center;\n }\n .sort-button svg {\n width: 16px; height: 16px; stroke: #b0c4de; transition: stroke 0.2s;\n }\n .sort-button:hover svg { stroke: white; }\n \n #sort-options-popup {\n position: absolute;\n bottom: calc(100% + 5px);\n right: -5px;\n z-index: 10;\n display: none;\n flex-direction: column;\n gap: 4px;\n background-color: #3a3a3a;\n border: 1px solid #555;\n border-radius: 4px;\n padding: 3px;\n width: 200px;\n box-shadow: 0 4px 8px rgba(0,0,0,0.3);\n }\n #sort-options-popup.active {\n display: flex;\n }\n #sort-options-popup button {\n background: none; border: none; color: #ccc;\n font-size: 12px; text-align: left; padding: 5px 8px;\n cursor: pointer; border-radius: 3px;\n transition: background-color 0.2s, color 0.2s;\n display: flex;\n align-items: center;\n height: 26px;\n }\n #sort-options-popup button:hover {\n background-color: #555;\n color: white;\n }\n #sort-options-popup button.active-sort-option {\n color: #b0c4de;\n font-weight: bold;\n }\n #sort-options-popup button.active-sort-option::before {\n content: \'✓\';\n margin-right: 6px;\n width: 10px;\n }\n #sort-options-popup button::before {\n content: \'\';\n margin-right: 6px;\n width: 10px;\n }\n\n .element-list { /* Scroll container */\n min-height: '.concat(237,"px;\n max-height: ").concat(237,"px; \n overflow-y: auto;\n background-color: rgba(20, 20, 20, 0.5);\n border-radius: 3px;\n padding: 0;\n display: flex;\n }\n\n /* Modern Scrollbar Styling */\n .element-list::-webkit-scrollbar { width: 8px; }\n .element-list::-webkit-scrollbar-track { background: rgba(30, 30, 30, 0.5); border-radius: 4px; }\n .element-list::-webkit-scrollbar-thumb { background-color: rgba(176, 196, 222, 0.5); border-radius: 4px; border: 2px solid rgba(0, 0, 0, 0.2); }\n .element-list::-webkit-scrollbar-thumb:hover { background-color: rgba(176, 196, 222, 0.7); }\n .element-list { scrollbar-width: thin; scrollbar-color: rgba(176, 196, 222, 0.5) rgba(30, 30, 30, 0.5); }\n\n #element-list-items-container { \n display: flex;\n flex-wrap: wrap;\n gap: ").concat(3,"px;\n padding: ").concat(6,"px;\n min-height: ").concat(225,"px;\n box-sizing: border-box;\n align-content: flex-start;\n }\n #element-list-items-container > em {\n flex-basis: 100%;\n text-align: center;\n padding: 10px 0;\n font-style: italic;\n color: #ccc;\n font-size: 12px;\n }\n .element-list-item {\n flex-basis: calc((100% - (").concat(0," * ").concat(3,"px)) / ").concat(1,");\n flex-grow: 0;\n flex-shrink: 0;\n height: ").concat(35,"px;\n box-sizing: border-box;\n padding: 3px 5px;\n border-radius: 2px;\n display: flex;\n align-items: center;\n gap: 5px;\n background-color: rgba(50,50,50,0.7);\n transition: background-color 0.2s ease, opacity 0.2s ease;\n font-size: 11px; \n overflow: hidden;\n }\n \n /* Viewport intersection styling */\n .element-list-item.not-in-viewport { opacity: 0.4; }\n \n .element-list-item .element-name {\n flex-grow: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: 12px; \n font-weight: bold;\n }\n .element-list-item .intersecting-indicator {\n font-size: 12px;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n }\n .element-list-item .hit-behavior,\n .element-list-item .hit-slop {\n font-size: 10px; \n color: #b0b0b0;\n padding: 2px 5px; \n border-radius: 3px; \n background-color: rgba(0,0,0,0.2);\n flex-shrink: 0;\n }\n ")},t}(),z=function(){return window.matchMedia("(pointer: coarse)").matches&&navigator.maxTouchPoints>0};function L(t,e,n){var i=t.expandedOverlay,o=t.nameLabel,r=e.elementBounds.expandedRect,s=r.right-r.left,a=r.bottom-r.top;i.style.width="".concat(s,"px"),i.style.height="".concat(a,"px"),i.style.transform="translate3d(".concat(r.left,"px, ").concat(r.top,"px, 0)"),i.style.display="block",o.textContent=e.name,""!==e.name&&n?(o.style.display="block",o.style.transform="translate3d(".concat(r.left,"px, ").concat(r.top-25,"px, 0)")):o.style.display="none"}var R=class{static intersect(t,e){const n=Math.max(t.left,e.left),i=Math.min(t.right,e.right),o=Math.max(t.top,e.top),r=Math.min(t.bottom,e.bottom),s=Math.max(0,i-n),a=Math.max(0,r-o);return new DOMRect(n,o,s,a)}static clip(t,e){const n={...t.toJSON(),top:t.top+e.top,left:t.left+e.left,bottom:t.bottom-e.bottom,right:t.right-e.right};return n.width=n.right-n.left,n.height=n.bottom-n.top,n}static clipOffsets(t,e){return{top:e.top-t.top,left:e.left-t.left,bottom:t.bottom-e.bottom,right:t.right-e.right}}static equals(t,e){return null==t||null==e?t===e:t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}static sizeEqual(t,e){return Math.round(t.width)===Math.round(e.width)&&Math.round(t.height)===Math.round(e.height)}};function D(t,e){const n=Math.max(t.width,3),i=Math.max(t.height,3),o=t.top-e.top- -1,r=t.left-e.left- -1,s=e.right-t.left-n- -1,a=e.bottom-t.top-i- -1;return`${-Math.round(o)}px ${-Math.round(s)}px ${-Math.round(a)}px ${-Math.round(r)}px`}var B=[...Array.from({length:1e3},((t,e)=>e/1e3)),1],H=class{constructor(t,e,n){this.#t=e,this.#e=n,this.#n=n.clientRect,this.#i(t)}#t;#o=void 0;#e;#n;#r=void 0;get visibleRect(){const t=this.#e.clip;return t?R.clip(this.#n,t):this.#n}get isIntersecting(){const{width:t,height:e}=this.visibleRect;return t>0&&e>0}#i(t){const{root:e,rootBounds:n}=this.#e,{visibleRect:i}=this;this.#o?.disconnect(),this.#o=new IntersectionObserver(this.#s,{root:e,rootMargin:D(i,n),threshold:B}),this.#o.observe(t)}#s=t=>{if(!this.#o)return;const e=t[t.length-1];if(e){const{intersectionRatio:t,boundingClientRect:n}=e,i=this.#n;this.#n=n;const o=this.#r,r=!R.equals(n,i);if(t!==this.#r||r){const i=this.#e.rootBounds,s=R.intersect(n,i),a=s.width>0&&s.height>0;if(!a)return;this.#r=t,(null!=o||r)&&(this.#t(new N(e.target,n,e.intersectionRect,a,i),this),this.#i(e.target))}}};disconnect(){this.#o?.disconnect()}},N=class{constructor(t,e,n,i,o){this.target=t,this.boundingClientRect=e,this.intersectionRect=n,this.isIntersecting=i,this.rootBounds=o}},V=class{constructor(t,e){const n=function(t){return!t||function(t){return t.nodeType===Node.DOCUMENT_NODE}(t)?t?.defaultView??window:t}(t);if(function(t){return _(t)&&t.nodeType===Node.ELEMENT_NODE}(n)){const t=n.ownerDocument??document;this.rootBounds=n.getBoundingClientRect(),this.#a=new ResizeObserver((t=>{for(const n of t){const[{inlineSize:t,blockSize:i}]=n.borderBoxSize;if(R.sizeEqual(this.rootBounds,{width:t,height:i}))continue;const o=n.target.getBoundingClientRect();this.rootBounds=o,e(o,this)}})),this.#a.observe(n),t.addEventListener("scroll",(t=>{t.target&&t.target!==n&&_(t.target)&&t.target.contains(n)&&(this.rootBounds=n.getBoundingClientRect(),e(this.rootBounds,this))}),{capture:!0,passive:!0,signal:this.#l.signal})}else{const t=n.visualViewport??n;this.rootBounds=A(n);const i=()=>{const t=A(n);R.equals(this.rootBounds,t)||(this.rootBounds=t,e(t,this))};t.addEventListener("resize",i,{signal:this.#l.signal})}}#a;#l=new AbortController;rootBounds;disconnect(){this.#a?.disconnect(),this.#l.abort()}};function A(t){const e=t.visualViewport?.width??t.innerWidth,n=t.visualViewport?.height??t.innerHeight;return new DOMRect(0,0,e,n)}function _(t){return"nodeType"in t}var q=class{constructor(t,e){this.#e=e,this.#t=e=>{const n=[];for(const t of e){const e=this.intersections.get(t.target);this.intersections.set(t.target,t),e?.isIntersecting===t.isIntersecting&&R.equals(e?.intersectionRect,t.intersectionRect)||n.push(t)}n.length>0&&t(n,this)}}#t;#c=new Map;#e;intersections=new WeakMap;observe(t){const e=t.ownerDocument;if(!e)return;let n=this.#c.get(e);n||(n=new IntersectionObserver(this.#t,{...this.#e,threshold:B}),this.#c.set(e,n)),n.observe(t)}unobserve(t){const e=t.ownerDocument;if(!e)return;const n=this.#c.get(e);n&&(n.unobserve(t),this.intersections.delete(t))}disconnect(){for(const t of this.#c.values())t.disconnect();this.#c.clear()}},F=class{constructor(t,e){this.#t=t,this.#e=e,this.#d=new V(e?.root,this.#u),this.#h=new q(this.#g,e),this.#a=new ResizeObserver(this.#p)}#t;#e;#b=new Map;#a;#m=new WeakMap;#d;#h;observe(t){this.#h.observe(t)}unobserve(t){t?(this.#b.get(t)?.disconnect(),this.#h.unobserve(t)):this.disconnect()}disconnect(){for(const t of this.#b.values())t.disconnect();this.#a.disconnect(),this.#d.disconnect(),this.#h.disconnect()}#f(t){const e=[];for(const n of t){const{target:t}=n;W(n,this.#m.get(t))||(this.#m.set(t,n),e.push(n))}e.length>0&&this.#t(e)}#u=t=>{const e=[];for(const[n]of this.#b){const i=n.getBoundingClientRect(),o=this.#v(n,i);e.push(new U(n,i,o.visibleRect,o.isIntersecting,t))}this.#f(e)};#v(t,e){const n=this.#h;this.#b.get(t)?.disconnect();const i=new H(t,this.#y,{clientRect:e,root:this.#e?.root,rootBounds:this.#d.rootBounds,get clip(){const e=n.intersections.get(t);if(!e)return;const{intersectionRect:i,boundingClientRect:o}=e;return R.clipOffsets(o,i)}});return this.#b.set(t,i),i}#g=t=>{const e=[];for(const n of t){const{target:t,isIntersecting:i,boundingClientRect:o}=n;i?(this.#v(t,o),this.#a.observe(t)):(this.#b.get(t)?.disconnect(),this.#b.delete(t),this.#a.unobserve(t));const r=this.#b.get(t);e.push(new U(t,o,r?.visibleRect??n.intersectionRect,i,this.#d.rootBounds))}this.#f(e)};#y=(t,e)=>{this.#f([new U(t.target,t.boundingClientRect,e.visibleRect,t.isIntersecting,this.#d.rootBounds)])};#p=t=>{const e=[];for(const n of t){const{target:t,borderBoxSize:i}=n,o=this.#m.get(t);if(o){const[{inlineSize:t,blockSize:e}]=i;if(R.sizeEqual(o.boundingClientRect,{width:t,height:e}))continue}const r=t.getBoundingClientRect(),s=this.#v(t,r);e.push(new U(t,r,s.visibleRect,this.#h.intersections.get(t)?.isIntersecting??!1,this.#d.rootBounds))}this.#f(e)}},U=class{constructor(t,e,n,i,o){this.target=t,this.boundingClientRect=e,this.intersectionRect=n,this.isIntersecting=i,this.rootBounds=o}};function W(t,e){return null!=e&&(t.target===e.target&&t.isIntersecting===e.isIntersecting&&R.equals(t.boundingClientRect,e.boundingClientRect)&&R.equals(t.intersectionRect,e.intersectionRect))}var G=function(){function t(t){var e=this;this.callbackAnimations=new Map,this.debugElementOverlays=new Map,this.predictedMouseIndicator=null,this.mouseTrajectoryLine=null,this.scrollTrajectoryLine=null,this.animationPositionObserver=null,this.handleAnimationPositionChange=function(t){for(var n=0,i=t;n<i.length;n++){var o=i[n],r=e.callbackAnimations.get(o.target);if(r){var s=o.boundingClientRect,a=r.hitSlop,l=r.overlay,c=s.left-a.left,d=s.top-a.top,u=s.width+a.left+a.right,h=s.height+a.top+a.bottom;l.style.transform="translate3d(".concat(c,"px, ").concat(d,"px, 0)"),l.style.width="".concat(u,"px"),l.style.height="".concat(h,"px")}}},this.foresightManagerInstance=t}return t.prototype._setupDOM=function(){this.shadowHost||(this.shadowHost=M("div",document.body,{id:"jsforesight-debugger-shadow-host"}),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"}),this.debugContainer=M("div",this.shadowRoot,{id:"jsforesight-debug-container"}),this.predictedMouseIndicator=M("div",this.debugContainer,{className:"jsforesight-mouse-predicted"}),this.mouseTrajectoryLine=M("div",this.debugContainer,{className:"jsforesight-trajectory-line"}),this.scrollTrajectoryLine=M("div",this.debugContainer,{className:"jsforesight-scroll-trajectory-line"}),this.controlPanel=I.initialize(this.foresightManagerInstance,this.shadowRoot,this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings),O(K,this.shadowRoot,"screen-visuals"),this.animationPositionObserver=new F(this.handleAnimationPositionChange))},Object.defineProperty(t,"isInitiated",{get:function(){return!!t.debuggerInstance},enumerable:!1,configurable:!0}),t.initialize=function(e,n){if(document.querySelectorAll("#jsforesight-debugger-shadow-host").forEach((function(t){return t.remove()})),"undefined"==typeof window||z())return null;t.isInitiated||(t.debuggerInstance=new t(e));var i=t.debuggerInstance;return i.shadowHost||i._setupDOM(),i.updateMouseTrajectoryVisuals(n,e.getManagerData.globalSettings.enableMousePrediction),i},t.prototype.createElementOverlays=function(t){var e={expandedOverlay:M("div",this.debugContainer,{className:"jsforesight-expanded-overlay",data:t.name}),nameLabel:M("div",this.debugContainer,{className:"jsforesight-name-label"})};return this.debugElementOverlays.set(t.element,e),e},t.prototype.createOrUpdateElementOverlay=function(t){var e;if(this.debugContainer&&this.shadowRoot){var n=this.debugElementOverlays.get(t.element);n||(n=this.createElementOverlays(t)),L(n,t,null!==(e=this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==e?e:k)}},t.prototype.toggleNameTagVisibility=function(){var t=this;this.foresightManagerInstance.registeredElements.forEach((function(e){var n,i=t.debugElementOverlays.get(e.element);i&&L(i,e,null!==(n=t.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==n?n:k)}))},t.prototype.removeElement=function(t){var e;this.removeElementOverlay(t),null===(e=this.controlPanel)||void 0===e||e.removeElementFromList(t)},t.prototype.removeElementOverlay=function(t){var e=this.debugElementOverlays.get(t.element);e&&(e.expandedOverlay.remove(),e.nameLabel.remove(),this.debugElementOverlays.delete(t.element))},t.prototype.addElement=function(t,e){void 0===e&&(e=!0),this.createOrUpdateElementOverlay(t),this.controlPanel.addElementToList(t,e)},t.prototype.updateMouseTrajectoryVisuals=function(t,e){if(this.shadowRoot&&this.debugContainer&&this.predictedMouseIndicator&&this.mouseTrajectoryLine){var n=t.predictedPoint,i=t.currentPoint;if(this.predictedMouseIndicator.style.transform="translate3d(".concat(n.x,"px, ").concat(n.y,"px, 0) translate3d(-50%, -50%, 0)"),this.predictedMouseIndicator.style.display=e?"block":"none",0!==n.x||0!==n.y)if(e){var o=n.x-i.x,r=n.y-i.y,s=Math.sqrt(o*o+r*r),a=180*Math.atan2(r,o)/Math.PI;this.mouseTrajectoryLine.style.transform="translate3d(".concat(i.x,"px, ").concat(i.y,"px, 0) rotate(").concat(a,"deg)"),this.mouseTrajectoryLine.style.width="".concat(s,"px"),this.mouseTrajectoryLine.style.display="block"}else this.mouseTrajectoryLine.style.display="none";else this.predictedMouseIndicator.style.display="none"}},t.prototype.updateScrollTrajectoryVisuals=function(t,e){if(this.scrollTrajectoryLine){var n=e.x-t.x,i=e.y-t.y,o=Math.sqrt(n*n+i*i),r=180*Math.atan2(i,n)/Math.PI;this.scrollTrajectoryLine.style.transform="translate3d(".concat(t.x,"px, ").concat(t.y,"px, 0) rotate(").concat(r,"deg)"),this.scrollTrajectoryLine.style.width="".concat(o,"px"),this.scrollTrajectoryLine.style.display="block"}},t.prototype.hideScrollTrajectoryVisuals=function(){this.scrollTrajectoryLine&&(this.scrollTrajectoryLine.style.display="none")},t.prototype.updateControlsState=function(t){var e;null===(e=this.controlPanel)||void 0===e||e.updateControlsState(t)},t.prototype.updateElementVisibilityStatus=function(t){var e;null===(e=this.controlPanel)||void 0===e||e.updateElementVisibilityStatus(t)},t.prototype.removeElementFromList=function(t){var e;null===(e=this.controlPanel)||void 0===e||e.removeElementFromList(t)},t.prototype.showCallbackAnimation=function(t){var e,n,i=this,o=t.element,r=t.elementBounds,s=this.callbackAnimations.get(o);s&&(clearTimeout(s.timeoutId),s.overlay.remove(),null===(e=this.animationPositionObserver)||void 0===e||e.unobserve(o),this.callbackAnimations.delete(o));var a=M("div",this.debugContainer,{className:"jsforesight-callback-indicator"}),l=r.expandedRect,c=l.left,d=l.top,u=l.right-c,h=l.bottom-d;a.style.display="block",a.style.transform="translate3d(".concat(c,"px, ").concat(d,"px, 0)"),a.style.width="".concat(u,"px"),a.style.height="".concat(h,"px"),a.classList.add("animate");var g=setTimeout((function(){var t;a.remove(),i.callbackAnimations.delete(o),null===(t=i.animationPositionObserver)||void 0===t||t.unobserve(o)}),500);this.callbackAnimations.set(o,{hitSlop:t.elementBounds.hitSlop,overlay:a,timeoutId:g}),null===(n=this.animationPositionObserver)||void 0===n||n.observe(o)},t.prototype.cleanup=function(){var t,e;null===(t=this.controlPanel)||void 0===t||t.cleanup(),null===(e=this.shadowHost)||void 0===e||e.remove(),this.debugElementOverlays.clear(),this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.predictedMouseIndicator=null,this.mouseTrajectoryLine=null,this.scrollTrajectoryLine=null,this.controlPanel=null},t}(),K='\n #jsforesight-debug-container { \n position: fixed; top: 0; left: 0; width: 100%; height: 100%;\n pointer-events: none; z-index: 9999;\n }\n\n .jsforesight-expanded-overlay, \n .jsforesight-name-label, \n .jsforesight-callback-indicator,\n .jsforesight-mouse-predicted,\n .jsforesight-scroll-trajectory-line,\n .jsforesight-trajectory-line {\n position: absolute;\n top: 0;\n left: 0;\n will-change: transform; \n }\n .jsforesight-expanded-overlay {\n border: 1px dashed rgba(100, 116, 139, 0.4);\n background-color: rgba(100, 116, 139, 0.05);\n box-sizing: border-box;\n border-radius: 8px;\n }\n .jsforesight-mouse-predicted {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n border: 2px solid #6b98e1;\n background-color: rgba(176, 196, 222, 0.3);\n z-index: 10000;\n /* transform is now set dynamically via JS for performance */\n }\n .jsforesight-trajectory-line {\n height: 2px;\n background-color: #6b98e1;\n transform-origin: left center;\n z-index: 9999;\n border-radius: 1px;\n /* width and transform are set dynamically via JS for performance */\n }\n .jsforesight-name-label {\n background-color: rgba(27, 31, 35, 0.85);\n backdrop-filter: blur(4px);\n color: white;\n padding: 4px 8px;\n font-size: 11px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";\n border-radius: 4px;\n z-index: 10001;\n white-space: nowrap;\n pointer-events: none;\n }\n .jsforesight-callback-indicator {\n border: 4px solid oklch(65% 0.22 280); \n border-radius: 8px;\n box-sizing: border-box;\n pointer-events: none;\n opacity: 0;\n z-index: 10002;\n display: none; \n }\n .jsforesight-callback-indicator.animate {\n animation: jsforesight-callback-pulse 0.5s ease-out forwards;\n }\n \n .jsforesight-scroll-trajectory-line {\n height: 2px;\n background: repeating-linear-gradient(\n 90deg,\n oklch(68% 0.18 145) 0px,\n oklch(68% 0.18 145) 6px,\n transparent 6px,\n transparent 10px\n );\n transform-origin: left center;\n z-index: 9999;\n border-radius: 1px;\n display: none;\n animation: scroll-dash-flow 1.8s linear infinite;\n position: relative;\n }\n\n .jsforesight-scroll-trajectory-line::after {\n content: \'\';\n position: absolute;\n right: -2px;\n top: 50%;\n transform: translateY(-50%);\n width: 6px;\n height: 6px;\n background: oklch(68% 0.18 145);\n border-radius: 50%;\n animation: scroll-escape-squeeze 2.2s ease-in-out infinite;\n }\n\n @keyframes scroll-dash-flow {\n 0% { background-position: 0px 0px; }\n 100% { background-position: 10px 0px; }\n }\n\n @keyframes scroll-escape-squeeze {\n 0%, 100% { \n transform: translateY(-50%) scale(1);\n right: -2px;\n }\n 25% {\n transform: translateY(-50%) scaleX(1.3) scaleY(0.7);\n right: -3px;\n }\n 50% {\n transform: translateY(-50%) scaleX(0.8) scaleY(1.2);\n right: -1px;\n }\n 75% {\n transform: translateY(-50%) scaleX(1.2) scaleY(0.8);\n right: -3px;\n }\n }\n\n \n @keyframes jsforesight-callback-pulse {\n 0% {\n opacity: 1;\n box-shadow: 0 0 15px oklch(65% 0.22 280 / 0.7);\n }\n 100% {\n opacity: 0;\n box-shadow: 0 0 25px oklch(65% 0.22 280 / 0);\n }\n }\n ';function Y(t,e,n,i,o){return i&&(t<e?console.warn('ForesightJS: "'.concat(o,'" value ').concat(t," is below minimum bound ").concat(e,", clamping to ").concat(e)):t>n&&console.warn('ForesightJS: "'.concat(o,'" value ').concat(t," is above maximum bound ").concat(n,", clamping to ").concat(n))),Math.min(Math.max(t,e),n)}function J(t,e,n){var i=0,o=1,r=e.x-t.x,s=e.y-t.y,a=function(t,e){if(0===t){if(e<0)return!1}else{var n=e/t;if(t<0){if(n>o)return!1;n>i&&(i=n)}else{if(n<i)return!1;n<o&&(o=n)}}return!0};return!!a(-r,t.x-n.left)&&(!!a(r,n.right-t.x)&&(!!a(-s,t.y-n.top)&&(!!a(s,n.bottom-t.y)&&i<=o)))}function X(t,e){if("number"==typeof t){var n=Y(t,0,w,e,"hitslop");return{top:n,left:n,right:n,bottom:n}}return{top:Y(t.top,0,w,e,"hitslop - top"),left:Y(t.left,0,w,e,"hitslop - left"),right:Y(t.right,0,w,e,"hitslop - right"),bottom:Y(t.bottom,0,w,e,"hitslop - bottom")}}function $(t,e){return{left:t.left-e.left,right:t.right+e.right,top:t.top-e.top,bottom:t.bottom+e.bottom}}function Q(t,e){return t&&e?t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom:t===e}function Z(t,e){return t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom}function tt(t,e){return void 0!==t&&e!==t}var et=function(){function e(){var t=this;this.elements=new Map,this.isSetup=!1,this.debugger=null,this._globalCallbackHits={mouse:{hover:0,trajectory:0},tab:{forwards:0,reverse:0},scroll:{down:0,left:0,right:0,up:0},total:0},this._globalSettings={debug:false,enableMousePrediction:true,enableScrollPrediction:true,positionHistorySize:8,trajectoryPredictionTime:120,scrollMargin:150,defaultHitSlop:{top:0,left:0,right:0,bottom:0},resizeScrollThrottleDelay:0,debuggerSettings:{isControlPanelDefaultMinimized:C,showNameTags:k,sortElementList:"visibility"},enableTabPrediction:true,tabOffset:2,onAnyCallbackFired:function(t,e){}},this.trajectoryPositions={positions:[],currentPoint:{x:0,y:0},predictedPoint:{x:0,y:0}},this.tabbableElementsCache=[],this.lastFocusedIndex=null,this.predictedScrollPoint=null,this.scrollDirection=null,this.domObserver=null,this.positionObserver=null,this.lastKeyDown=null,this.globalListenersController=null,this.handleMouseMove=function(e){t.updatePointerState(e),t.elements.forEach((function(e){e.isIntersectingWithViewport&&(e.unregisterOnCallback?t.handleSingleCallbackInteraction(e):t.handleMultiCallbackInteraction(e))})),t.debugger&&(t.debugger.hideScrollTrajectoryVisuals(),t.debugger.updateMouseTrajectoryVisuals(t.trajectoryPositions,t._globalSettings.enableMousePrediction))},this.handleDomMutations=function(e){e.length&&(t.tabbableElementsCache=[],t.lastFocusedIndex=null);for(var n=0,i=e;n<i.length;n++){var o=i[n];if("childList"===o.type&&o.removedNodes.length>0)for(var r=0,s=Array.from(t.elements.keys());r<s.length;r++){var a=s[r];a.isConnected||t.unregister(a)}}},this.handleKeyDown=function(e){"Tab"===e.key&&(t.lastKeyDown=e)},this.handleFocusIn=function(e){if(t.lastKeyDown&&t._globalSettings.enableTabPrediction){var n=e.target;if(n instanceof HTMLElement){t.tabbableElementsCache.length||(t.tabbableElementsCache=v(document.documentElement),t._globalSettings.debug&&console.log("ForesightJS: Recomputed tabbable elements cache because of DOM change"));var i=t.lastKeyDown.shiftKey,o=function(t,e,n,i){if(null!==e){var o=t?e-1:e+1;if(o>=0&&o<n.length&&n[o]===i)return o}return n.findIndex((function(t){return t===i}))}(i,t.lastFocusedIndex,t.tabbableElementsCache,n);t.lastFocusedIndex=o,t.lastKeyDown=null;for(var r=[],s=0;s<=t._globalSettings.tabOffset;s++)if(i){var a=t.tabbableElementsCache[o-s];t.elements.has(a)&&r.push(a)}else{a=t.tabbableElementsCache[o+s];t.elements.has(a)&&r.push(a)}r.forEach((function(e){t.callCallback(t.elements.get(e),{kind:"tab",subType:i?"reverse":"forwards"})}))}}},this.handlePositionChange=function(e){for(var n,i,o=0,r=e;o<r.length;o++){var s=r[o],a=t.elements.get(s.target);if(a){var l=a.isIntersectingWithViewport,c=s.isIntersecting;a.isIntersectingWithViewport=c,l!==c&&(null===(n=t.debugger)||void 0===n||n.updateElementVisibilityStatus(a)),c?(t.updateElementBounds(s.boundingClientRect,a),t.handleScrollPrefetch(a,s.boundingClientRect)):t._globalSettings.debug&&l&&(null===(i=t.debugger)||void 0===i||i.removeElementOverlay(a))}}t.scrollDirection=null,t.predictedScrollPoint=null}}return e.initialize=function(t){return this.isInitiated||(e.manager=new e),void 0!==t&&e.manager.alterGlobalSettings(t),e.manager},Object.defineProperty(e.prototype,"getManagerData",{get:function(){return{registeredElements:this.elements,globalSettings:this._globalSettings,globalCallbackHits:this._globalCallbackHits}},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isInitiated",{get:function(){return!!e.manager},enumerable:!1,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return this.initialize()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"registeredElements",{get:function(){return this.elements},enumerable:!1,configurable:!0}),e.prototype.register=function(t){var e,n,i=this,o=t.element,r=t.callback,s=t.hitSlop,a=t.unregisterOnCallback,l=t.name;if(z())return{isTouchDevice:!0,unregister:function(){}};if(this.elements.has(o))return{isTouchDevice:!1,unregister:function(){return i.unregister(o)}};this.isSetup||this.initializeGlobalListeners();var c=s?X(s,this._globalSettings.debug):this._globalSettings.defaultHitSlop,d={element:o,callback:r,callbackHits:{mouse:{hover:0,trajectory:0},tab:{forwards:0,reverse:0},scroll:{down:0,left:0,right:0,up:0},total:0},elementBounds:{originalRect:void 0,expandedRect:{top:0,left:0,right:0,bottom:0},hitSlop:c},isHovering:!1,trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0},name:null!==(e=null!=l?l:o.id)&&void 0!==e?e:"",unregisterOnCallback:null==a||a,isIntersectingWithViewport:!0};return this.elements.set(o,d),null===(n=this.positionObserver)||void 0===n||n.observe(o),this.debugger&&this.debugger.addElement(d),{isTouchDevice:!1,unregister:function(){return i.unregister(o)}}},e.prototype.unregister=function(t){var e;if(this.elements.has(t)){var n=this.elements.get(t);(null==n?void 0:n.trajectoryHitData.trajectoryHitExpirationTimeoutId)&&clearTimeout(n.trajectoryHitData.trajectoryHitExpirationTimeoutId),null===(e=this.positionObserver)||void 0===e||e.unobserve(t),this.elements.delete(t),this.debugger&&n&&this.debugger.removeElement(n),0===this.elements.size&&this.isSetup&&this.removeGlobalListeners()}},e.prototype.updateNumericSettings=function(t,e,n,i){return!!tt(t,this._globalSettings[e])&&(this._globalSettings[e]=Y(t,n,i,this._globalSettings.debug,e),!0)},e.prototype.updateBooleanSetting=function(t,e){return!!tt(t,this._globalSettings[e])&&(this._globalSettings[e]=t,!0)},e.prototype.alterGlobalSettings=function(t){var e,n,i,o=this._globalSettings.positionHistorySize,r=this.updateNumericSettings(null==t?void 0:t.positionHistorySize,"positionHistorySize",2,30);r&&this._globalSettings.positionHistorySize<o&&this.trajectoryPositions.positions.length>this._globalSettings.positionHistorySize&&(this.trajectoryPositions.positions=this.trajectoryPositions.positions.slice(this.trajectoryPositions.positions.length-this._globalSettings.positionHistorySize));var s=this.updateNumericSettings(null==t?void 0:t.trajectoryPredictionTime,"trajectoryPredictionTime",10,200),a=this.updateNumericSettings(null==t?void 0:t.scrollMargin,"scrollMargin",30,300),l=this.updateNumericSettings(null==t?void 0:t.tabOffset,"tabOffset",0,20);void 0!==(null==t?void 0:t.resizeScrollThrottleDelay)&&console.warn("resizeScrollThrottleDelay is deprecated and will be removed in V3.0.0 of ForesightJS");var c=this.updateBooleanSetting(null==t?void 0:t.enableMousePrediction,"enableMousePrediction"),d=this.updateBooleanSetting(null==t?void 0:t.enableScrollPrediction,"enableScrollPrediction"),u=this.updateBooleanSetting(null==t?void 0:t.enableTabPrediction,"enableTabPrediction");void 0!==(null==t?void 0:t.onAnyCallbackFired)&&(this._globalSettings.onAnyCallbackFired=t.onAnyCallbackFired);var h=!1;void 0!==(null===(e=null==t?void 0:t.debuggerSettings)||void 0===e?void 0:e.isControlPanelDefaultMinimized)&&(this._globalSettings.debuggerSettings.isControlPanelDefaultMinimized=t.debuggerSettings.isControlPanelDefaultMinimized,h=!0),void 0!==(null===(n=null==t?void 0:t.debuggerSettings)||void 0===n?void 0:n.showNameTags)&&(this._globalSettings.debuggerSettings.showNameTags=t.debuggerSettings.showNameTags,h=!0,this.debugger&&this.debugger.toggleNameTagVisibility()),void 0!==(null===(i=null==t?void 0:t.debuggerSettings)||void 0===i?void 0:i.sortElementList)&&(this._globalSettings.debuggerSettings.sortElementList=t.debuggerSettings.sortElementList,h=!0,this.debugger);var g=!1;if(void 0!==(null==t?void 0:t.defaultHitSlop)){var p=X(t.defaultHitSlop,this._globalSettings.debug);Q(this._globalSettings.defaultHitSlop,p)||(this._globalSettings.defaultHitSlop=p,g=!0,this.forceUpdateAllElementBounds())}var b=!1;void 0!==(null==t?void 0:t.debug)&&this._globalSettings.debug!==t.debug&&"undefined"!=typeof window&&"undefined"!=typeof document&&(this._globalSettings.debug=t.debug,b=!0,this._globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null)),(r||s||l||c||u||d||h||g||a||b)&&this.debugger&&this.debugger.updateControlsState(this._globalSettings)},e.prototype.turnOnDebugMode=function(){var t=this;if(this.debugger)this.debugger.updateControlsState(this._globalSettings);else{this.debugger=G.initialize(e.instance,this.trajectoryPositions);var n=Array.from(this.elements.values());n.forEach((function(e,i){var o,r=i===n.length-1;null===(o=t.debugger)||void 0===o||o.addElement(e,r)}))}},e.prototype.forceUpdateAllElementBounds=function(){var t=this;this.elements.forEach((function(e,n){var i=t.elements.get(n);i&&i.isIntersectingWithViewport&&t.forceUpdateElementBounds(i)}))},e.prototype.updatePointerState=function(e){this.trajectoryPositions.currentPoint={x:e.clientX,y:e.clientY},this.trajectoryPositions.predictedPoint=this._globalSettings.enableMousePrediction?function(t,e,n,i){var o={point:t,time:performance.now()},r=t.x,s=t.y;if(e.push(o),e.length>n&&e.shift(),e.length<2)return{x:r,y:s};var a=e[0],l=e[e.length-1],c=(l.time-a.time)/1e3;if(0===c)return{x:r,y:s};var d=i/1e3;return{x:r+(l.point.x-a.point.x)/c*d,y:s+(l.point.y-a.point.y)/c*d}}(this.trajectoryPositions.currentPoint,this.trajectoryPositions.positions,this._globalSettings.positionHistorySize,this._globalSettings.trajectoryPredictionTime):t({},this.trajectoryPositions.currentPoint)},e.prototype.handleSingleCallbackInteraction=function(t){var e=t.elementBounds.expandedRect;if(this._globalSettings.enableMousePrediction)J(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,e)&&this.callCallback(t,{kind:"mouse",subType:"trajectory"});else if(Z(this.trajectoryPositions.currentPoint,e))return void this.callCallback(t,{kind:"mouse",subType:"hover"})},e.prototype.handleMultiCallbackInteraction=function(e){var n=this,i=e.elementBounds.expandedRect,o=Z(this.trajectoryPositions.currentPoint,i),r=o&&!e.isHovering,s=this._globalSettings.enableMousePrediction&&!o&&!e.trajectoryHitData.isTrajectoryHit&&J(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,i);if((r||s)&&this.callCallback(e,{kind:"mouse",subType:r?"hover":"trajectory"}),o!==e.isHovering||s){var a=t(t({},e),{isHovering:o,trajectoryHitData:t(t({},e.trajectoryHitData),{isTrajectoryHit:s,trajectoryHitTime:s?performance.now():e.trajectoryHitData.trajectoryHitTime})});s&&(a.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(a.trajectoryHitData.trajectoryHitExpirationTimeoutId),a.trajectoryHitData.trajectoryHitExpirationTimeoutId=setTimeout((function(){var t,i=n.elements.get(e.element);i&&i.trajectoryHitData.trajectoryHitTime===a.trajectoryHitData.trajectoryHitTime&&(i.trajectoryHitData.isTrajectoryHit=!1,null===(t=n.debugger)||void 0===t||t.createOrUpdateElementOverlay(i))}),200)),this.elements.set(e.element,a)}},e.prototype.updateHitCounters=function(t,e){switch(e.kind){case"mouse":t.callbackHits.mouse[e.subType]++,this._globalCallbackHits.mouse[e.subType]++;break;case"tab":t.callbackHits.tab[e.subType]++,this._globalCallbackHits.tab[e.subType]++;break;case"scroll":t.callbackHits.scroll[e.subType]++,this._globalCallbackHits.scroll[e.subType]++}t.callbackHits.total++,this._globalCallbackHits.total++},e.prototype.callCallback=function(t,e){t&&(this.updateHitCounters(t,e),t.callback(),this._globalSettings.onAnyCallbackFired(t,this.getManagerData),this.debugger&&this.debugger.showCallbackAnimation(t),t.unregisterOnCallback&&this.unregister(t.element))},e.prototype.forceUpdateElementBounds=function(e){var n=e.element.getBoundingClientRect(),i=$(n,e.elementBounds.hitSlop);if(!Q(i,e.elementBounds.expandedRect)&&(this.elements.set(e.element,t(t({},e),{elementBounds:t(t({},e.elementBounds),{originalRect:n,expandedRect:i})})),this.debugger)){var o=this.elements.get(e.element);o&&this.debugger.createOrUpdateElementOverlay(o)}},e.prototype.updateElementBounds=function(e,n){if(this.elements.set(n.element,t(t({},n),{elementBounds:t(t({},n.elementBounds),{originalRect:e,expandedRect:$(e,n.elementBounds.hitSlop)})})),this.debugger){var i=this.elements.get(n.element);i&&this.debugger.createOrUpdateElementOverlay(i)}},e.prototype.handleScrollPrefetch=function(t,e){var n,i;if(this._globalSettings.enableScrollPrediction){if(!t.elementBounds.originalRect)return;if(this.scrollDirection=null!==(n=this.scrollDirection)&&void 0!==n?n:function(t,e){var n=e.top-t.top,i=e.left-t.left;return n<-1?"down":n>1?"up":i<-1?"right":i>1?"left":"none"}(t.elementBounds.originalRect,e),"none"===this.scrollDirection)return;this.predictedScrollPoint=null!==(i=this.predictedScrollPoint)&&void 0!==i?i:function(t,e,n){var i={x:t.x,y:t.y};switch(e){case"down":i.y+=n;break;case"up":i.y-=n;break;case"left":i.x-=n;break;case"right":i.x+=n}return i}(this.trajectoryPositions.currentPoint,this.scrollDirection,this._globalSettings.scrollMargin),J(this.trajectoryPositions.currentPoint,this.predictedScrollPoint,null==t?void 0:t.elementBounds.expandedRect)&&this.callCallback(t,{kind:"scroll",subType:this.scrollDirection}),this.debugger&&this.debugger.updateScrollTrajectoryVisuals(this.trajectoryPositions.currentPoint,this.predictedScrollPoint)}else Z(this.trajectoryPositions.currentPoint,t.elementBounds.expandedRect)&&this.callCallback(t,{kind:"mouse",subType:"hover"})},e.prototype.initializeGlobalListeners=function(){if(!this.isSetup&&"undefined"!=typeof window&&"undefined"!=typeof document){this.globalListenersController=new AbortController;var t=this.globalListenersController.signal;document.addEventListener("mousemove",this.handleMouseMove,{signal:t}),document.addEventListener("keydown",this.handleKeyDown,{signal:t}),document.addEventListener("focusin",this.handleFocusIn,{signal:t}),this.domObserver=new MutationObserver(this.handleDomMutations),this.domObserver.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1}),this.positionObserver=new F(this.handlePositionChange),this.isSetup=!0}},e.prototype.removeGlobalListeners=function(){var t,e,n;this.isSetup=!1,this.debugger?console.log("ForesightJS: All elements have successfully been unregistered. ForesightJS would typically perform cleanup events now, but these are currently skipped while in debug mode. Observers are cleared up."):(null===(t=this.globalListenersController)||void 0===t||t.abort(),this.globalListenersController=null),null===(e=this.domObserver)||void 0===e||e.disconnect(),this.domObserver=null,null===(n=this.positionObserver)||void 0===n||n.disconnect(),this.positionObserver=null},e}();exports.ForesightManager=et;
|
|
6
|
+
var e=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"].join(","),n="undefined"==typeof Element,i=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,o=!n&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},r=function t(e,n){var i;void 0===n&&(n=!0);var o=null==e||null===(i=e.getAttribute)||void 0===i?void 0:i.call(e,"inert");return""===o||"true"===o||n&&e&&t(e.parentNode)},s=function t(n,o,s){for(var a=[],l=Array.from(n);l.length;){var c=l.shift();if(!r(c,!1))if("SLOT"===c.tagName){var d=c.assignedElements(),u=t(d.length?d:c.children,!0,s);s.flatten?a.push.apply(a,u):a.push({scopeParent:c,candidates:u})}else{i.call(c,e)&&s.filter(c)&&(o||!n.includes(c))&&a.push(c);var h=c.shadowRoot||"function"==typeof s.getShadowRoot&&s.getShadowRoot(c),g=!r(h,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(c));if(h&&g){var p=t(!0===h?c.children:h.children,!0,s);s.flatten?a.push.apply(a,p):a.push({scopeParent:c,candidates:p})}else l.unshift.apply(l,c.children)}}return a},a=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},l=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&!a(t)?0:t.tabIndex},c=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},d=function(t){return"INPUT"===t.tagName},u=function(t){return function(t){return d(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||o(t),i=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=i(window.CSS.escape(t.name));else try{e=i(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var r=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!r||r===t}(t)},h=function(t){var e=t.getBoundingClientRect(),n=e.width,i=e.height;return 0===n&&0===i},g=function(t,e){var n=e.displayCheck,r=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var s=i.call(t,"details>summary:first-of-type")?t.parentElement:t;if(i.call(s,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return h(t)}else{if("function"==typeof r){for(var a=t;t;){var l=t.parentElement,c=o(t);if(l&&!l.shadowRoot&&!0===r(l))return h(t);t=t.assignedSlot?t.assignedSlot:l||c===t.ownerDocument?l:c.host}t=a}if(function(t){var e,n,i,r,s=t&&o(t),a=null===(e=s)||void 0===e?void 0:e.host,l=!1;if(s&&s!==t)for(l=!!(null!==(n=a)&&void 0!==n&&null!==(i=n.ownerDocument)&&void 0!==i&&i.contains(a)||null!=t&&null!==(r=t.ownerDocument)&&void 0!==r&&r.contains(t));!l&&a;){var c,d,u;l=!(null===(d=a=null===(c=s=o(a))||void 0===c?void 0:c.host)||void 0===d||null===(u=d.ownerDocument)||void 0===u||!u.contains(a))}return l}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},p=function(t,e){return!(e.disabled||r(e)||function(t){return d(t)&&"hidden"===t.type}(e)||g(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var o=e.children.item(n);if("LEGEND"===o.tagName)return!!i.call(e,"fieldset[disabled] *")||!o.contains(t)}return!0}e=e.parentElement}return!1}(e))},b=function(t,e){return!(u(e)||l(e)<0||!p(t,e))},m=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},f=function t(e){var n=[],i=[];return e.forEach((function(e,o){var r=!!e.scopeParent,s=r?e.scopeParent:e,c=function(t,e){var n=l(t);return n<0&&e&&!a(t)?0:n}(s,r),d=r?t(e.candidates):s;0===c?r?n.push.apply(n,d):n.push(s):i.push({documentOrder:o,tabIndex:c,item:e,isScope:r,content:d})})),i.sort(c).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},v=function(t,n){var o;return o=(n=n||{}).getShadowRoot?s([t],n.includeContainer,{filter:b.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:m}):function(t,n,o){if(r(t))return[];var s=Array.prototype.slice.apply(t.querySelectorAll(e));return n&&i.call(t,e)&&s.unshift(t),s.filter(o)}(t,n.includeContainer,b.bind(null,n)),f(o)},y="ms",S="points",x="tabs",w=2e3,C=!1,k=!0;var E=function(t,e){void 0===e&&(e=2);var n=" ".repeat(e);if("object"==typeof t&&null!==t&&!Array.isArray(t)){var i=Object.entries(t);if(0===i.length)return"{}";var o=i.map((function(t){var i=t[0],o=t[1];return"".concat(n," ").concat(i,": ").concat(E(o,e+2))})).join(",\n");return"{\n".concat(o,"\n").concat(n,"}")}return"string"==typeof t?"'".concat(t,"'"):"boolean"==typeof t||"number"==typeof t?String(t):null===t?"null":void 0===t?"undefined":Array.isArray(t)?JSON.stringify(t):String(t)};function M(t,e,n){var i=document.createElement(t);return n.id&&(i.id=n.id),n.className&&(i.className=n.className),n.data&&i.setAttribute("data-value",n.data),e.appendChild(i)}function O(t,e,n){var i=document.createElement("style");return i.textContent=t,i.id=n,e.appendChild(i)}var j=function(t){return t?"👁️":"🚫"},T='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>',P="<em>No elements registered.</em>",I=function(){function t(t){this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems=new Map,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.scrollEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.scrollMarginSlider=null,this.scrollMarginValueSpan=null,this.showNameTagsCheckbox=null,this.sortOptionsPopup=null,this.sortButton=null,this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.isContainerMinimized=!1,this.isMouseSettingsMinimized=!0,this.isKeyboardSettingsMinimized=!0,this.isScrollSettingsMinimized=!0,this.isGeneralSettingsMinimized=!0,this.SESSION_STORAGE_KEY="jsforesightDebuggerSectionStates",this.copySettingsButton=null,this.copyTimeoutId=null,this.closeSortDropdownHandler=null,this.foresightManagerInstance=t}return t.prototype._setupDOMAndListeners=function(t,e){var n;this.controlsContainer||(this.shadowRoot=t,this.isContainerMinimized=null!==(n=e.isControlPanelDefaultMinimized)&&void 0!==n?n:C,this.controlsContainer=this.createControlContainer(),this.shadowRoot.appendChild(this.controlsContainer),this.controlPanelStyleElement=O(this.getStyles(),this.shadowRoot,"debug-control-panel"),this.queryDOMElements(),this.originalSectionStates(),this.setupEventListeners(),this.updateContainerVisibilityState())},t.initialize=function(e,n,i){t.isInitiated||(t.debuggerControlPanelInstance=new t(e));var o=t.debuggerControlPanelInstance;return o._setupDOMAndListeners(n,i),o},Object.defineProperty(t,"isInitiated",{get:function(){return!!t.debuggerControlPanelInstance},enumerable:!1,configurable:!0}),t.prototype.loadSectionStatesFromSessionStorage=function(){var t,e,n,i,o=sessionStorage.getItem(this.SESSION_STORAGE_KEY),r={};return o&&(r=JSON.parse(o)),this.isMouseSettingsMinimized=null===(t=r.mouse)||void 0===t||t,this.isKeyboardSettingsMinimized=null===(e=r.keyboard)||void 0===e||e,this.isScrollSettingsMinimized=null===(n=r.scroll)||void 0===n||n,this.isGeneralSettingsMinimized=null===(i=r.general)||void 0===i||i,r},t.prototype.saveSectionStatesToSessionStorage=function(){var t={mouse:this.isMouseSettingsMinimized,keyboard:this.isKeyboardSettingsMinimized,scroll:this.isScrollSettingsMinimized,general:this.isGeneralSettingsMinimized};try{sessionStorage.setItem(this.SESSION_STORAGE_KEY,JSON.stringify(t))}catch(t){console.error("Foresight Debugger: Could not save section states to session storage.",t)}},t.prototype.queryDOMElements=function(){this.trajectoryEnabledCheckbox=this.controlsContainer.querySelector("#trajectory-enabled"),this.tabEnabledCheckbox=this.controlsContainer.querySelector("#tab-enabled"),this.scrollEnabledCheckbox=this.controlsContainer.querySelector("#scroll-enabled"),this.historySizeSlider=this.controlsContainer.querySelector("#history-size"),this.historyValueSpan=this.controlsContainer.querySelector("#history-value"),this.predictionTimeSlider=this.controlsContainer.querySelector("#prediction-time"),this.predictionValueSpan=this.controlsContainer.querySelector("#prediction-value"),this.tabOffsetSlider=this.controlsContainer.querySelector("#tab-offset"),this.tabOffsetValueSpan=this.controlsContainer.querySelector("#tab-offset-value"),this.scrollMarginSlider=this.controlsContainer.querySelector("#scroll-margin"),this.scrollMarginValueSpan=this.controlsContainer.querySelector("#scroll-margin-value"),this.elementListItemsContainer=this.controlsContainer.querySelector("#element-list-items-container"),this.showNameTagsCheckbox=this.controlsContainer.querySelector("#toggle-name-tags"),this.sortOptionsPopup=this.controlsContainer.querySelector("#sort-options-popup"),this.sortButton=this.controlsContainer.querySelector(".sort-button"),this.elementCountSpan=this.controlsContainer.querySelector("#element-count"),this.callbackCountSpan=this.controlsContainer.querySelector("#callback-count"),this.containerMinimizeButton=this.controlsContainer.querySelector(".minimize-button"),this.allSettingsSectionsContainer=this.controlsContainer.querySelector(".all-settings-sections-container"),this.debuggerElementsSection=this.controlsContainer.querySelector(".debugger-elements"),this.copySettingsButton=this.controlsContainer.querySelector(".copy-settings-button")},t.prototype.handleCopySettings=function(){var t,e,n,i=this;this.copySettingsButton&&navigator.clipboard.writeText((t=this.foresightManagerInstance.getManagerData.globalSettings,e="ForesightManager.initialize",n=Object.entries(t).filter((function(t){var e=t[0];return"resizeScrollThrottleDelay"!==String(e)})).map((function(t){var e=t[0],n=t[1];return" ".concat(String(e),": ").concat(E(n))})).join(",\n"),"".concat(e,"({\n").concat(n,"\n})"))).then((function(){i.copySettingsButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',i.copyTimeoutId&&clearTimeout(i.copyTimeoutId),i.copyTimeoutId=setTimeout((function(){i.copySettingsButton&&(i.copySettingsButton.innerHTML=T),i.copyTimeoutId=null}),3e3)})).catch((function(t){console.error("Foresight Debugger: Could not copy settings to clipboard",t)}))},t.prototype.createInputEventListener=function(t,e,n,i){var o=this;t&&e&&t.addEventListener("input",(function(t){var r,s=parseInt(t.target.value,10);e.textContent="".concat(s," ").concat(n),o.foresightManagerInstance.alterGlobalSettings(((r={})[i]=s,r))}))},t.prototype.createChangeEventListener=function(t,e){var n=this;t&&t.addEventListener("change",(function(t){var i;"name-tag"===e?n.foresightManagerInstance.alterGlobalSettings({debuggerSettings:{showNameTags:t.target.checked}}):n.foresightManagerInstance.alterGlobalSettings(((i={})[e]=t.target.checked,i))}))},t.prototype.createSectionVisibilityToggleEventListener=function(t,e){var n=this,i=null==t?void 0:t.querySelector(".debugger-section-header");null==i||i.addEventListener("click",(function(i){i.stopPropagation(),n.toggleMinimizeSection(t,n[e]=!n[e])}))},t.prototype.setupEventListeners=function(){var t,e,n,i,o=this;this.createChangeEventListener(this.trajectoryEnabledCheckbox,"enableMousePrediction"),this.createChangeEventListener(this.tabEnabledCheckbox,"enableTabPrediction"),this.createChangeEventListener(this.scrollEnabledCheckbox,"enableScrollPrediction"),this.createChangeEventListener(this.showNameTagsCheckbox,"name-tag"),this.createInputEventListener(this.historySizeSlider,this.historyValueSpan,S,"positionHistorySize"),this.createInputEventListener(this.predictionTimeSlider,this.predictionValueSpan,y,"trajectoryPredictionTime"),this.createInputEventListener(this.tabOffsetSlider,this.tabOffsetValueSpan,x,"tabOffset"),this.createInputEventListener(this.scrollMarginSlider,this.scrollMarginValueSpan,"px","scrollMargin"),null===(t=this.sortButton)||void 0===t||t.addEventListener("click",(function(t){var e;t.stopPropagation(),null===(e=o.sortOptionsPopup)||void 0===e||e.classList.toggle("active")})),null===(e=this.sortOptionsPopup)||void 0===e||e.addEventListener("click",(function(t){var e,n=t.target.closest("[data-sort]");if(n){var i=n.dataset.sort;o.foresightManagerInstance.alterGlobalSettings({debuggerSettings:{sortElementList:i}}),console.log("here"),o.sortAndReorderElements(),o.updateSortOptionUI(i),null===(e=o.sortOptionsPopup)||void 0===e||e.classList.remove("active")}})),this.closeSortDropdownHandler=function(t){var e,n;(null===(e=o.sortOptionsPopup)||void 0===e?void 0:e.classList.contains("active"))&&!(null===(n=o.sortButton)||void 0===n?void 0:n.contains(t.target))&&o.sortOptionsPopup.classList.remove("active")},document.addEventListener("click",this.closeSortDropdownHandler),null===(n=this.containerMinimizeButton)||void 0===n||n.addEventListener("click",(function(){o.isContainerMinimized=!o.isContainerMinimized,o.updateContainerVisibilityState()})),null===(i=this.copySettingsButton)||void 0===i||i.addEventListener("click",this.handleCopySettings.bind(this)),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".mouse-settings-section"),"isMouseSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".keyboard-settings-section"),"isKeyboardSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".scroll-settings-section"),"isScrollSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".general-settings-section"),"isGeneralSettingsMinimized")},t.prototype.toggleMinimizeSection=function(t,e){if(t){var n=t.querySelector(".debugger-section-content"),i=t.querySelector(".section-minimize-button");n&&i&&(e?(n.style.display="none",i.textContent="+"):(n.style.display="flex",i.textContent="-")),this.saveSectionStatesToSessionStorage()}},t.prototype.originalSectionStates=function(){var t,e,n,i,o,r=this.loadSectionStatesFromSessionStorage();this.toggleMinimizeSection(this.controlsContainer.querySelector(".mouse-settings-section"),null===(t=r.mouse)||void 0===t||t),this.toggleMinimizeSection(this.controlsContainer.querySelector(".keyboard-settings-section"),null===(e=r.keyboard)||void 0===e||e),this.toggleMinimizeSection(this.controlsContainer.querySelector(".scroll-settings-section"),null===(n=r.scroll)||void 0===n||n),this.toggleMinimizeSection(this.controlsContainer.querySelector(".general-settings-section"),null===(i=r.general)||void 0===i||i);var s=null===(o=this.debuggerElementsSection)||void 0===o?void 0:o.querySelector(".debugger-section-content");s&&(s.style.display="flex")},t.prototype.updateContainerVisibilityState=function(){this.containerMinimizeButton&&(this.isContainerMinimized?(this.controlsContainer.classList.add("minimized"),this.containerMinimizeButton.textContent="+",this.allSettingsSectionsContainer&&(this.allSettingsSectionsContainer.style.display="none"),this.debuggerElementsSection&&(this.debuggerElementsSection.style.display="none"),this.copySettingsButton&&(this.copySettingsButton.style.display="none")):(this.controlsContainer.classList.remove("minimized"),this.containerMinimizeButton.textContent="-",this.allSettingsSectionsContainer&&(this.allSettingsSectionsContainer.style.display=""),this.debuggerElementsSection&&(this.debuggerElementsSection.style.display=""),this.copySettingsButton&&(this.copySettingsButton.style.display="")))},t.prototype.updateSortOptionUI=function(t){var e;null===(e=this.sortOptionsPopup)||void 0===e||e.querySelectorAll("[data-sort]").forEach((function(e){var n=e;n.dataset.sort===t?n.classList.add("active-sort-option"):n.classList.remove("active-sort-option")}))},t.prototype.updateControlsState=function(t){var e,n;this.trajectoryEnabledCheckbox&&(this.trajectoryEnabledCheckbox.checked=t.enableMousePrediction),this.tabEnabledCheckbox&&(this.tabEnabledCheckbox.checked=t.enableTabPrediction),this.scrollEnabledCheckbox&&(this.scrollEnabledCheckbox.checked=t.enableScrollPrediction),this.showNameTagsCheckbox&&(this.showNameTagsCheckbox.checked=null!==(e=t.debuggerSettings.showNameTags)&&void 0!==e?e:k),this.updateSortOptionUI(null!==(n=t.debuggerSettings.sortElementList)&&void 0!==n?n:"visibility"),this.historySizeSlider&&this.historyValueSpan&&(this.historySizeSlider.value=t.positionHistorySize.toString(),this.historyValueSpan.textContent="".concat(t.positionHistorySize," ").concat(S)),this.predictionTimeSlider&&this.predictionValueSpan&&(this.predictionTimeSlider.value=t.trajectoryPredictionTime.toString(),this.predictionValueSpan.textContent="".concat(t.trajectoryPredictionTime," ").concat(y)),this.tabOffsetSlider&&this.tabOffsetValueSpan&&(this.tabOffsetSlider.value=t.tabOffset.toString(),this.tabOffsetValueSpan.textContent="".concat(t.tabOffset," ").concat(x)),this.scrollMarginSlider&&this.scrollMarginValueSpan&&(this.scrollMarginSlider.value=t.scrollMargin.toString(),this.scrollMarginValueSpan.textContent="".concat(t.scrollMargin," ").concat("px"))},t.prototype.refreshRegisteredElementCountDisplay=function(t){if(this.elementCountSpan&&this.callbackCountSpan){var e=0;t.forEach((function(t){t.isIntersectingWithViewport&&e++}));var n=t.size,i=this.foresightManagerInstance.getManagerData.globalCallbackHits,o=i.tab,r=i.mouse,s=i.scroll,a=i.total;this.elementCountSpan.textContent="Visible: ".concat(e,"/").concat(n," ~ "),this.elementCountSpan.title=["Element Visibility Status","━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Visible in Viewport: ".concat(e),"Not in Viewport: ".concat(n-e),"Total Registered Elements: ".concat(n),"","Note: Only elements visible in the viewport","are actively tracked by intersection observers."].join("\n"),this.callbackCountSpan.textContent="Mouse: ".concat(r.hover+r.trajectory," Tab: ").concat(o.forwards+o.reverse," Scroll: ").concat(s.down+s.left+s.right+s.up),this.callbackCountSpan.title=["Callback Execution Stats","━━━━━━━━━━━━━━━━━━━━━━━━","Mouse Callbacks"," • Trajectory: ".concat(r.trajectory)," • Hover: ".concat(r.hover)," • Subtotal: ".concat(r.hover+r.trajectory),"","Keyboard Callbacks:"," • Tab Forward: ".concat(o.forwards)," • Tab Reverse: ".concat(o.reverse)," • Subtotal: ".concat(o.forwards+o.reverse),"","Scroll Callbacks:"," • Up: ".concat(s.up," | Down: ").concat(s.down)," • Left: ".concat(s.left," | Right: ").concat(s.right)," • Subtotal: ".concat(s.up+s.down+s.left+s.right),"","Total Callbacks: "+a].join("\n")}},t.prototype.removeElementFromList=function(t){if(this.elementListItemsContainer){var e=this.elementListItems.get(t.element);if(e){e.remove(),this.elementListItems.delete(t.element);var n=this.foresightManagerInstance.registeredElements;this.refreshRegisteredElementCountDisplay(n),0===this.elementListItems.size&&(this.elementListItemsContainer.innerHTML=P)}}},t.prototype.updateElementVisibilityStatus=function(t){if(this.elementListItemsContainer){var e=this.elementListItems.get(t.element);if(e){e.classList.toggle("not-in-viewport",!t.isIntersectingWithViewport);var n=e.querySelector(".intersecting-indicator");if(n){var i=j(t.isIntersectingWithViewport);n.textContent=i}this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements),this.sortAndReorderElements()}else this.addElementToList(t)}},t.prototype.sortAndReorderElements=function(){var t,e=this;if(this.elementListItemsContainer){var n=null!==(t=this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.sortElementList)&&void 0!==t?t:"visibility",i=Array.from(this.foresightManagerInstance.registeredElements.values());if("insertionOrder"!==n){var o=function(t,e){var n=t.element.compareDocumentPosition(e.element);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0};"visibility"===n?i.sort((function(t,e){return t.isIntersectingWithViewport!==e.isIntersectingWithViewport?t.isIntersectingWithViewport?-1:1:o(t,e)})):"documentOrder"===n&&i.sort(o)}var r=document.createDocumentFragment();i.length&&(i.forEach((function(t){var n=e.elementListItems.get(t.element);n&&r.appendChild(n)})),this.elementListItemsContainer.innerHTML="",this.elementListItemsContainer.appendChild(r))}},t.prototype.addElementToList=function(t,e){if(void 0===e&&(e=!0),this.elementListItemsContainer&&(this.elementListItemsContainer.innerHTML===P&&(this.elementListItemsContainer.innerHTML=""),!this.elementListItems.has(t.element))){var n=document.createElement("div");n.className="element-list-item",this.updateListItemContent(n,t),this.elementListItemsContainer.appendChild(n),this.elementListItems.set(t.element,n),this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements),e&&this.sortAndReorderElements()}},t.prototype.updateListItemContent=function(t,e){var n=j(e.isIntersectingWithViewport);t.classList.toggle("not-in-viewport",!e.isIntersectingWithViewport);var i=e.unregisterOnCallback?"Single":"Multi",o="N/A";if(e.elementBounds.hitSlop){var r=e.elementBounds.hitSlop,s=r.top,a=r.right,l=r.bottom,c=r.left;o="T:".concat(s," R:").concat(a," B:").concat(l," L:").concat(c)}var d=["".concat(e.name||"Unnamed Element"),"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Viewport Status:",e.isIntersectingWithViewport?" ✓ In viewport - actively tracked by observers":" ✗ Not in viewport - not being tracked","","Hit Behavior:",e.unregisterOnCallback?" • Single: Callback triggers once":" • Multi: Callback can trigger multiple times","","Hit Slop:",e.elementBounds.hitSlop?[" Top: ".concat(e.elementBounds.hitSlop.top,"px, Bottom: ").concat(e.elementBounds.hitSlop.bottom,"px ")," Right: ".concat(e.elementBounds.hitSlop.right,"px, Left: ").concat(e.elementBounds.hitSlop.left,"px")].join("\n"):" • Not defined - using element's natural boundaries",""].join("\n");t.title=d,t.innerHTML='\n <span class="intersecting-indicator">'.concat(n,'</span>\n <span class="element-name">').concat(e.name||"Unnamed Element",'</span>\n <span class="hit-slop">').concat(o,'</span>\n <span class="hit-behavior">').concat(i,"</span>\n ")},t.prototype.cleanup=function(){var t,e;null===(t=this.controlsContainer)||void 0===t||t.remove(),null===(e=this.controlPanelStyleElement)||void 0===e||e.remove(),this.copyTimeoutId&&(clearTimeout(this.copyTimeoutId),this.copyTimeoutId=null),this.closeSortDropdownHandler&&(document.removeEventListener("click",this.closeSortDropdownHandler),this.closeSortDropdownHandler=null),this.controlsContainer=null,this.controlPanelStyleElement=null,this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems.clear(),this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.scrollEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.scrollMarginSlider=null,this.scrollMarginValueSpan=null,this.showNameTagsCheckbox=null,this.sortOptionsPopup=null,this.sortButton=null,this.copySettingsButton=null},t.prototype.createControlContainer=function(){var t=document.createElement("div");return t.id="debug-controls",t.innerHTML='\n <div class="debugger-title-container">\n <button class="minimize-button">-</button>\n <div class="title-group">\n <h2>Foresight Debugger</h2>\n <span class="info-icon" title="'.concat(["Foresight Debugger Information","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Session-Only Changes:","All adjustments made here apply only to the","current browser session and won't persist.","","Permanent Configuration:","To make lasting changes, update the initial","values in your ForesightManager.initialize().","","You can copy the current debugger settings","with the button on the right"].join("\n"),'">i</span>\n </div>\n <button class="copy-settings-button" title="').concat(["Copy Settings to Clipboard","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Copies the current configuration as a","formatted method call that you can paste","directly into your code."].join("\n"),'">\n ').concat(T,'\n </button>\n </div>\n\n <div class="all-settings-sections-container">\n <div class="debugger-section mouse-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>Mouse Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content mouse-settings-content">\n <div class="control-row">\n <label for="trajectory-enabled">\n Enable Mouse Prediction\n <span class="info-icon" title="').concat(["Mouse Prediction Control","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","When enabled: Predicts mouse movement","trajectory and triggers callbacks before","the cursor reaches the target element.","","When disabled: Only direct hover events","trigger actions (next to tab/scroll).","","Property: enableMousePrediction"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="trajectory-enabled">\n </div>\n <div class="control-row">\n <label for="history-size">\n History Size\n <span class="info-icon" title="').concat(["Position History","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Controls how many past mouse positions","are stored for velocity calculations.","","Higher values:"," • More accurate trajectory predictions"," • Smoother movement detection"," • Slightly increased processing overhead","","Lower values:"," • Faster response to direction changes"," • Less memory usage"," • May be less accurate for fast movements","","Property: positionHistorySize"].join("\n"),'">i</span>\n </label>\n <input type="range" id="history-size" min="').concat(2,'" max="').concat(30,'">\n <span id="history-value"></span>\n </div>\n <div class="control-row">\n <label for="prediction-time">\n Prediction Time\n <span class="info-icon" title="').concat(["Trajectory Prediction Time","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","How far into the future (in ".concat(y,")"),"to calculate the mouse trajectory path.","","Larger values:"," • Elements are detected sooner"," • More time for preloading/preparation"," • May trigger false positives for curved paths","","Smaller values:"," • More precise targeting"," • Reduced false positive rate"," • Less time for preparation","","Property: trajectoryPredictionTime"].join("\n"),'">i</span>\n </label>\n <input type="range" id="prediction-time" min="').concat(10,'" max="').concat(200,'" step="10">\n <span id="prediction-value"></span>\n </div>\n </div>\n </div>\n\n <div class="debugger-section keyboard-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>Keyboard Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content keyboard-settings-content">\n <div class="control-row">\n <label for="tab-enabled">\n Enable Tab Prediction\n <span class="info-icon" title="').concat(["Tab Navigation Prediction","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","When enabled: Callbacks are executed when","the user is ".concat(this.foresightManagerInstance.getManagerData.globalSettings.tabOffset," (tabOffset) ").concat(x," away from"),"a registered element during tab navigation.","","(works with Shift+Tab too).","","Property: enableTabPrediction"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="tab-enabled">\n </div>\n <div class="control-row">\n <label for="tab-offset">\n Tab Offset\n <span class="info-icon" title="').concat(["Tab Offset","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Number of tabbable elements to look ahead","when predicting tab navigation targets.","","How it works:"," • Tracks the current focused element"," • Looks ahead by the specified offset"," • Triggers callbacks for registered elements"," within that range","","Property: tabOffset"].join("\n"),'">i</span>\n </label>\n <input type="range" id="tab-offset" min="').concat(0,'" max="').concat(20,'" step="1">\n <span id="tab-offset-value"></span>\n </div>\n </div>\n </div>\n\n <div class="debugger-section scroll-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>Scroll Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content scroll-settings-content">\n <div class="control-row">\n <label for="scroll-enabled">\n Enable Scroll Prediction\n <span class="info-icon" title="').concat(["Scroll Prediction","━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Enables predictive scrolling based on mouse","position and scroll direction.","","When enabled, calculates scroll direction from","mouse movement and triggers callbacks for","elements that intersect the predicted path.","","Property: enableScrollPrediction"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="scroll-enabled">\n </div>\n <div class="control-row">\n <label for="scroll-margin">\n Scroll Margin\n <span class="info-icon" title="').concat(["Scroll Margin","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sets the pixel distance to check from the","mouse position in the scroll direction.","","Higher values check further ahead, allowing","earlier detection of elements that will come","into view during scrolling.","","Property: scrollMargin"].join("\n"),'">i</span>\n </label>\n <input type="range" id="scroll-margin" min="').concat(30,'" max="').concat(300,'" step="10">\n <span id="scroll-margin-value"></span>\n </div>\n </div>\n\n <div class="debugger-section general-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>General Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content general-settings-content">\n <div class="control-row">\n <label for="toggle-name-tags">\n Show Name Tags\n <span class="info-icon" title="').concat(["Visual Debug Name Tags","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","When enabled: Displays name tags over","each registered element in debug mode.","","Property: debuggerSettings.showNameTags"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="toggle-name-tags">\n </div>\n </div>\n </div>\n </div>\n\n <div class="debugger-section debugger-elements">\n <div class="debugger-section-header elements-list-header">\n <h3>Elements <span id="element-count"></span> <span id="callback-count"></span></h3>\n <div class="header-controls">\n <div class="sort-control-container">\n <button class="sort-button" title="Change element list sort order">\n ').concat('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon></svg>','\n </button>\n <div id="sort-options-popup">\n <button\n data-sort="visibility"\n title="').concat(["Sort by Visibility","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sorts elements by their viewport visibility","(visible elements first), with a secondary","sort by their order in the document.","","Property: debuggerSettings.sortElementList","Value: 'visibility'"].join("\n"),'"\n>\n Visibility\n</button>\n<button\n data-sort="documentOrder"\n title="').concat(["Sort by Document Order","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sorts elements based on their order of","appearance in the document's structure","(matching the HTML source).","","Property: debuggerSettings.sortElementList","Value: 'documentOrder'"].join("\n"),'"\n>\n Document Order\n</button>\n<button\n data-sort="insertionOrder"\n title="').concat(["Sort by Insertion Order","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sorts elements based on the order they","were registered with the ForesightManager.","","Property: debuggerSettings.sortElementList","Value: 'insertionOrder'"].join("\n"),'"\n>\n Insertion Order\n</button>\n </div>\n </div>\n </div>\n </div>\n <div class="debugger-section-content element-list">\n <div id="element-list-items-container">\n </div>\n </div>\n </div>\n '),t},t.prototype.getStyles=function(){return'\n #debug-controls {\n position: fixed; bottom: 10px; right: 10px;\n background-color: rgba(0, 0, 0, 0.90); color: white; padding: 12px;\n border-radius: 5px; font-family: Arial, sans-serif; font-size: 13px;\n z-index: 10001; pointer-events: auto; display: flex; flex-direction: column; gap: 8px;\n width: 400px;\n transition: width 0.3s ease, height 0.3s ease;\n }\n #debug-controls.minimized {\n width: 220px;\n overflow: hidden;\n padding: 12px 0; \n }\n #debug-controls.minimized .debugger-title-container {\n justify-content: flex-start; \n padding-left: 10px; \n padding-right: 10px;\n gap: 10px; \n }\n #debug-controls.minimized .debugger-title-container h2 {\n display: inline;\n font-size: 14px;\n margin: 0;\n white-space: nowrap;\n }\n #debug-controls.minimized .info-icon {\n display: none;\n }\n\n #element-count,#callback-count {\n font-size: 12px;\n color: #9e9e9e;\n }\n\n .debugger-title-container {\n display: flex;\n align-items: center;\n justify-content: space-between; \n padding: 0 0px; \n }\n .title-group { \n display: flex;\n align-items: center;\n gap: 8px; \n\n }\n .minimize-button {\n background: none; border: none; color: white;\n font-size: 22px; cursor: pointer;\n line-height: 1;\n }\n .debugger-title-container h2 { margin: 0; font-size: 15px; }\n\n .copy-settings-button {\n background: none; border: none; color: white;\n cursor: pointer; padding: 0;\n display: flex; align-items: center; justify-content: center;\n }\n .copy-settings-button svg {\n width: 16px; height: 16px;\n stroke: white;\n }\n\n .all-settings-sections-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n\n .debugger-section-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-top: 5px;\n margin-bottom: 2px;\n padding-bottom: 2px;\n border-bottom: 1px solid #444;\n }\n .debugger-section-header.collapsible {\n cursor: pointer;\n }\n .debugger-section-header h3 {\n margin: 0;\n font-size: 14px;\n font-weight: bold;\n color: #b0c4de;\n flex-grow: 1;\n }\n\n .section-minimize-button {\n background: none;\n border: none;\n color: white;\n font-size: 18px;\n cursor: pointer;\n padding: 0;\n line-height: 1;\n }\n\n #debug-controls .control-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n #debug-controls label {\n display: flex;\n align-items: center;\n gap: 5px;\n cursor: pointer;\n }\n #debug-controls .control-row:has(input[type="checkbox"]) label {\n flex-grow: 1;\n }\n #debug-controls .control-row input[type="checkbox"] {\n appearance: none; -webkit-appearance: none; -moz-appearance: none;\n position: relative; width: 40px; height: 18px;\n background-color: #555; border-radius: 10px; cursor: pointer;\n outline: none; transition: background-color 0.2s ease;\n vertical-align: middle; flex-shrink: 0; margin: 0;\n }\n #debug-controls .control-row input[type="checkbox"]::before {\n content: ""; position: absolute; width: 14px; height: 14px;\n border-radius: 50%; background-color: white; top: 2px; left: 2px;\n transition: transform 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.4);\n }\n #debug-controls .control-row input[type="checkbox"]:checked {\n background-color: #b0c4de;\n }\n #debug-controls .control-row input[type="checkbox"]:checked::before {\n transform: translateX(22px);\n }\n #debug-controls .control-row:has(input[type="range"]) label {\n flex-basis: 170px; flex-shrink: 0;\n }\n #debug-controls input[type="range"] {\n flex-grow: 1; margin: 0; cursor: pointer; -webkit-appearance: none;\n appearance: none; background: transparent; height: 18px; vertical-align: middle;\n }\n #debug-controls input[type="range"]::-webkit-slider-runnable-track {\n height: 6px; background: #555; border-radius: 3px;\n }\n #debug-controls input[type="range"]::-moz-range-track {\n height: 6px; background: #555; border-radius: 3px;\n }\n #debug-controls input[type="range"]::-webkit-slider-thumb {\n -webkit-appearance: none; appearance: none; margin-top: -5px;\n background: #b0c4de; height: 16px; width: 16px;\n border-radius: 50%; border: 1px solid #333;\n }\n #debug-controls input[type="range"]::-moz-range-thumb {\n background: #b0c4de; height: 16px; width: 16px;\n border-radius: 50%; border: 1px solid #333; border: none;\n }\n #debug-controls .control-row:has(input[type="range"]) span:not(.info-icon) {\n width: 55px; min-width: 55px; text-align: right; flex-shrink: 0;\n }\n .info-icon {\n display: inline-flex; align-items: center; justify-content: center;\n width: 16px; height: 16px; border-radius: 50%;\n background-color: #555; color: white; font-size: 10px;\n font-style: italic; font-weight: bold; font-family: \'Georgia\', serif;\n cursor: help; user-select: none; flex-shrink: 0;\n }\n .debugger-section {\n display: flex; flex-direction: column; gap: 6px;\n }\n .debugger-section-content {\n display: none; flex-direction: column; gap: 8px;\n }\n\n /* Element List Styles */\n .elements-list-header { cursor: default; }\n .header-controls {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n .sort-control-container {\n position: relative;\n }\n .sort-button {\n background: none; border: none; color: white; cursor: pointer;\n padding: 0; display: flex; align-items: center; justify-content: center;\n }\n .sort-button svg {\n width: 16px; height: 16px; stroke: #b0c4de; transition: stroke 0.2s;\n }\n .sort-button:hover svg { stroke: white; }\n \n #sort-options-popup {\n position: absolute;\n bottom: calc(100% + 5px);\n right: -5px;\n z-index: 10;\n display: none;\n flex-direction: column;\n gap: 4px;\n background-color: #3a3a3a;\n border: 1px solid #555;\n border-radius: 4px;\n padding: 3px;\n width: 200px;\n box-shadow: 0 4px 8px rgba(0,0,0,0.3);\n }\n #sort-options-popup.active {\n display: flex;\n }\n #sort-options-popup button {\n background: none; border: none; color: #ccc;\n font-size: 12px; text-align: left; padding: 5px 8px;\n cursor: pointer; border-radius: 3px;\n transition: background-color 0.2s, color 0.2s;\n display: flex;\n align-items: center;\n height: 26px;\n }\n #sort-options-popup button:hover {\n background-color: #555;\n color: white;\n }\n #sort-options-popup button.active-sort-option {\n color: #b0c4de;\n font-weight: bold;\n }\n #sort-options-popup button.active-sort-option::before {\n content: \'✓\';\n margin-right: 6px;\n width: 10px;\n }\n #sort-options-popup button::before {\n content: \'\';\n margin-right: 6px;\n width: 10px;\n }\n\n .element-list { /* Scroll container */\n min-height: '.concat(237,"px;\n max-height: ").concat(237,"px; \n overflow-y: auto;\n background-color: rgba(20, 20, 20, 0.5);\n border-radius: 3px;\n padding: 0;\n display: flex;\n }\n\n /* Modern Scrollbar Styling */\n .element-list::-webkit-scrollbar { width: 8px; }\n .element-list::-webkit-scrollbar-track { background: rgba(30, 30, 30, 0.5); border-radius: 4px; }\n .element-list::-webkit-scrollbar-thumb { background-color: rgba(176, 196, 222, 0.5); border-radius: 4px; border: 2px solid rgba(0, 0, 0, 0.2); }\n .element-list::-webkit-scrollbar-thumb:hover { background-color: rgba(176, 196, 222, 0.7); }\n .element-list { scrollbar-width: thin; scrollbar-color: rgba(176, 196, 222, 0.5) rgba(30, 30, 30, 0.5); }\n\n #element-list-items-container { \n display: flex;\n flex-wrap: wrap;\n gap: ").concat(3,"px;\n padding: ").concat(6,"px;\n min-height: ").concat(225,"px;\n box-sizing: border-box;\n align-content: flex-start;\n }\n #element-list-items-container > em {\n flex-basis: 100%;\n text-align: center;\n padding: 10px 0;\n font-style: italic;\n color: #ccc;\n font-size: 12px;\n }\n .element-list-item {\n flex-basis: calc((100% - (").concat(0," * ").concat(3,"px)) / ").concat(1,");\n flex-grow: 0;\n flex-shrink: 0;\n height: ").concat(35,"px;\n box-sizing: border-box;\n padding: 3px 5px;\n border-radius: 2px;\n display: flex;\n align-items: center;\n gap: 5px;\n background-color: rgba(50,50,50,0.7);\n transition: background-color 0.2s ease, opacity 0.2s ease;\n font-size: 11px; \n overflow: hidden;\n }\n \n /* Viewport intersection styling */\n .element-list-item.not-in-viewport { opacity: 0.4; }\n \n .element-list-item .element-name {\n flex-grow: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: 12px; \n font-weight: bold;\n }\n .element-list-item .intersecting-indicator {\n font-size: 12px;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n }\n .element-list-item .hit-behavior,\n .element-list-item .hit-slop {\n font-size: 10px; \n color: #b0b0b0;\n padding: 2px 5px; \n border-radius: 3px; \n background-color: rgba(0,0,0,0.2);\n flex-shrink: 0;\n }\n ")},t}();function z(t,e,n){var i=t.expandedOverlay,o=t.nameLabel,r=e.elementBounds.expandedRect,s=r.right-r.left,a=r.bottom-r.top;i.style.width="".concat(s,"px"),i.style.height="".concat(a,"px"),i.style.transform="translate3d(".concat(r.left,"px, ").concat(r.top,"px, 0)"),i.style.display="block",o.textContent=e.name,""!==e.name&&n?(o.style.display="block",o.style.transform="translate3d(".concat(r.left,"px, ").concat(r.top-25,"px, 0)")):o.style.display="none"}var L=class{static intersect(t,e){const n=Math.max(t.left,e.left),i=Math.min(t.right,e.right),o=Math.max(t.top,e.top),r=Math.min(t.bottom,e.bottom),s=Math.max(0,i-n),a=Math.max(0,r-o);return new DOMRect(n,o,s,a)}static clip(t,e){const n={...t.toJSON(),top:t.top+e.top,left:t.left+e.left,bottom:t.bottom-e.bottom,right:t.right-e.right};return n.width=n.right-n.left,n.height=n.bottom-n.top,n}static clipOffsets(t,e){return{top:e.top-t.top,left:e.left-t.left,bottom:t.bottom-e.bottom,right:t.right-e.right}}static equals(t,e){return null==t||null==e?t===e:t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}static sizeEqual(t,e){return Math.round(t.width)===Math.round(e.width)&&Math.round(t.height)===Math.round(e.height)}};function R(t,e){const n=Math.max(t.width,3),i=Math.max(t.height,3),o=t.top-e.top- -1,r=t.left-e.left- -1,s=e.right-t.left-n- -1,a=e.bottom-t.top-i- -1;return`${-Math.round(o)}px ${-Math.round(s)}px ${-Math.round(a)}px ${-Math.round(r)}px`}var D=[...Array.from({length:1e3},((t,e)=>e/1e3)),1],B=class{constructor(t,e,n){this.#t=e,this.#e=n,this.#n=n.clientRect,this.#i(t)}#t;#o=void 0;#e;#n;#r=void 0;get visibleRect(){const t=this.#e.clip;return t?L.clip(this.#n,t):this.#n}get isIntersecting(){const{width:t,height:e}=this.visibleRect;return t>0&&e>0}#i(t){const{root:e,rootBounds:n}=this.#e,{visibleRect:i}=this;this.#o?.disconnect(),this.#o=new IntersectionObserver(this.#s,{root:e,rootMargin:R(i,n),threshold:D}),this.#o.observe(t)}#s=t=>{if(!this.#o)return;const e=t[t.length-1];if(e){const{intersectionRatio:t,boundingClientRect:n}=e,i=this.#n;this.#n=n;const o=this.#r,r=!L.equals(n,i);if(t!==this.#r||r){const i=this.#e.rootBounds,s=L.intersect(n,i),a=s.width>0&&s.height>0;if(!a)return;this.#r=t,(null!=o||r)&&(this.#t(new H(e.target,n,e.intersectionRect,a,i),this),this.#i(e.target))}}};disconnect(){this.#o?.disconnect()}},H=class{constructor(t,e,n,i,o){this.target=t,this.boundingClientRect=e,this.intersectionRect=n,this.isIntersecting=i,this.rootBounds=o}},N=class{constructor(t,e){const n=function(t){return!t||function(t){return t.nodeType===Node.DOCUMENT_NODE}(t)?t?.defaultView??window:t}(t);if(function(t){return A(t)&&t.nodeType===Node.ELEMENT_NODE}(n)){const t=n.ownerDocument??document;this.rootBounds=n.getBoundingClientRect(),this.#a=new ResizeObserver((t=>{for(const n of t){const[{inlineSize:t,blockSize:i}]=n.borderBoxSize;if(L.sizeEqual(this.rootBounds,{width:t,height:i}))continue;const o=n.target.getBoundingClientRect();this.rootBounds=o,e(o,this)}})),this.#a.observe(n),t.addEventListener("scroll",(t=>{t.target&&t.target!==n&&A(t.target)&&t.target.contains(n)&&(this.rootBounds=n.getBoundingClientRect(),e(this.rootBounds,this))}),{capture:!0,passive:!0,signal:this.#l.signal})}else{const t=n.visualViewport??n;this.rootBounds=V(n);const i=()=>{const t=V(n);L.equals(this.rootBounds,t)||(this.rootBounds=t,e(t,this))};t.addEventListener("resize",i,{signal:this.#l.signal})}}#a;#l=new AbortController;rootBounds;disconnect(){this.#a?.disconnect(),this.#l.abort()}};function V(t){const e=t.visualViewport?.width??t.innerWidth,n=t.visualViewport?.height??t.innerHeight;return new DOMRect(0,0,e,n)}function A(t){return"nodeType"in t}var _=class{constructor(t,e){this.#e=e,this.#t=e=>{const n=[];for(const t of e){const e=this.intersections.get(t.target);this.intersections.set(t.target,t),e?.isIntersecting===t.isIntersecting&&L.equals(e?.intersectionRect,t.intersectionRect)||n.push(t)}n.length>0&&t(n,this)}}#t;#c=new Map;#e;intersections=new WeakMap;observe(t){const e=t.ownerDocument;if(!e)return;let n=this.#c.get(e);n||(n=new IntersectionObserver(this.#t,{...this.#e,threshold:D}),this.#c.set(e,n)),n.observe(t)}unobserve(t){const e=t.ownerDocument;if(!e)return;const n=this.#c.get(e);n&&(n.unobserve(t),this.intersections.delete(t))}disconnect(){for(const t of this.#c.values())t.disconnect();this.#c.clear()}},q=class{constructor(t,e){this.#t=t,this.#e=e,this.#d=new N(e?.root,this.#u),this.#h=new _(this.#g,e),this.#a=new ResizeObserver(this.#p)}#t;#e;#b=new Map;#a;#m=new WeakMap;#d;#h;observe(t){this.#h.observe(t)}unobserve(t){t?(this.#b.get(t)?.disconnect(),this.#h.unobserve(t)):this.disconnect()}disconnect(){for(const t of this.#b.values())t.disconnect();this.#a.disconnect(),this.#d.disconnect(),this.#h.disconnect()}#f(t){const e=[];for(const n of t){const{target:t}=n;U(n,this.#m.get(t))||(this.#m.set(t,n),e.push(n))}e.length>0&&this.#t(e)}#u=t=>{const e=[];for(const[n]of this.#b){const i=n.getBoundingClientRect(),o=this.#v(n,i);e.push(new F(n,i,o.visibleRect,o.isIntersecting,t))}this.#f(e)};#v(t,e){const n=this.#h;this.#b.get(t)?.disconnect();const i=new B(t,this.#y,{clientRect:e,root:this.#e?.root,rootBounds:this.#d.rootBounds,get clip(){const e=n.intersections.get(t);if(!e)return;const{intersectionRect:i,boundingClientRect:o}=e;return L.clipOffsets(o,i)}});return this.#b.set(t,i),i}#g=t=>{const e=[];for(const n of t){const{target:t,isIntersecting:i,boundingClientRect:o}=n;i?(this.#v(t,o),this.#a.observe(t)):(this.#b.get(t)?.disconnect(),this.#b.delete(t),this.#a.unobserve(t));const r=this.#b.get(t);e.push(new F(t,o,r?.visibleRect??n.intersectionRect,i,this.#d.rootBounds))}this.#f(e)};#y=(t,e)=>{this.#f([new F(t.target,t.boundingClientRect,e.visibleRect,t.isIntersecting,this.#d.rootBounds)])};#p=t=>{const e=[];for(const n of t){const{target:t,borderBoxSize:i}=n,o=this.#m.get(t);if(o){const[{inlineSize:t,blockSize:e}]=i;if(L.sizeEqual(o.boundingClientRect,{width:t,height:e}))continue}const r=t.getBoundingClientRect(),s=this.#v(t,r);e.push(new F(t,r,s.visibleRect,this.#h.intersections.get(t)?.isIntersecting??!1,this.#d.rootBounds))}this.#f(e)}},F=class{constructor(t,e,n,i,o){this.target=t,this.boundingClientRect=e,this.intersectionRect=n,this.isIntersecting=i,this.rootBounds=o}};function U(t,e){return null!=e&&(t.target===e.target&&t.isIntersecting===e.isIntersecting&&L.equals(t.boundingClientRect,e.boundingClientRect)&&L.equals(t.intersectionRect,e.intersectionRect))}function W(){var t=window.matchMedia("(pointer: coarse)").matches&&navigator.maxTouchPoints>0;console.log(t);var e,n=!!(e=navigator.connection)&&(/2g/.test(e.effectiveType)||e.saveData);return{isTouchDevice:t,isLimitedConnection:n,shouldRegister:!t&&!n}}var G=function(){function t(t){var e=this;this.callbackAnimations=new Map,this.debugElementOverlays=new Map,this.predictedMouseIndicator=null,this.mouseTrajectoryLine=null,this.scrollTrajectoryLine=null,this.animationPositionObserver=null,this.handleAnimationPositionChange=function(t){for(var n=0,i=t;n<i.length;n++){var o=i[n],r=e.callbackAnimations.get(o.target);if(r){var s=o.boundingClientRect,a=r.hitSlop,l=r.overlay,c=s.left-a.left,d=s.top-a.top,u=s.width+a.left+a.right,h=s.height+a.top+a.bottom;l.style.transform="translate3d(".concat(c,"px, ").concat(d,"px, 0)"),l.style.width="".concat(u,"px"),l.style.height="".concat(h,"px")}}},this.foresightManagerInstance=t}return t.prototype._setupDOM=function(){this.shadowHost||(this.shadowHost=M("div",document.body,{id:"jsforesight-debugger-shadow-host"}),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"}),this.debugContainer=M("div",this.shadowRoot,{id:"jsforesight-debug-container"}),this.predictedMouseIndicator=M("div",this.debugContainer,{className:"jsforesight-mouse-predicted"}),this.mouseTrajectoryLine=M("div",this.debugContainer,{className:"jsforesight-trajectory-line"}),this.scrollTrajectoryLine=M("div",this.debugContainer,{className:"jsforesight-scroll-trajectory-line"}),this.controlPanel=I.initialize(this.foresightManagerInstance,this.shadowRoot,this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings),O(K,this.shadowRoot,"screen-visuals"),this.animationPositionObserver=new q(this.handleAnimationPositionChange))},Object.defineProperty(t,"isInitiated",{get:function(){return!!t.debuggerInstance},enumerable:!1,configurable:!0}),t.initialize=function(e,n){if(document.querySelectorAll("#jsforesight-debugger-shadow-host").forEach((function(t){return t.remove()})),"undefined"==typeof window||!W().shouldRegister)return null;t.isInitiated||(t.debuggerInstance=new t(e));var i=t.debuggerInstance;return i.shadowHost||i._setupDOM(),i.updateMouseTrajectoryVisuals(n,e.getManagerData.globalSettings.enableMousePrediction),i},t.prototype.createElementOverlays=function(t){var e={expandedOverlay:M("div",this.debugContainer,{className:"jsforesight-expanded-overlay",data:t.name}),nameLabel:M("div",this.debugContainer,{className:"jsforesight-name-label"})};return this.debugElementOverlays.set(t.element,e),e},t.prototype.createOrUpdateElementOverlay=function(t){var e;if(this.debugContainer&&this.shadowRoot){var n=this.debugElementOverlays.get(t.element);n||(n=this.createElementOverlays(t)),z(n,t,null!==(e=this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==e?e:k)}},t.prototype.toggleNameTagVisibility=function(){var t=this;this.foresightManagerInstance.registeredElements.forEach((function(e){var n,i=t.debugElementOverlays.get(e.element);i&&z(i,e,null!==(n=t.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==n?n:k)}))},t.prototype.removeElement=function(t){var e;this.removeElementOverlay(t),null===(e=this.controlPanel)||void 0===e||e.removeElementFromList(t)},t.prototype.removeElementOverlay=function(t){var e=this.debugElementOverlays.get(t.element);e&&(e.expandedOverlay.remove(),e.nameLabel.remove(),this.debugElementOverlays.delete(t.element))},t.prototype.addElement=function(t,e){void 0===e&&(e=!0),this.createOrUpdateElementOverlay(t),this.controlPanel.addElementToList(t,e)},t.prototype.updateMouseTrajectoryVisuals=function(t,e){if(this.shadowRoot&&this.debugContainer&&this.predictedMouseIndicator&&this.mouseTrajectoryLine){var n=t.predictedPoint,i=t.currentPoint;if(this.predictedMouseIndicator.style.transform="translate3d(".concat(n.x,"px, ").concat(n.y,"px, 0) translate3d(-50%, -50%, 0)"),this.predictedMouseIndicator.style.display=e?"block":"none",0!==n.x||0!==n.y)if(e){var o=n.x-i.x,r=n.y-i.y,s=Math.sqrt(o*o+r*r),a=180*Math.atan2(r,o)/Math.PI;this.mouseTrajectoryLine.style.transform="translate3d(".concat(i.x,"px, ").concat(i.y,"px, 0) rotate(").concat(a,"deg)"),this.mouseTrajectoryLine.style.width="".concat(s,"px"),this.mouseTrajectoryLine.style.display="block"}else this.mouseTrajectoryLine.style.display="none";else this.predictedMouseIndicator.style.display="none"}},t.prototype.updateScrollTrajectoryVisuals=function(t,e){if(this.scrollTrajectoryLine){var n=e.x-t.x,i=e.y-t.y,o=Math.sqrt(n*n+i*i),r=180*Math.atan2(i,n)/Math.PI;this.scrollTrajectoryLine.style.transform="translate3d(".concat(t.x,"px, ").concat(t.y,"px, 0) rotate(").concat(r,"deg)"),this.scrollTrajectoryLine.style.width="".concat(o,"px"),this.scrollTrajectoryLine.style.display="block"}},t.prototype.hideScrollTrajectoryVisuals=function(){this.scrollTrajectoryLine&&(this.scrollTrajectoryLine.style.display="none")},t.prototype.updateControlsState=function(t){var e;null===(e=this.controlPanel)||void 0===e||e.updateControlsState(t)},t.prototype.updateElementVisibilityStatus=function(t){var e;null===(e=this.controlPanel)||void 0===e||e.updateElementVisibilityStatus(t)},t.prototype.removeElementFromList=function(t){var e;null===(e=this.controlPanel)||void 0===e||e.removeElementFromList(t)},t.prototype.showCallbackAnimation=function(t){var e,n,i=this,o=t.element,r=t.elementBounds,s=this.callbackAnimations.get(o);s&&(clearTimeout(s.timeoutId),s.overlay.remove(),null===(e=this.animationPositionObserver)||void 0===e||e.unobserve(o),this.callbackAnimations.delete(o));var a=M("div",this.debugContainer,{className:"jsforesight-callback-indicator"}),l=r.expandedRect,c=l.left,d=l.top,u=l.right-c,h=l.bottom-d;a.style.display="block",a.style.transform="translate3d(".concat(c,"px, ").concat(d,"px, 0)"),a.style.width="".concat(u,"px"),a.style.height="".concat(h,"px"),a.classList.add("animate");var g=setTimeout((function(){var t;a.remove(),i.callbackAnimations.delete(o),null===(t=i.animationPositionObserver)||void 0===t||t.unobserve(o)}),500);this.callbackAnimations.set(o,{hitSlop:t.elementBounds.hitSlop,overlay:a,timeoutId:g}),null===(n=this.animationPositionObserver)||void 0===n||n.observe(o)},t.prototype.cleanup=function(){var t,e;null===(t=this.controlPanel)||void 0===t||t.cleanup(),null===(e=this.shadowHost)||void 0===e||e.remove(),this.debugElementOverlays.clear(),this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.predictedMouseIndicator=null,this.mouseTrajectoryLine=null,this.scrollTrajectoryLine=null,this.controlPanel=null},t}(),K='\n #jsforesight-debug-container { \n position: fixed; top: 0; left: 0; width: 100%; height: 100%;\n pointer-events: none; z-index: 9999;\n }\n\n .jsforesight-expanded-overlay, \n .jsforesight-name-label, \n .jsforesight-callback-indicator,\n .jsforesight-mouse-predicted,\n .jsforesight-scroll-trajectory-line,\n .jsforesight-trajectory-line {\n position: absolute;\n top: 0;\n left: 0;\n will-change: transform; \n }\n .jsforesight-expanded-overlay {\n border: 1px dashed rgba(100, 116, 139, 0.4);\n background-color: rgba(100, 116, 139, 0.05);\n box-sizing: border-box;\n border-radius: 8px;\n }\n .jsforesight-mouse-predicted {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n border: 2px solid #6b98e1;\n background-color: rgba(176, 196, 222, 0.3);\n z-index: 10000;\n /* transform is now set dynamically via JS for performance */\n }\n .jsforesight-trajectory-line {\n height: 2px;\n background-color: #6b98e1;\n transform-origin: left center;\n z-index: 9999;\n border-radius: 1px;\n /* width and transform are set dynamically via JS for performance */\n }\n .jsforesight-name-label {\n background-color: rgba(27, 31, 35, 0.85);\n backdrop-filter: blur(4px);\n color: white;\n padding: 4px 8px;\n font-size: 11px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";\n border-radius: 4px;\n z-index: 10001;\n white-space: nowrap;\n pointer-events: none;\n }\n .jsforesight-callback-indicator {\n border: 4px solid oklch(65% 0.22 280); \n border-radius: 8px;\n box-sizing: border-box;\n pointer-events: none;\n opacity: 0;\n z-index: 10002;\n display: none; \n }\n .jsforesight-callback-indicator.animate {\n animation: jsforesight-callback-pulse 0.5s ease-out forwards;\n }\n \n .jsforesight-scroll-trajectory-line {\n height: 2px;\n background: repeating-linear-gradient(\n 90deg,\n oklch(68% 0.18 145) 0px,\n oklch(68% 0.18 145) 6px,\n transparent 6px,\n transparent 10px\n );\n transform-origin: left center;\n z-index: 9999;\n border-radius: 1px;\n display: none;\n animation: scroll-dash-flow 1.8s linear infinite;\n position: relative;\n }\n\n .jsforesight-scroll-trajectory-line::after {\n content: \'\';\n position: absolute;\n right: -2px;\n top: 50%;\n transform: translateY(-50%);\n width: 6px;\n height: 6px;\n background: oklch(68% 0.18 145);\n border-radius: 50%;\n animation: scroll-escape-squeeze 2.2s ease-in-out infinite;\n }\n\n @keyframes scroll-dash-flow {\n 0% { background-position: 0px 0px; }\n 100% { background-position: 10px 0px; }\n }\n\n @keyframes scroll-escape-squeeze {\n 0%, 100% { \n transform: translateY(-50%) scale(1);\n right: -2px;\n }\n 25% {\n transform: translateY(-50%) scaleX(1.3) scaleY(0.7);\n right: -3px;\n }\n 50% {\n transform: translateY(-50%) scaleX(0.8) scaleY(1.2);\n right: -1px;\n }\n 75% {\n transform: translateY(-50%) scaleX(1.2) scaleY(0.8);\n right: -3px;\n }\n }\n\n \n @keyframes jsforesight-callback-pulse {\n 0% {\n opacity: 1;\n box-shadow: 0 0 15px oklch(65% 0.22 280 / 0.7);\n }\n 100% {\n opacity: 0;\n box-shadow: 0 0 25px oklch(65% 0.22 280 / 0);\n }\n }\n ';function Y(t,e,n,i,o){return i&&(t<e?console.warn('ForesightJS: "'.concat(o,'" value ').concat(t," is below minimum bound ").concat(e,", clamping to ").concat(e)):t>n&&console.warn('ForesightJS: "'.concat(o,'" value ').concat(t," is above maximum bound ").concat(n,", clamping to ").concat(n))),Math.min(Math.max(t,e),n)}function J(t,e,n){var i=0,o=1,r=e.x-t.x,s=e.y-t.y,a=function(t,e){if(0===t){if(e<0)return!1}else{var n=e/t;if(t<0){if(n>o)return!1;n>i&&(i=n)}else{if(n<i)return!1;n<o&&(o=n)}}return!0};return!!a(-r,t.x-n.left)&&(!!a(r,n.right-t.x)&&(!!a(-s,t.y-n.top)&&(!!a(s,n.bottom-t.y)&&i<=o)))}function X(t,e){if("number"==typeof t){var n=Y(t,0,w,e,"hitslop");return{top:n,left:n,right:n,bottom:n}}return{top:Y(t.top,0,w,e,"hitslop - top"),left:Y(t.left,0,w,e,"hitslop - left"),right:Y(t.right,0,w,e,"hitslop - right"),bottom:Y(t.bottom,0,w,e,"hitslop - bottom")}}function $(t,e){return{left:t.left-e.left,right:t.right+e.right,top:t.top-e.top,bottom:t.bottom+e.bottom}}function Q(t,e){return t&&e?t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom:t===e}function Z(t,e){return t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom}function tt(t,e){return void 0!==t&&e!==t}var et=function(){function e(){var t=this;this.elements=new Map,this.isSetup=!1,this.debugger=null,this._globalCallbackHits={mouse:{hover:0,trajectory:0},tab:{forwards:0,reverse:0},scroll:{down:0,left:0,right:0,up:0},total:0},this._globalSettings={debug:false,enableMousePrediction:true,enableScrollPrediction:true,positionHistorySize:8,trajectoryPredictionTime:120,scrollMargin:150,defaultHitSlop:{top:0,left:0,right:0,bottom:0},resizeScrollThrottleDelay:0,debuggerSettings:{isControlPanelDefaultMinimized:C,showNameTags:k,sortElementList:"visibility"},enableTabPrediction:true,tabOffset:2,onAnyCallbackFired:function(t,e){}},this.trajectoryPositions={positions:[],currentPoint:{x:0,y:0},predictedPoint:{x:0,y:0}},this.tabbableElementsCache=[],this.lastFocusedIndex=null,this.predictedScrollPoint=null,this.scrollDirection=null,this.domObserver=null,this.positionObserver=null,this.lastKeyDown=null,this.globalListenersController=null,this.handleMouseMove=function(e){t.updatePointerState(e),t.elements.forEach((function(e){e.isIntersectingWithViewport&&(e.unregisterOnCallback?t.handleSingleCallbackInteraction(e):t.handleMultiCallbackInteraction(e))})),t.debugger&&(t.debugger.hideScrollTrajectoryVisuals(),t.debugger.updateMouseTrajectoryVisuals(t.trajectoryPositions,t._globalSettings.enableMousePrediction))},this.handleDomMutations=function(e){e.length&&(t.tabbableElementsCache=[],t.lastFocusedIndex=null);for(var n=0,i=e;n<i.length;n++){var o=i[n];if("childList"===o.type&&o.removedNodes.length>0)for(var r=0,s=Array.from(t.elements.keys());r<s.length;r++){var a=s[r];a.isConnected||t.unregister(a)}}},this.handleKeyDown=function(e){"Tab"===e.key&&(t.lastKeyDown=e)},this.handleFocusIn=function(e){if(t.lastKeyDown&&t._globalSettings.enableTabPrediction){var n=e.target;if(n instanceof HTMLElement){t.tabbableElementsCache.length||(t.tabbableElementsCache=v(document.documentElement),t._globalSettings.debug&&console.log("ForesightJS: Recomputed tabbable elements cache because of DOM change"));var i=t.lastKeyDown.shiftKey,o=function(t,e,n,i){if(null!==e){var o=t?e-1:e+1;if(o>=0&&o<n.length&&n[o]===i)return o}return n.findIndex((function(t){return t===i}))}(i,t.lastFocusedIndex,t.tabbableElementsCache,n);t.lastFocusedIndex=o,t.lastKeyDown=null;for(var r=[],s=0;s<=t._globalSettings.tabOffset;s++)if(i){var a=t.tabbableElementsCache[o-s];t.elements.has(a)&&r.push(a)}else{a=t.tabbableElementsCache[o+s];t.elements.has(a)&&r.push(a)}r.forEach((function(e){t.callCallback(t.elements.get(e),{kind:"tab",subType:i?"reverse":"forwards"})}))}}},this.handlePositionChange=function(e){for(var n,i,o=0,r=e;o<r.length;o++){var s=r[o],a=t.elements.get(s.target);if(a){var l=a.isIntersectingWithViewport,c=s.isIntersecting;a.isIntersectingWithViewport=c,l!==c&&(null===(n=t.debugger)||void 0===n||n.updateElementVisibilityStatus(a)),c?(t.updateElementBounds(s.boundingClientRect,a),t.handleScrollPrefetch(a,s.boundingClientRect)):t._globalSettings.debug&&l&&(null===(i=t.debugger)||void 0===i||i.removeElementOverlay(a))}}t.scrollDirection=null,t.predictedScrollPoint=null}}return e.initialize=function(t){return this.isInitiated||(e.manager=new e),void 0!==t&&e.manager.alterGlobalSettings(t),e.manager},Object.defineProperty(e.prototype,"getManagerData",{get:function(){return{registeredElements:this.elements,globalSettings:this._globalSettings,globalCallbackHits:this._globalCallbackHits}},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isInitiated",{get:function(){return!!e.manager},enumerable:!1,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return this.initialize()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"registeredElements",{get:function(){return this.elements},enumerable:!1,configurable:!0}),e.prototype.register=function(t){var e,n,i=this,o=t.element,r=t.callback,s=t.hitSlop,a=t.unregisterOnCallback,l=t.name,c=W(),d=c.shouldRegister,u=c.isTouchDevice,h=c.isLimitedConnection;if(!d)return{isLimitedConnection:h,isTouchDevice:u,isRegistered:!1,unregister:function(){}};this.isSetup||this.initializeGlobalListeners();var g=s?X(s,this._globalSettings.debug):this._globalSettings.defaultHitSlop,p={element:o,callback:r,callbackHits:{mouse:{hover:0,trajectory:0},tab:{forwards:0,reverse:0},scroll:{down:0,left:0,right:0,up:0},total:0},elementBounds:{originalRect:void 0,expandedRect:{top:0,left:0,right:0,bottom:0},hitSlop:g},isHovering:!1,trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0},name:null!==(e=null!=l?l:o.id)&&void 0!==e?e:"",unregisterOnCallback:null==a||a,isIntersectingWithViewport:!0};return this.elements.set(o,p),null===(n=this.positionObserver)||void 0===n||n.observe(o),this.debugger&&this.debugger.addElement(p),{isTouchDevice:u,isLimitedConnection:h,isRegistered:!0,unregister:function(){return i.unregister(o)}}},e.prototype.unregister=function(t){var e;if(this.elements.has(t)){var n=this.elements.get(t);(null==n?void 0:n.trajectoryHitData.trajectoryHitExpirationTimeoutId)&&clearTimeout(n.trajectoryHitData.trajectoryHitExpirationTimeoutId),null===(e=this.positionObserver)||void 0===e||e.unobserve(t),this.elements.delete(t),this.debugger&&n&&this.debugger.removeElement(n),0===this.elements.size&&this.isSetup&&this.removeGlobalListeners()}},e.prototype.updateNumericSettings=function(t,e,n,i){return!!tt(t,this._globalSettings[e])&&(this._globalSettings[e]=Y(t,n,i,this._globalSettings.debug,e),!0)},e.prototype.updateBooleanSetting=function(t,e){return!!tt(t,this._globalSettings[e])&&(this._globalSettings[e]=t,!0)},e.prototype.alterGlobalSettings=function(t){var e,n,i,o=this._globalSettings.positionHistorySize,r=this.updateNumericSettings(null==t?void 0:t.positionHistorySize,"positionHistorySize",2,30);r&&this._globalSettings.positionHistorySize<o&&this.trajectoryPositions.positions.length>this._globalSettings.positionHistorySize&&(this.trajectoryPositions.positions=this.trajectoryPositions.positions.slice(this.trajectoryPositions.positions.length-this._globalSettings.positionHistorySize));var s=this.updateNumericSettings(null==t?void 0:t.trajectoryPredictionTime,"trajectoryPredictionTime",10,200),a=this.updateNumericSettings(null==t?void 0:t.scrollMargin,"scrollMargin",30,300),l=this.updateNumericSettings(null==t?void 0:t.tabOffset,"tabOffset",0,20);void 0!==(null==t?void 0:t.resizeScrollThrottleDelay)&&console.warn("resizeScrollThrottleDelay is deprecated and will be removed in V3.0.0 of ForesightJS");var c=this.updateBooleanSetting(null==t?void 0:t.enableMousePrediction,"enableMousePrediction"),d=this.updateBooleanSetting(null==t?void 0:t.enableScrollPrediction,"enableScrollPrediction"),u=this.updateBooleanSetting(null==t?void 0:t.enableTabPrediction,"enableTabPrediction");void 0!==(null==t?void 0:t.onAnyCallbackFired)&&(this._globalSettings.onAnyCallbackFired=t.onAnyCallbackFired);var h=!1;void 0!==(null===(e=null==t?void 0:t.debuggerSettings)||void 0===e?void 0:e.isControlPanelDefaultMinimized)&&(this._globalSettings.debuggerSettings.isControlPanelDefaultMinimized=t.debuggerSettings.isControlPanelDefaultMinimized,h=!0),void 0!==(null===(n=null==t?void 0:t.debuggerSettings)||void 0===n?void 0:n.showNameTags)&&(this._globalSettings.debuggerSettings.showNameTags=t.debuggerSettings.showNameTags,h=!0,this.debugger&&this.debugger.toggleNameTagVisibility()),void 0!==(null===(i=null==t?void 0:t.debuggerSettings)||void 0===i?void 0:i.sortElementList)&&(this._globalSettings.debuggerSettings.sortElementList=t.debuggerSettings.sortElementList,h=!0,this.debugger);var g=!1;if(void 0!==(null==t?void 0:t.defaultHitSlop)){var p=X(t.defaultHitSlop,this._globalSettings.debug);Q(this._globalSettings.defaultHitSlop,p)||(this._globalSettings.defaultHitSlop=p,g=!0,this.forceUpdateAllElementBounds())}var b=!1;void 0!==(null==t?void 0:t.debug)&&this._globalSettings.debug!==t.debug&&"undefined"!=typeof window&&"undefined"!=typeof document&&(this._globalSettings.debug=t.debug,b=!0,this._globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null)),(r||s||l||c||u||d||h||g||a||b)&&this.debugger&&this.debugger.updateControlsState(this._globalSettings)},e.prototype.turnOnDebugMode=function(){var t=this;if(this.debugger)this.debugger.updateControlsState(this._globalSettings);else{this.debugger=G.initialize(e.instance,this.trajectoryPositions);var n=Array.from(this.elements.values());n.forEach((function(e,i){var o,r=i===n.length-1;null===(o=t.debugger)||void 0===o||o.addElement(e,r)}))}},e.prototype.forceUpdateAllElementBounds=function(){var t=this;this.elements.forEach((function(e,n){var i=t.elements.get(n);i&&i.isIntersectingWithViewport&&t.forceUpdateElementBounds(i)}))},e.prototype.updatePointerState=function(e){this.trajectoryPositions.currentPoint={x:e.clientX,y:e.clientY},this.trajectoryPositions.predictedPoint=this._globalSettings.enableMousePrediction?function(t,e,n,i){var o={point:t,time:performance.now()},r=t.x,s=t.y;if(e.push(o),e.length>n&&e.shift(),e.length<2)return{x:r,y:s};var a=e[0],l=e[e.length-1],c=(l.time-a.time)/1e3;if(0===c)return{x:r,y:s};var d=i/1e3;return{x:r+(l.point.x-a.point.x)/c*d,y:s+(l.point.y-a.point.y)/c*d}}(this.trajectoryPositions.currentPoint,this.trajectoryPositions.positions,this._globalSettings.positionHistorySize,this._globalSettings.trajectoryPredictionTime):t({},this.trajectoryPositions.currentPoint)},e.prototype.handleSingleCallbackInteraction=function(t){var e=t.elementBounds.expandedRect;if(this._globalSettings.enableMousePrediction)J(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,e)&&this.callCallback(t,{kind:"mouse",subType:"trajectory"});else if(Z(this.trajectoryPositions.currentPoint,e))return void this.callCallback(t,{kind:"mouse",subType:"hover"})},e.prototype.handleMultiCallbackInteraction=function(e){var n=this,i=e.elementBounds.expandedRect,o=Z(this.trajectoryPositions.currentPoint,i),r=o&&!e.isHovering,s=this._globalSettings.enableMousePrediction&&!o&&!e.trajectoryHitData.isTrajectoryHit&&J(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,i);if((r||s)&&this.callCallback(e,{kind:"mouse",subType:r?"hover":"trajectory"}),o!==e.isHovering||s){var a=t(t({},e),{isHovering:o,trajectoryHitData:t(t({},e.trajectoryHitData),{isTrajectoryHit:s,trajectoryHitTime:s?performance.now():e.trajectoryHitData.trajectoryHitTime})});s&&(a.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(a.trajectoryHitData.trajectoryHitExpirationTimeoutId),a.trajectoryHitData.trajectoryHitExpirationTimeoutId=setTimeout((function(){var t,i=n.elements.get(e.element);i&&i.trajectoryHitData.trajectoryHitTime===a.trajectoryHitData.trajectoryHitTime&&(i.trajectoryHitData.isTrajectoryHit=!1,null===(t=n.debugger)||void 0===t||t.createOrUpdateElementOverlay(i))}),200)),this.elements.set(e.element,a)}},e.prototype.updateHitCounters=function(t,e){switch(e.kind){case"mouse":t.callbackHits.mouse[e.subType]++,this._globalCallbackHits.mouse[e.subType]++;break;case"tab":t.callbackHits.tab[e.subType]++,this._globalCallbackHits.tab[e.subType]++;break;case"scroll":t.callbackHits.scroll[e.subType]++,this._globalCallbackHits.scroll[e.subType]++}t.callbackHits.total++,this._globalCallbackHits.total++},e.prototype.callCallback=function(t,e){t&&(this.updateHitCounters(t,e),t.callback(),this._globalSettings.onAnyCallbackFired(t,this.getManagerData),this.debugger&&this.debugger.showCallbackAnimation(t),t.unregisterOnCallback&&this.unregister(t.element))},e.prototype.forceUpdateElementBounds=function(e){var n=e.element.getBoundingClientRect(),i=$(n,e.elementBounds.hitSlop);if(!Q(i,e.elementBounds.expandedRect)&&(this.elements.set(e.element,t(t({},e),{elementBounds:t(t({},e.elementBounds),{originalRect:n,expandedRect:i})})),this.debugger)){var o=this.elements.get(e.element);o&&this.debugger.createOrUpdateElementOverlay(o)}},e.prototype.updateElementBounds=function(e,n){if(this.elements.set(n.element,t(t({},n),{elementBounds:t(t({},n.elementBounds),{originalRect:e,expandedRect:$(e,n.elementBounds.hitSlop)})})),this.debugger){var i=this.elements.get(n.element);i&&this.debugger.createOrUpdateElementOverlay(i)}},e.prototype.handleScrollPrefetch=function(t,e){var n,i;if(this._globalSettings.enableScrollPrediction){if(!t.elementBounds.originalRect)return;if(this.scrollDirection=null!==(n=this.scrollDirection)&&void 0!==n?n:function(t,e){var n=e.top-t.top,i=e.left-t.left;return n<-1?"down":n>1?"up":i<-1?"right":i>1?"left":"none"}(t.elementBounds.originalRect,e),"none"===this.scrollDirection)return;this.predictedScrollPoint=null!==(i=this.predictedScrollPoint)&&void 0!==i?i:function(t,e,n){var i={x:t.x,y:t.y};switch(e){case"down":i.y+=n;break;case"up":i.y-=n;break;case"left":i.x-=n;break;case"right":i.x+=n}return i}(this.trajectoryPositions.currentPoint,this.scrollDirection,this._globalSettings.scrollMargin),J(this.trajectoryPositions.currentPoint,this.predictedScrollPoint,null==t?void 0:t.elementBounds.expandedRect)&&this.callCallback(t,{kind:"scroll",subType:this.scrollDirection}),this.debugger&&this.debugger.updateScrollTrajectoryVisuals(this.trajectoryPositions.currentPoint,this.predictedScrollPoint)}else Z(this.trajectoryPositions.currentPoint,t.elementBounds.expandedRect)&&this.callCallback(t,{kind:"mouse",subType:"hover"})},e.prototype.initializeGlobalListeners=function(){if(!this.isSetup&&"undefined"!=typeof window&&"undefined"!=typeof document){this.globalListenersController=new AbortController;var t=this.globalListenersController.signal;document.addEventListener("mousemove",this.handleMouseMove,{signal:t}),document.addEventListener("keydown",this.handleKeyDown,{signal:t}),document.addEventListener("focusin",this.handleFocusIn,{signal:t}),this.domObserver=new MutationObserver(this.handleDomMutations),this.domObserver.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1}),this.positionObserver=new q(this.handlePositionChange),this.isSetup=!0}},e.prototype.removeGlobalListeners=function(){var t,e,n;this.isSetup=!1,this.debugger?console.log("ForesightJS: All elements have successfully been unregistered. ForesightJS would typically perform cleanup events now, but these are currently skipped while in debug mode. Observers are cleared up."):(null===(t=this.globalListenersController)||void 0===t||t.abort(),this.globalListenersController=null),null===(e=this.domObserver)||void 0===e||e.disconnect(),this.domObserver=null,null===(n=this.positionObserver)||void 0===n||n.disconnect(),this.positionObserver=null},e}();exports.ForesightManager=et;
|
|
7
7
|
//# sourceMappingURL=index.js.map
|