js.foresight 2.1.2 → 2.1.4

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 CHANGED
@@ -23,9 +23,9 @@ When you over simplify prefetching it exists of three parts.
23
23
  ForesightJS takes care of the **When** by predicting user intent with mouse trajectory and tab navigation.
24
24
  You supply the **What** and **How** inside your `callback` when you register an element.
25
25
 
26
- ### [ForesightJS docs (with interactive demo)](https://foresightjs.com/)
26
+ ### [Playground](https://foresightjs.com/)
27
27
 
28
- ![](https://github.com/spaansba/ForesightJS/blob/main/static/ForesightJSDemo.gif)
28
+ ![](https://github.com/user-attachments/assets/36c81a82-fee7-43d6-ba1e-c48214136f90)
29
29
  _In the GIF above, [debug mode](https://foresightjs.com/docs/getting_started/debug) is on. Normally, users won't see anything that ForesightJS does except the increased perceived speed from early prefetching._
30
30
 
31
31
  ## Download
@@ -113,6 +113,16 @@ Since ForesightJS is a relatively new and unknown library, most AI assistants an
113
113
 
114
114
  Additionally, every page in the documentation is available in markdown format (try adding .md to any documentation URL). You can share these markdown files as context with AI assistants, though all this information is also consolidated in the llms.txt file for convenience.
115
115
 
116
+ ## Future of ForesightJS
117
+
118
+ ForesightJS will continue to evolve with a focus on staying as lightweight and performant as possible. To achieve this the plan is to decouple the debugger and make it its own standalone dev package, reducing the core library size even further.
119
+
120
+ Beyond size optimization, performance remains central to every development decision. Each release will focus on improving prediction accuracy while reducing computational overhead, ensuring ForesightJS stays practical for production environments. We also want to move as much processing as possible off the main thread to keep user interfaces responsive.
121
+
122
+ These performance improvements go hand in hand with expanding accessibility across different development environments. The documentation will grow to include more framework integrations beyond the current Next.js and React Router implementations, making ForesightJS accessible to developers working with different technology stacks and routing solutions.
123
+
124
+ All of these efforts benefit from community input. [Contributions](/CONTRIBUTING.md) are always welcome, whether for new framework integrations, performance improvements, or feature ideas.
125
+
116
126
  # Contributing
117
127
 
118
128
  Please see the [contributing guidelines](/CONTRIBUTING.md)
package/dist/index.d.ts CHANGED
@@ -4,12 +4,6 @@ type Rect = {
4
4
  right: number;
5
5
  bottom: number;
6
6
  };
7
- type PositionObserverEntry = {
8
- target: Element;
9
- boundingClientRect: DOMRect;
10
- clientHeight: number;
11
- clientWidth: number;
12
- };
13
7
  /**
14
8
  * A callback function that is executed when a foresight interaction
15
9
  * (e.g., hover, trajectory hit) occurs on a registered element.
@@ -89,7 +83,7 @@ type ForesightManagerData = {
89
83
  registeredElements: Map<ForesightElement, ForesightElementData>;
90
84
  globalSettings: Readonly<ForesightManagerSettings>;
91
85
  globalCallbackHits: Readonly<CallbackHits>;
92
- positionObserverElements: Map<Element, PositionObserverEntry> | undefined;
86
+ positionObserverElements: Map<Element, IntersectionObserverEntry> | undefined;
93
87
  };
94
88
  type BaseForesightManagerSettings = {
95
89
  /**
@@ -193,7 +187,6 @@ declare class ForesightManager {
193
187
  private _globalSettings;
194
188
  private trajectoryPositions;
195
189
  private domObserver;
196
- private elementIntersectionObserver;
197
190
  private positionObserver;
198
191
  private lastKeyDown;
199
192
  private globalListenersController;
@@ -249,7 +242,6 @@ declare class ForesightManager {
249
242
  private handleFocusIn;
250
243
  private updateHitCounters;
251
244
  private callCallback;
252
- private handleIntersection;
253
245
  /**
254
246
  * ONLY use this function when you want to change the rect bounds via code, if the rects are changing because of updates in the DOM do not use this function.
255
247
  * We need an observer for that
package/dist/index.js CHANGED
@@ -3,19 +3,21 @@
3
3
  * tabbable 6.2.0
4
4
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
5
5
  */
6
- var t=["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(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},r=function e(t,n){var i;void 0===n&&(n=!0);var o=null==t||null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"inert");return""===o||"true"===o||n&&t&&e(t.parentNode)},s=function e(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=e(d.length?d:c.children,!0,s);s.flatten?a.push.apply(a,u):a.push({scopeParent:c,candidates:u})}else{i.call(c,t)&&s.filter(c)&&(o||!n.includes(c))&&a.push(c);var g=c.shadowRoot||"function"==typeof s.getShadowRoot&&s.getShadowRoot(c),h=!r(g,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(c));if(g&&h){var p=e(!0===g?c.children:g.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(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},l=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!a(e)?0:e.tabIndex},c=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},d=function(e){return"INPUT"===e.tagName},u=function(e){return function(e){return d(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||o(e),i=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=i(window.CSS.escape(e.name));else try{t=i(e.name)}catch(e){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",e.message),!1}var r=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!r||r===e}(e)},g=function(e){var t=e.getBoundingClientRect(),n=t.width,i=t.height;return 0===n&&0===i},h=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var s=i.call(e,"details>summary:first-of-type")?e.parentElement:e;if(i.call(s,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return g(e)}else{if("function"==typeof r){for(var a=e;e;){var l=e.parentElement,c=o(e);if(l&&!l.shadowRoot&&!0===r(l))return g(e);e=e.assignedSlot?e.assignedSlot:l||c===e.ownerDocument?l:c.host}e=a}if(function(e){var t,n,i,r,s=e&&o(e),a=null===(t=s)||void 0===t?void 0:t.host,l=!1;if(s&&s!==e)for(l=!!(null!==(n=a)&&void 0!==n&&null!==(i=n.ownerDocument)&&void 0!==i&&i.contains(a)||null!=e&&null!==(r=e.ownerDocument)&&void 0!==r&&r.contains(e));!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}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},p=function(e,t){return!(t.disabled||r(t)||function(e){return d(e)&&"hidden"===e.type}(t)||h(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var o=t.children.item(n);if("LEGEND"===o.tagName)return!!i.call(t,"fieldset[disabled] *")||!o.contains(e)}return!0}t=t.parentElement}return!1}(t))},b=function(e,t){return!(u(t)||l(t)<0||!p(e,t))},m=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},f=function e(t){var n=[],i=[];return t.forEach((function(t,o){var r=!!t.scopeParent,s=r?t.scopeParent:t,c=function(e,t){var n=l(e);return n<0&&t&&!a(e)?0:n}(s,r),d=r?e(t.candidates):s;0===c?r?n.push.apply(n,d):n.push(s):i.push({documentOrder:o,tabIndex:c,item:t,isScope:r,content:d})})),i.sort(c).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},y=function(e,n){var o;return o=(n=n||{}).getShadowRoot?s([e],n.includeContainer,{filter:b.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:m}):function(e,n,o){if(r(e))return[];var s=Array.prototype.slice.apply(e.querySelectorAll(t));return n&&i.call(e,t)&&s.unshift(e),s.filter(o)}(e,n.includeContainer,b.bind(null,n)),f(o)},v="ms",S="points",x="tabs",w=2e3,C=!1,k=!0;var E=function(e,t){void 0===t&&(t=2);var n=" ".repeat(t);if("object"==typeof e&&null!==e&&!Array.isArray(e)){var i=Object.entries(e);if(0===i.length)return"{}";var o=i.map((function(e){var i=e[0],o=e[1];return"".concat(n," ").concat(i,": ").concat(E(o,t+2))})).join(",\n");return"{\n".concat(o,"\n").concat(n,"}")}return"string"==typeof e?"'".concat(e,"'"):"boolean"==typeof e||"number"==typeof e?String(e):null===e?"null":void 0===e?"undefined":Array.isArray(e)?JSON.stringify(e):String(e)};function T(e,t,n,i){var o=document.createElement(e);return i&&(o.id=i),n&&(o.className=n),t.appendChild(o)}function j(e,t,n){var i=document.createElement("style");return i.textContent=e,i.id="control-panel",t.appendChild(i)}var M='<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>',z=function(){function e(e){this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems=new Map,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.showNameTagsCheckbox=null,this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.isContainerMinimized=!1,this.isMouseSettingsMinimized=!0,this.isKeyboardSettingsMinimized=!0,this.isGeneralSettingsMinimized=!0,this.isElementsListMinimized=!0,this.SESSION_STORAGE_KEY="jsforesightDebuggerSectionStates",this.copySettingsButton=null,this.copyTimeoutId=null,this.foresightManagerInstance=e}return e.prototype._setupDOMAndListeners=function(e,t){var n;this.controlsContainer||(this.shadowRoot=e,this.isContainerMinimized=null!==(n=t.isControlPanelDefaultMinimized)&&void 0!==n?n:C,this.controlsContainer=this.createControlContainer(),this.shadowRoot.appendChild(this.controlsContainer),this.controlPanelStyleElement=j(this.getStyles(),this.shadowRoot),this.queryDOMElements(),this.originalSectionStates(),this.setupEventListeners(),this.refreshElementList(),this.updateContainerVisibilityState())},e.initialize=function(t,n,i){e.isInitiated||(e.debuggerControlPanelInstance=new e(t));var o=e.debuggerControlPanelInstance;return o._setupDOMAndListeners(n,i),o},Object.defineProperty(e,"isInitiated",{get:function(){return!!e.debuggerControlPanelInstance},enumerable:!1,configurable:!0}),e.prototype.loadSectionStatesFromSessionStorage=function(){var e,t,n,i,o=sessionStorage.getItem(this.SESSION_STORAGE_KEY),r={};return o&&(r=JSON.parse(o)),this.isMouseSettingsMinimized=null===(e=r.mouse)||void 0===e||e,this.isKeyboardSettingsMinimized=null===(t=r.keyboard)||void 0===t||t,this.isGeneralSettingsMinimized=null===(n=r.general)||void 0===n||n,this.isElementsListMinimized=null!==(i=r.elements)&&void 0!==i&&i,r},e.prototype.saveSectionStatesToSessionStorage=function(){var e={mouse:this.isMouseSettingsMinimized,keyboard:this.isKeyboardSettingsMinimized,general:this.isGeneralSettingsMinimized,elements:this.isElementsListMinimized};try{sessionStorage.setItem(this.SESSION_STORAGE_KEY,JSON.stringify(e))}catch(e){console.error("Foresight Debugger: Could not save section states to session storage.",e)}},e.prototype.queryDOMElements=function(){this.trajectoryEnabledCheckbox=this.controlsContainer.querySelector("#trajectory-enabled"),this.tabEnabledCheckbox=this.controlsContainer.querySelector("#tab-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.elementListItemsContainer=this.controlsContainer.querySelector("#element-list-items-container"),this.showNameTagsCheckbox=this.controlsContainer.querySelector("#toggle-name-tags"),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")},e.prototype.handleCopySettings=function(){var e,t,n,i=this;this.copySettingsButton&&navigator.clipboard.writeText((e=this.foresightManagerInstance.getManagerData.globalSettings,t="ForesightManager.initialize",n=Object.entries(e).filter((function(e){var t=e[0];return"resizeScrollThrottleDelay"!==String(t)})).map((function(e){var t=e[0],n=e[1];return" ".concat(String(t),": ").concat(E(n))})).join(",\n"),"".concat(t,"({\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=M),i.copyTimeoutId=null}),3e3)})).catch((function(e){console.error("Foresight Debugger: Could not copy settings to clipboard",e)}))},e.prototype.createInputEventListener=function(e,t,n,i){var o=this;e&&t&&e.addEventListener("input",(function(e){var r,s=parseInt(e.target.value,10);t.textContent="".concat(s," ").concat(n),o.foresightManagerInstance.alterGlobalSettings(((r={})[i]=s,r))}))},e.prototype.createChangeEventListener=function(e,t){var n=this;e&&e.addEventListener("change",(function(e){var i;"name-tag"===t?n.foresightManagerInstance.alterGlobalSettings({debuggerSettings:{showNameTags:e.target.checked}}):n.foresightManagerInstance.alterGlobalSettings(((i={})[t]=e.target.checked,i))}))},e.prototype.createSectionVisibilityToggleEventListener=function(e,t){var n=this,i=null==e?void 0:e.querySelector(".debugger-section-header");null==i||i.addEventListener("click",(function(i){i.stopPropagation(),n.toggleMinimizeSection(e,n[t]=!n[t])}))},e.prototype.setupEventListeners=function(){var e,t,n=this;this.createChangeEventListener(this.trajectoryEnabledCheckbox,"enableMousePrediction"),this.createChangeEventListener(this.tabEnabledCheckbox,"enableTabPrediction"),this.createChangeEventListener(this.showNameTagsCheckbox,"name-tag"),this.createInputEventListener(this.historySizeSlider,this.historyValueSpan,S,"positionHistorySize"),this.createInputEventListener(this.predictionTimeSlider,this.predictionValueSpan,v,"trajectoryPredictionTime"),this.createInputEventListener(this.tabOffsetSlider,this.tabOffsetValueSpan,x,"tabOffset"),null===(e=this.containerMinimizeButton)||void 0===e||e.addEventListener("click",(function(){n.isContainerMinimized=!n.isContainerMinimized,n.updateContainerVisibilityState()})),null===(t=this.copySettingsButton)||void 0===t||t.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(".general-settings-section"),"isGeneralSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".debugger-elements"),"isElementsListMinimized")},e.prototype.toggleMinimizeSection=function(e,t){if(e){var n=e.querySelector(".debugger-section-content"),i=e.querySelector(".section-minimize-button");n&&i&&(t?(n.style.display="none",i.textContent="+"):(n.style.display="flex",i.textContent="-")),this.saveSectionStatesToSessionStorage()}},e.prototype.originalSectionStates=function(){var e,t,n,i,o=this.loadSectionStatesFromSessionStorage();this.toggleMinimizeSection(this.controlsContainer.querySelector(".mouse-settings-section"),null===(e=o.mouse)||void 0===e||e),this.toggleMinimizeSection(this.controlsContainer.querySelector(".keyboard-settings-section"),null===(t=o.keyboard)||void 0===t||t),this.toggleMinimizeSection(this.controlsContainer.querySelector(".general-settings-section"),null===(n=o.general)||void 0===n||n),this.toggleMinimizeSection(this.controlsContainer.querySelector(".debugger-elements"),null!==(i=o.elements)&&void 0!==i&&i)},e.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="")))},e.prototype.updateControlsState=function(e){var t;this.trajectoryEnabledCheckbox&&(this.trajectoryEnabledCheckbox.checked=e.enableMousePrediction),this.tabEnabledCheckbox&&(this.tabEnabledCheckbox.checked=e.enableTabPrediction),this.showNameTagsCheckbox&&(this.showNameTagsCheckbox.checked=null!==(t=e.debuggerSettings.showNameTags)&&void 0!==t?t:k),this.historySizeSlider&&this.historyValueSpan&&(this.historySizeSlider.value=e.positionHistorySize.toString(),this.historyValueSpan.textContent="".concat(e.positionHistorySize," ").concat(S)),this.predictionTimeSlider&&this.predictionValueSpan&&(this.predictionTimeSlider.value=e.trajectoryPredictionTime.toString(),this.predictionValueSpan.textContent="".concat(e.trajectoryPredictionTime," ").concat(v)),this.tabOffsetSlider&&this.tabOffsetValueSpan&&(this.tabOffsetSlider.value=e.tabOffset.toString(),this.tabOffsetValueSpan.textContent="".concat(e.tabOffset," ").concat(x))},e.prototype.refreshRegisteredElementCountDisplay=function(e){if(this.elementCountSpan&&this.callbackCountSpan){var t=0;e.forEach((function(e){e.isIntersectingWithViewport&&t++}));var n=e.size,i=this.foresightManagerInstance.getManagerData.globalCallbackHits,o=i.tab,r=i.mouse;this.elementCountSpan.textContent="Visible: ".concat(t,"/").concat(n," ~ "),this.elementCountSpan.title="Total registered elements: ".concat(n,", visible in viewport: ").concat(t,", not in viewport: ").concat(n-t),this.callbackCountSpan.textContent="Mouse: ".concat(r," Tab: ").concat(o),this.callbackCountSpan.title="Total callbacks executed: Mouse: ".concat(r,", Tab: ").concat(o,", total: ").concat(r+o)}},e.prototype.refreshElementList=function(){var e=this;if(this.elementListItemsContainer){this.elementListItemsContainer.innerHTML="",this.elementListItems.clear();var t=this.foresightManagerInstance.registeredElements;this.refreshRegisteredElementCountDisplay(t),0!==t.size?t.forEach((function(t,n){var i=document.createElement("div");i.className="element-list-item",e.updateListItemContent(i,t),e.elementListItemsContainer.appendChild(i),e.elementListItems.set(n,i)})):this.elementListItemsContainer.innerHTML="<em>No elements registered.</em>"}},e.prototype.updateListItemContent=function(e,t){e.classList.toggle("hovering",t.isHovering),e.classList.toggle("trajectory-hit",t.trajectoryHitData.isTrajectoryHit),e.classList.toggle("not-in-viewport",!t.isIntersectingWithViewport),e.title=t.isIntersectingWithViewport?"".concat(t.name||"Element"," - is in viewport and being tracked by observers"):"".concat(t.name||"Element"," - is not in viewport and not being tracked by observers");var n=t.unregisterOnCallback?"Single":"Multi",i=t.unregisterOnCallback?"Callback triggers once, then element unregisters.":"Callback can trigger multiple times.",o="N/A",r="Hit Slop: Not defined";if(t.elementBounds.hitSlop){var s=t.elementBounds.hitSlop,a=s.top,l=s.right,c=s.bottom,d=s.left;o="T:".concat(a," R:").concat(l," B:").concat(c," L:").concat(d),r="Hit Slop (px): Top: ".concat(a,", Right: ").concat(l,", Bottom: ").concat(c,", Left: ").concat(d)}var u=t.isIntersectingWithViewport?"👁️":"🚫";e.innerHTML='\n <span class="viewport-indicator"">'.concat(u,'</span>\n <span class="element-name">').concat(t.name||"Unnamed Element",'</span>\n <span class="hit-slop" title="').concat(r,'">').concat(o,'</span>\n <span class="hit-behavior" title="').concat(i,'">').concat(n,"</span>\n ")},e.prototype.cleanup=function(){var e,t;null===(e=this.controlsContainer)||void 0===e||e.remove(),null===(t=this.controlPanelStyleElement)||void 0===t||t.remove(),this.copyTimeoutId&&(clearTimeout(this.copyTimeoutId),this.copyTimeoutId=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.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.showNameTagsCheckbox=null,this.copySettingsButton=null},e.prototype.createControlContainer=function(){var e=document.createElement("div");return e.id="debug-controls",e.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="Changes made here are for the current session only and won\'t persist. Update initial values in the ForesightManager.initialize() props for permanent changes.">i</span>\n </div>\n <button class="copy-settings-button" title="Copy current settings to clipboard">\n '.concat(M,'\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 mouse-settings-header">\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="Toggles mouse movement prediction. If disabled, only direct hovers trigger actions (or tab if enabled). - enableMousePrediction">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="Number of past mouse positions to use for velocity calculation. Higher values smooth predictions but add latency. - positionHistorySize">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="How many ').concat(v,' in the future to calculate the mouse trajectory. Larger value detects elements sooner. - trajectoryPredictionTime">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 keyboard-settings-header">\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="With tab prediction the callback will be executed when the user is tabOffset amount of ').concat(x,' away from an registered element (works with reversed shift-tabs) - enableTabPrediction.">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 Prediction Offset\n <span class="info-icon" title="Number of next/previous tabbable elements to consider for prediction when using the Tab key - tabOffset.">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 general-settings-section">\n <div class="debugger-section-header general-settings-header">\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="Toggles name tags, purely for debugging. - showNameTags">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 <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content element-list">\n <div id="element-list-items-container">\n <em>Initializing...</em>\n </div>\n </div>\n </div>\n '),e},e.prototype.getStyles=function(){return'\n #debug-controls {\n position: fixed; bottom: 10px; right: 10px;\n background-color: rgba(0, 0, 0, 0.75); 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\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 cursor: pointer;\n }\n .debugger-section-header h3 {\n margin: 0;\n font-size: 14px;\n font-weight: bold;\n color: #b0c4de;\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 .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 {\n width: 8px; \n }\n .element-list::-webkit-scrollbar-track {\n background: rgba(30, 30, 30, 0.5); \n border-radius: 4px;\n }\n .element-list::-webkit-scrollbar-thumb {\n background-color: rgba(176, 196, 222, 0.5); \n border-radius: 4px; \n border: 2px solid rgba(0, 0, 0, 0.2); \n }\n .element-list::-webkit-scrollbar-thumb:hover {\n background-color: rgba(176, 196, 222, 0.7);\n }\n /* Firefox scrollbar styling */\n .element-list {\n scrollbar-width: thin;\n scrollbar-color: rgba(176, 196, 222, 0.5) rgba(30, 30, 30, 0.5);\n }\n\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 {\n opacity: 0.4;\n }\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 .viewport-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 ")},e}(),I=function(){return window.matchMedia("(pointer: coarse)").matches&&navigator.maxTouchPoints>0};function O(e,t,n){var i=e.expandedOverlay,o=e.nameLabel,r=t.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="translate(".concat(r.left,"px, ").concat(r.top,"px)"),i.style.display="block",o.textContent=t.name,""!==t.name&&n?(o.style.display="block",o.style.transform="translate(".concat(r.left,"px, ").concat(r.top-25,"px)")):o.style.display="none"}var P=function(){function e(e){this.debugElementOverlays=new Map,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.lastElementData=new Map,this.foresightManagerInstance=e}return e.prototype._setupDOM=function(){this.shadowHost||(this.shadowHost=T("div",document.body,"","jsforesight-debugger-shadow-host"),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"}),this.debugContainer=T("div",this.shadowRoot,"","jsforesight-debug-container"),this.debugPredictedMouseIndicator=T("div",this.debugContainer,"jsforesight-mouse-predicted"),this.debugTrajectoryLine=T("div",this.debugContainer,"jsforesight-trajectory-line"),this.controlPanel=z.initialize(this.foresightManagerInstance,this.shadowRoot,this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings),j(L,this.shadowRoot))},Object.defineProperty(e,"isInitiated",{get:function(){return!!e.debuggerInstance},enumerable:!1,configurable:!0}),e.initialize=function(t,n){if(document.querySelectorAll("#jsforesight-debugger-shadow-host").forEach((function(e){return e.remove()})),"undefined"==typeof window||I())return null;e.isInitiated||(e.debuggerInstance=new e(t));var i=e.debuggerInstance;return i.shadowHost||i._setupDOM(),i.updateTrajectoryVisuals(n,t.getManagerData.globalSettings.enableMousePrediction),i},e.prototype.createElementOverlays=function(e){var t={expandedOverlay:T("div",this.debugContainer,"jsforesight-expanded-overlay"),nameLabel:T("div",this.debugContainer,"jsforesight-name-label")};return this.debugElementOverlays.set(e,t),t},e.prototype.createOrUpdateElementOverlay=function(e){var t;if(this.debugContainer&&this.shadowRoot){this.lastElementData.set(e.element,{isHovering:e.isHovering,isTrajectoryHit:e.trajectoryHitData.isTrajectoryHit});var n=this.debugElementOverlays.get(e.element);n||(n=this.createElementOverlays(e.element)),O(n,e,null!==(t=this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==t?t:k),this.controlPanel.refreshElementList()}},e.prototype.toggleNameTagVisibility=function(){var e=this;this.foresightManagerInstance.registeredElements.forEach((function(t){var n,i=e.debugElementOverlays.get(t.element);i&&O(i,t,null!==(n=e.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==n?n:k)}))},e.prototype.removeElement=function(e){var t,n=this.debugElementOverlays.get(e);n&&(n.expandedOverlay.remove(),n.nameLabel.remove(),this.debugElementOverlays.delete(e)),this.lastElementData.delete(e),null===(t=this.controlPanel)||void 0===t||t.refreshElementList()},e.prototype.updateTrajectoryVisuals=function(e,t){if(this.shadowRoot&&this.debugContainer&&this.debugPredictedMouseIndicator&&this.debugTrajectoryLine){var n=e.predictedPoint,i=e.currentPoint;if(this.debugPredictedMouseIndicator.style.transform="translate(".concat(n.x,"px, ").concat(n.y,"px) translate(-50%, -50%)"),this.debugPredictedMouseIndicator.style.display=t?"block":"none",0!==n.x||0!==n.y)if(t){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.debugTrajectoryLine.style.transform="translate(".concat(i.x,"px, ").concat(i.y,"px) rotate(").concat(a,"deg)"),this.debugTrajectoryLine.style.width="".concat(s,"px"),this.debugTrajectoryLine.style.display="block"}else this.debugTrajectoryLine.style.display="none";else this.debugPredictedMouseIndicator.style.display="none"}},e.prototype.updateControlsState=function(e){var t,n;null===(t=this.controlPanel)||void 0===t||t.updateControlsState(e),null===(n=this.controlPanel)||void 0===n||n.refreshElementList()},e.prototype.refreshDebuggerElementList=function(){var e;null===(e=this.controlPanel)||void 0===e||e.refreshElementList()},e.prototype.showCallbackAnimation=function(e){var t=this.debugElementOverlays.get(e.element);if(t){t.animation&&(clearTimeout(t.animation.timeoutId),t.animation.overlay.remove());var n=T("div",this.debugContainer,"jsforesight-callback-indicator"),i=e.elementBounds.expandedRect,o=i.left,r=i.top,s=i.right-o,a=i.bottom-r;n.style.display="block",n.style.translate="".concat(o,"px ").concat(r,"px"),n.style.width="".concat(s,"px"),n.style.height="".concat(a,"px"),requestAnimationFrame((function(){n.classList.add("animate")}));var l=setTimeout((function(){t.animation&&(t.animation.overlay.remove(),t.animation=void 0)}),400);t.animation={overlay:n,startTime:Date.now(),duration:400,timeoutId:l}}},e.prototype.cleanup=function(){var e,t;null===(e=this.controlPanel)||void 0===e||e.cleanup(),null===(t=this.shadowHost)||void 0===t||t.remove(),this.debugElementOverlays.clear(),this.lastElementData.clear(),this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.controlPanel=null},e}(),L='\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-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.4s ease-out forwards;\n }\n\n @keyframes jsforesight-callback-pulse {\n 0% {\n scale: 1;\n opacity: 1;\n box-shadow: 0 0 15px oklch(65% 0.22 280 / 0.7);\n }\n 100% {\n scale: 1.1; \n opacity: 0;\n box-shadow: 0 0 25px oklch(65% 0.22 280 / 0);\n }\n }\n ';function H(e,t,n,i,o){return i&&(e<t?console.warn('ForesightJS: "'.concat(o,'" value ').concat(e," is below minimum bound ").concat(t,", clamping to ").concat(t)):e>n&&console.warn('ForesightJS: "'.concat(o,'" value ').concat(e," is above maximum bound ").concat(n,", clamping to ").concat(n))),Math.min(Math.max(e,t),n)}function D(e,t,n){var i=0,o=1,r=t.x-e.x,s=t.y-e.y,a=function(e,t){if(0===e){if(t<0)return!1}else{var n=t/e;if(e<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,e.x-n.left)&&(!!a(r,n.right-e.x)&&(!!a(-s,e.y-n.top)&&(!!a(s,n.bottom-e.y)&&i<=o)))}function _(e,t){if("number"==typeof e){var n=H(e,0,w,t,"hitslop");return{top:n,left:n,right:n,bottom:n}}return{top:H(e.top,0,w,t,"hitslop - top"),left:H(e.left,0,w,t,"hitslop - left"),right:H(e.right,0,w,t,"hitslop - right"),bottom:H(e.bottom,0,w,t,"hitslop - bottom")}}function R(e,t){return{left:e.left-t.left,right:e.right+t.right,top:e.top-t.top,bottom:e.bottom+t.bottom}}function N(e,t){return e&&t?e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom:e===t}function B(e,t){return e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom}const A=e=>(e=>(e=>null!=e&&"object"==typeof e||!1)(e)&&"number"==typeof e.nodeType&&[1,2,3,4,5,6,7,8,9,10,11].some((t=>e.nodeType===t))||!1)(e)&&1===e.nodeType||!1;const V="PositionObserver Error";var q=class{entries;static version="1.0.11";_tick;_root;_callback;constructor(e,t){if("function"!=typeof e)throw new Error(`${V}: ${e} is not a function.`);this.entries=new Map,this._callback=e,this._root=A(t?.root)?t.root:document?.documentElement,this._tick=0}observe=e=>{if(!A(e))throw new Error(`${V}: ${e} is not an instance of Element.`);
7
- /* istanbul ignore else @preserve - a guard must be set */this._root.contains(e)&&this._new(e).then((({boundingClientRect:t})=>{
6
+ var t=["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(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},r=function e(t,n){var i;void 0===n&&(n=!0);var o=null==t||null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"inert");return""===o||"true"===o||n&&t&&e(t.parentNode)},s=function e(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=e(d.length?d:c.children,!0,s);s.flatten?a.push.apply(a,u):a.push({scopeParent:c,candidates:u})}else{i.call(c,t)&&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=e(!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(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},l=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!a(e)?0:e.tabIndex},c=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},d=function(e){return"INPUT"===e.tagName},u=function(e){return function(e){return d(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||o(e),i=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=i(window.CSS.escape(e.name));else try{t=i(e.name)}catch(e){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",e.message),!1}var r=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!r||r===e}(e)},h=function(e){var t=e.getBoundingClientRect(),n=t.width,i=t.height;return 0===n&&0===i},g=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var s=i.call(e,"details>summary:first-of-type")?e.parentElement:e;if(i.call(s,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return h(e)}else{if("function"==typeof r){for(var a=e;e;){var l=e.parentElement,c=o(e);if(l&&!l.shadowRoot&&!0===r(l))return h(e);e=e.assignedSlot?e.assignedSlot:l||c===e.ownerDocument?l:c.host}e=a}if(function(e){var t,n,i,r,s=e&&o(e),a=null===(t=s)||void 0===t?void 0:t.host,l=!1;if(s&&s!==e)for(l=!!(null!==(n=a)&&void 0!==n&&null!==(i=n.ownerDocument)&&void 0!==i&&i.contains(a)||null!=e&&null!==(r=e.ownerDocument)&&void 0!==r&&r.contains(e));!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}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},p=function(e,t){return!(t.disabled||r(t)||function(e){return d(e)&&"hidden"===e.type}(t)||g(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var o=t.children.item(n);if("LEGEND"===o.tagName)return!!i.call(t,"fieldset[disabled] *")||!o.contains(e)}return!0}t=t.parentElement}return!1}(t))},b=function(e,t){return!(u(t)||l(t)<0||!p(e,t))},m=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},f=function e(t){var n=[],i=[];return t.forEach((function(t,o){var r=!!t.scopeParent,s=r?t.scopeParent:t,c=function(e,t){var n=l(e);return n<0&&t&&!a(e)?0:n}(s,r),d=r?e(t.candidates):s;0===c?r?n.push.apply(n,d):n.push(s):i.push({documentOrder:o,tabIndex:c,item:t,isScope:r,content:d})})),i.sort(c).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},y=function(e,n){var o;return o=(n=n||{}).getShadowRoot?s([e],n.includeContainer,{filter:b.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:m}):function(e,n,o){if(r(e))return[];var s=Array.prototype.slice.apply(e.querySelectorAll(t));return n&&i.call(e,t)&&s.unshift(e),s.filter(o)}(e,n.includeContainer,b.bind(null,n)),f(o)},v="ms",S="points",x="tabs",w=2e3,C=!1,k=!0;var E=function(e,t){void 0===t&&(t=2);var n=" ".repeat(t);if("object"==typeof e&&null!==e&&!Array.isArray(e)){var i=Object.entries(e);if(0===i.length)return"{}";var o=i.map((function(e){var i=e[0],o=e[1];return"".concat(n," ").concat(i,": ").concat(E(o,t+2))})).join(",\n");return"{\n".concat(o,"\n").concat(n,"}")}return"string"==typeof e?"'".concat(e,"'"):"boolean"==typeof e||"number"==typeof e?String(e):null===e?"null":void 0===e?"undefined":Array.isArray(e)?JSON.stringify(e):String(e)};function T(e,t,n){var i=document.createElement(e);return n.id&&(i.id=n.id),n.className&&(i.className=n.className),n.data&&i.setAttribute("data-value",n.data),t.appendChild(i)}function M(e,t,n){var i=document.createElement("style");return i.textContent=e,i.id=n,t.appendChild(i)}var j='<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>',z=function(){function e(e){this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems=new Map,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.showNameTagsCheckbox=null,this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.isContainerMinimized=!1,this.isMouseSettingsMinimized=!0,this.isKeyboardSettingsMinimized=!0,this.isGeneralSettingsMinimized=!0,this.isElementsListMinimized=!0,this.SESSION_STORAGE_KEY="jsforesightDebuggerSectionStates",this.copySettingsButton=null,this.copyTimeoutId=null,this.foresightManagerInstance=e}return e.prototype._setupDOMAndListeners=function(e,t){var n;this.controlsContainer||(this.shadowRoot=e,this.isContainerMinimized=null!==(n=t.isControlPanelDefaultMinimized)&&void 0!==n?n:C,this.controlsContainer=this.createControlContainer(),this.shadowRoot.appendChild(this.controlsContainer),this.controlPanelStyleElement=M(this.getStyles(),this.shadowRoot,"debug-control-panel"),this.queryDOMElements(),this.originalSectionStates(),this.setupEventListeners(),this.refreshElementList(),this.updateContainerVisibilityState())},e.initialize=function(t,n,i){e.isInitiated||(e.debuggerControlPanelInstance=new e(t));var o=e.debuggerControlPanelInstance;return o._setupDOMAndListeners(n,i),o},Object.defineProperty(e,"isInitiated",{get:function(){return!!e.debuggerControlPanelInstance},enumerable:!1,configurable:!0}),e.prototype.loadSectionStatesFromSessionStorage=function(){var e,t,n,i,o=sessionStorage.getItem(this.SESSION_STORAGE_KEY),r={};return o&&(r=JSON.parse(o)),this.isMouseSettingsMinimized=null===(e=r.mouse)||void 0===e||e,this.isKeyboardSettingsMinimized=null===(t=r.keyboard)||void 0===t||t,this.isGeneralSettingsMinimized=null===(n=r.general)||void 0===n||n,this.isElementsListMinimized=null!==(i=r.elements)&&void 0!==i&&i,r},e.prototype.saveSectionStatesToSessionStorage=function(){var e={mouse:this.isMouseSettingsMinimized,keyboard:this.isKeyboardSettingsMinimized,general:this.isGeneralSettingsMinimized,elements:this.isElementsListMinimized};try{sessionStorage.setItem(this.SESSION_STORAGE_KEY,JSON.stringify(e))}catch(e){console.error("Foresight Debugger: Could not save section states to session storage.",e)}},e.prototype.queryDOMElements=function(){this.trajectoryEnabledCheckbox=this.controlsContainer.querySelector("#trajectory-enabled"),this.tabEnabledCheckbox=this.controlsContainer.querySelector("#tab-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.elementListItemsContainer=this.controlsContainer.querySelector("#element-list-items-container"),this.showNameTagsCheckbox=this.controlsContainer.querySelector("#toggle-name-tags"),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")},e.prototype.handleCopySettings=function(){var e,t,n,i=this;this.copySettingsButton&&navigator.clipboard.writeText((e=this.foresightManagerInstance.getManagerData.globalSettings,t="ForesightManager.initialize",n=Object.entries(e).filter((function(e){var t=e[0];return"resizeScrollThrottleDelay"!==String(t)})).map((function(e){var t=e[0],n=e[1];return" ".concat(String(t),": ").concat(E(n))})).join(",\n"),"".concat(t,"({\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=j),i.copyTimeoutId=null}),3e3)})).catch((function(e){console.error("Foresight Debugger: Could not copy settings to clipboard",e)}))},e.prototype.createInputEventListener=function(e,t,n,i){var o=this;e&&t&&e.addEventListener("input",(function(e){var r,s=parseInt(e.target.value,10);t.textContent="".concat(s," ").concat(n),o.foresightManagerInstance.alterGlobalSettings(((r={})[i]=s,r))}))},e.prototype.createChangeEventListener=function(e,t){var n=this;e&&e.addEventListener("change",(function(e){var i;"name-tag"===t?n.foresightManagerInstance.alterGlobalSettings({debuggerSettings:{showNameTags:e.target.checked}}):n.foresightManagerInstance.alterGlobalSettings(((i={})[t]=e.target.checked,i))}))},e.prototype.createSectionVisibilityToggleEventListener=function(e,t){var n=this,i=null==e?void 0:e.querySelector(".debugger-section-header");null==i||i.addEventListener("click",(function(i){i.stopPropagation(),n.toggleMinimizeSection(e,n[t]=!n[t])}))},e.prototype.setupEventListeners=function(){var e,t,n=this;this.createChangeEventListener(this.trajectoryEnabledCheckbox,"enableMousePrediction"),this.createChangeEventListener(this.tabEnabledCheckbox,"enableTabPrediction"),this.createChangeEventListener(this.showNameTagsCheckbox,"name-tag"),this.createInputEventListener(this.historySizeSlider,this.historyValueSpan,S,"positionHistorySize"),this.createInputEventListener(this.predictionTimeSlider,this.predictionValueSpan,v,"trajectoryPredictionTime"),this.createInputEventListener(this.tabOffsetSlider,this.tabOffsetValueSpan,x,"tabOffset"),null===(e=this.containerMinimizeButton)||void 0===e||e.addEventListener("click",(function(){n.isContainerMinimized=!n.isContainerMinimized,n.updateContainerVisibilityState()})),null===(t=this.copySettingsButton)||void 0===t||t.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(".general-settings-section"),"isGeneralSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".debugger-elements"),"isElementsListMinimized")},e.prototype.toggleMinimizeSection=function(e,t){if(e){var n=e.querySelector(".debugger-section-content"),i=e.querySelector(".section-minimize-button");n&&i&&(t?(n.style.display="none",i.textContent="+"):(n.style.display="flex",i.textContent="-")),this.saveSectionStatesToSessionStorage()}},e.prototype.originalSectionStates=function(){var e,t,n,i,o=this.loadSectionStatesFromSessionStorage();this.toggleMinimizeSection(this.controlsContainer.querySelector(".mouse-settings-section"),null===(e=o.mouse)||void 0===e||e),this.toggleMinimizeSection(this.controlsContainer.querySelector(".keyboard-settings-section"),null===(t=o.keyboard)||void 0===t||t),this.toggleMinimizeSection(this.controlsContainer.querySelector(".general-settings-section"),null===(n=o.general)||void 0===n||n),this.toggleMinimizeSection(this.controlsContainer.querySelector(".debugger-elements"),null!==(i=o.elements)&&void 0!==i&&i)},e.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="")))},e.prototype.updateControlsState=function(e){var t;this.trajectoryEnabledCheckbox&&(this.trajectoryEnabledCheckbox.checked=e.enableMousePrediction),this.tabEnabledCheckbox&&(this.tabEnabledCheckbox.checked=e.enableTabPrediction),this.showNameTagsCheckbox&&(this.showNameTagsCheckbox.checked=null!==(t=e.debuggerSettings.showNameTags)&&void 0!==t?t:k),this.historySizeSlider&&this.historyValueSpan&&(this.historySizeSlider.value=e.positionHistorySize.toString(),this.historyValueSpan.textContent="".concat(e.positionHistorySize," ").concat(S)),this.predictionTimeSlider&&this.predictionValueSpan&&(this.predictionTimeSlider.value=e.trajectoryPredictionTime.toString(),this.predictionValueSpan.textContent="".concat(e.trajectoryPredictionTime," ").concat(v)),this.tabOffsetSlider&&this.tabOffsetValueSpan&&(this.tabOffsetSlider.value=e.tabOffset.toString(),this.tabOffsetValueSpan.textContent="".concat(e.tabOffset," ").concat(x))},e.prototype.refreshRegisteredElementCountDisplay=function(e){if(this.elementCountSpan&&this.callbackCountSpan){var t=0;e.forEach((function(e){e.isIntersectingWithViewport&&t++}));var n=e.size,i=this.foresightManagerInstance.getManagerData.globalCallbackHits,o=i.tab,r=i.mouse;this.elementCountSpan.textContent="Visible: ".concat(t,"/").concat(n," ~ "),this.elementCountSpan.title="Total registered elements: ".concat(n,", visible in viewport: ").concat(t,", not in viewport: ").concat(n-t),this.callbackCountSpan.textContent="Mouse: ".concat(r," Tab: ").concat(o),this.callbackCountSpan.title="Total callbacks executed: Mouse: ".concat(r,", Tab: ").concat(o,", total: ").concat(r+o)}},e.prototype.refreshElementList=function(){var e=this;if(this.elementListItemsContainer){this.elementListItemsContainer.innerHTML="",this.elementListItems.clear();var t=this.foresightManagerInstance.registeredElements;this.refreshRegisteredElementCountDisplay(t),0!==t.size?t.forEach((function(t,n){var i=document.createElement("div");i.className="element-list-item",e.updateListItemContent(i,t),e.elementListItemsContainer.appendChild(i),e.elementListItems.set(n,i)})):this.elementListItemsContainer.innerHTML="<em>No elements registered.</em>"}},e.prototype.updateListItemContent=function(e,t){e.classList.toggle("hovering",t.isHovering),e.classList.toggle("trajectory-hit",t.trajectoryHitData.isTrajectoryHit),e.classList.toggle("not-in-viewport",!t.isIntersectingWithViewport),e.title=t.isIntersectingWithViewport?"".concat(t.name||"Element"," - is in viewport and being tracked by observers"):"".concat(t.name||"Element"," - is not in viewport and not being tracked by observers");var n=t.unregisterOnCallback?"Single":"Multi",i=t.unregisterOnCallback?"Callback triggers once, then element unregisters.":"Callback can trigger multiple times.",o="N/A",r="Hit Slop: Not defined";if(t.elementBounds.hitSlop){var s=t.elementBounds.hitSlop,a=s.top,l=s.right,c=s.bottom,d=s.left;o="T:".concat(a," R:").concat(l," B:").concat(c," L:").concat(d),r="Hit Slop (px): Top: ".concat(a,", Right: ").concat(l,", Bottom: ").concat(c,", Left: ").concat(d)}var u=t.isIntersectingWithViewport?"👁️":"🚫";e.innerHTML='\n <span class="viewport-indicator"">'.concat(u,'</span>\n <span class="element-name">').concat(t.name||"Unnamed Element",'</span>\n <span class="hit-slop" title="').concat(r,'">').concat(o,'</span>\n <span class="hit-behavior" title="').concat(i,'">').concat(n,"</span>\n ")},e.prototype.cleanup=function(){var e,t;null===(e=this.controlsContainer)||void 0===e||e.remove(),null===(t=this.controlPanelStyleElement)||void 0===t||t.remove(),this.copyTimeoutId&&(clearTimeout(this.copyTimeoutId),this.copyTimeoutId=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.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.showNameTagsCheckbox=null,this.copySettingsButton=null},e.prototype.createControlContainer=function(){var e=document.createElement("div");return e.id="debug-controls",e.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="Changes made here are for the current session only and won\'t persist. Update initial values in the ForesightManager.initialize() props for permanent changes.">i</span>\n </div>\n <button class="copy-settings-button" title="Copy current settings to clipboard">\n '.concat(j,'\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 mouse-settings-header">\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="Toggles mouse movement prediction. If disabled, only direct hovers trigger actions (or tab if enabled). - enableMousePrediction">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="Number of past mouse positions to use for velocity calculation. Higher values smooth predictions but add latency. - positionHistorySize">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="How many ').concat(v,' in the future to calculate the mouse trajectory. Larger value detects elements sooner. - trajectoryPredictionTime">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 keyboard-settings-header">\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="With tab prediction the callback will be executed when the user is tabOffset amount of ').concat(x,' away from an registered element (works with reversed shift-tabs) - enableTabPrediction.">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 Prediction Offset\n <span class="info-icon" title="Number of next/previous tabbable elements to consider for prediction when using the Tab key - tabOffset.">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 general-settings-section">\n <div class="debugger-section-header general-settings-header">\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="Toggles name tags, purely for debugging. - showNameTags">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 <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content element-list">\n <div id="element-list-items-container">\n <em>Initializing...</em>\n </div>\n </div>\n </div>\n '),e},e.prototype.getStyles=function(){return'\n #debug-controls {\n position: fixed; bottom: 10px; right: 10px;\n background-color: rgba(0, 0, 0, 0.75); 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\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 cursor: pointer;\n }\n .debugger-section-header h3 {\n margin: 0;\n font-size: 14px;\n font-weight: bold;\n color: #b0c4de;\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 .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 {\n width: 8px; \n }\n .element-list::-webkit-scrollbar-track {\n background: rgba(30, 30, 30, 0.5); \n border-radius: 4px;\n }\n .element-list::-webkit-scrollbar-thumb {\n background-color: rgba(176, 196, 222, 0.5); \n border-radius: 4px; \n border: 2px solid rgba(0, 0, 0, 0.2); \n }\n .element-list::-webkit-scrollbar-thumb:hover {\n background-color: rgba(176, 196, 222, 0.7);\n }\n /* Firefox scrollbar styling */\n .element-list {\n scrollbar-width: thin;\n scrollbar-color: rgba(176, 196, 222, 0.5) rgba(30, 30, 30, 0.5);\n }\n\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 {\n opacity: 0.4;\n }\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 .viewport-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 ")},e}(),P=function(){return window.matchMedia("(pointer: coarse)").matches&&navigator.maxTouchPoints>0};function I(e,t,n){var i=e.expandedOverlay,o=e.nameLabel,r=t.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="translate(".concat(r.left,"px, ").concat(r.top,"px)"),i.style.display="block",o.textContent=t.name,""!==t.name&&n?(o.style.display="block",o.style.transform="translate(".concat(r.left,"px, ").concat(r.top-25,"px)")):o.style.display="none"}var O=function(){function e(e){this.debugElementOverlays=new Map,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.lastElementData=new Map,this.foresightManagerInstance=e}return e.prototype._setupDOM=function(){this.shadowHost||(this.shadowHost=T("div",document.body,{id:"jsforesight-debugger-shadow-host"}),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"}),this.debugContainer=T("div",this.shadowRoot,{id:"jsforesight-debug-container"}),this.debugPredictedMouseIndicator=T("div",this.debugContainer,{className:"jsforesight-mouse-predicted"}),this.debugTrajectoryLine=T("div",this.debugContainer,{className:"jsforesight-trajectory-line"}),this.controlPanel=z.initialize(this.foresightManagerInstance,this.shadowRoot,this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings),M(L,this.shadowRoot,"screen-visuals"))},Object.defineProperty(e,"isInitiated",{get:function(){return!!e.debuggerInstance},enumerable:!1,configurable:!0}),e.initialize=function(t,n){if(document.querySelectorAll("#jsforesight-debugger-shadow-host").forEach((function(e){return e.remove()})),"undefined"==typeof window||P())return null;e.isInitiated||(e.debuggerInstance=new e(t));var i=e.debuggerInstance;return i.shadowHost||i._setupDOM(),i.updateTrajectoryVisuals(n,t.getManagerData.globalSettings.enableMousePrediction),i},e.prototype.createElementOverlays=function(e){var t={expandedOverlay:T("div",this.debugContainer,{className:"jsforesight-expanded-overlay",data:e.name}),nameLabel:T("div",this.debugContainer,{className:"jsforesight-name-label"})};return this.debugElementOverlays.set(e.element,t),t},e.prototype.createOrUpdateElementOverlay=function(e){var t;if(this.debugContainer&&this.shadowRoot){this.lastElementData.set(e.element,{isHovering:e.isHovering,isTrajectoryHit:e.trajectoryHitData.isTrajectoryHit});var n=this.debugElementOverlays.get(e.element);n||(n=this.createElementOverlays(e)),I(n,e,null!==(t=this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==t?t:k),this.controlPanel.refreshElementList()}},e.prototype.toggleNameTagVisibility=function(){var e=this;this.foresightManagerInstance.registeredElements.forEach((function(t){var n,i=e.debugElementOverlays.get(t.element);i&&I(i,t,null!==(n=e.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==n?n:k)}))},e.prototype.removeElement=function(e){var t,n=this.debugElementOverlays.get(e);n&&(n.expandedOverlay.remove(),n.nameLabel.remove(),this.debugElementOverlays.delete(e)),this.lastElementData.delete(e),null===(t=this.controlPanel)||void 0===t||t.refreshElementList()},e.prototype.updateTrajectoryVisuals=function(e,t){if(this.shadowRoot&&this.debugContainer&&this.debugPredictedMouseIndicator&&this.debugTrajectoryLine){var n=e.predictedPoint,i=e.currentPoint;if(this.debugPredictedMouseIndicator.style.transform="translate(".concat(n.x,"px, ").concat(n.y,"px) translate(-50%, -50%)"),this.debugPredictedMouseIndicator.style.display=t?"block":"none",0!==n.x||0!==n.y)if(t){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.debugTrajectoryLine.style.transform="translate(".concat(i.x,"px, ").concat(i.y,"px) rotate(").concat(a,"deg)"),this.debugTrajectoryLine.style.width="".concat(s,"px"),this.debugTrajectoryLine.style.display="block"}else this.debugTrajectoryLine.style.display="none";else this.debugPredictedMouseIndicator.style.display="none"}},e.prototype.updateControlsState=function(e){var t,n;null===(t=this.controlPanel)||void 0===t||t.updateControlsState(e),null===(n=this.controlPanel)||void 0===n||n.refreshElementList()},e.prototype.refreshDebuggerElementList=function(){var e;null===(e=this.controlPanel)||void 0===e||e.refreshElementList()},e.prototype.showCallbackAnimation=function(e){var t=this.debugElementOverlays.get(e.element);if(t){t.animation&&(clearTimeout(t.animation.timeoutId),t.animation.overlay.remove());var n=T("div",this.debugContainer,{className:"jsforesight-callback-indicator"}),i=e.elementBounds.expandedRect,o=i.left,r=i.top,s=i.right-o,a=i.bottom-r;n.style.display="block",n.style.translate="".concat(o,"px ").concat(r,"px"),n.style.width="".concat(s,"px"),n.style.height="".concat(a,"px"),requestAnimationFrame((function(){n.classList.add("animate")}));var l=setTimeout((function(){t.animation&&(t.animation.overlay.remove(),t.animation=void 0)}),400);t.animation={overlay:n,startTime:Date.now(),duration:400,timeoutId:l}}},e.prototype.cleanup=function(){var e,t;null===(e=this.controlPanel)||void 0===e||e.cleanup(),null===(t=this.shadowHost)||void 0===t||t.remove(),this.debugElementOverlays.clear(),this.lastElementData.clear(),this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.controlPanel=null},e}(),L='\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-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.4s ease-out forwards;\n }\n\n @keyframes jsforesight-callback-pulse {\n 0% {\n scale: 1;\n opacity: 1;\n box-shadow: 0 0 15px oklch(65% 0.22 280 / 0.7);\n }\n 100% {\n scale: 1.1; \n opacity: 0;\n box-shadow: 0 0 25px oklch(65% 0.22 280 / 0);\n }\n }\n ';function H(e,t,n,i,o){return i&&(e<t?console.warn('ForesightJS: "'.concat(o,'" value ').concat(e," is below minimum bound ").concat(t,", clamping to ").concat(t)):e>n&&console.warn('ForesightJS: "'.concat(o,'" value ').concat(e," is above maximum bound ").concat(n,", clamping to ").concat(n))),Math.min(Math.max(e,t),n)}function _(e,t,n){var i=0,o=1,r=t.x-e.x,s=t.y-e.y,a=function(e,t){if(0===e){if(t<0)return!1}else{var n=t/e;if(e<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,e.x-n.left)&&(!!a(r,n.right-e.x)&&(!!a(-s,e.y-n.top)&&(!!a(s,n.bottom-e.y)&&i<=o)))}function D(e,t){if("number"==typeof e){var n=H(e,0,w,t,"hitslop");return{top:n,left:n,right:n,bottom:n}}return{top:H(e.top,0,w,t,"hitslop - top"),left:H(e.left,0,w,t,"hitslop - left"),right:H(e.right,0,w,t,"hitslop - right"),bottom:H(e.bottom,0,w,t,"hitslop - bottom")}}function N(e,t){return{left:e.left-t.left,right:e.right+t.right,top:e.top-t.top,bottom:e.bottom+t.bottom}}function R(e,t){return e&&t?e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom:e===t}function B(e,t){return e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom}function A(e,t){return void 0!==e&&t!==e}const V=e=>(e=>(e=>null!=e&&"object"==typeof e||!1)(e)&&"number"==typeof e.nodeType&&[1,2,3,4,5,6,7,8,9,10,11].some((t=>e.nodeType===t))||!1)(e)&&1===e.nodeType||!1;const q=["all","intersecting","update"],F="PositionObserver Error";var G=class{entries;static version="1.1.0";_t;_r;_cm;_w;_h;_rm;_th;_c;constructor(e,t){if("function"!=typeof e)throw new Error(`${F}: ${e} is not a function.`);this.entries=new Map,this._c=e,this._t=0;const n=V(t?.root)?t.root:document?.documentElement;this._r=n,this._rm=t?.rootMargin,this._th=t?.threshold,
7
+ /* istanbul ignore next @preserve */
8
+ this._cm=q.indexOf(t?.callbackMode||"intersecting"),this._w=n.clientWidth,this._h=n.clientHeight}observe=e=>{if(console.log("here"),!V(e))throw new Error(`${F}: ${e} is not an instance of Element.`);
9
+ /* istanbul ignore else @preserve - a guard must be set */this._r.contains(e)&&this._n(e).then((t=>{
8
10
  /* istanbul ignore else @preserve - don't allow duplicate entries */
9
- if(t&&!this.getEntry(e)){const{clientWidth:n,clientHeight:i}=this._root;this.entries.set(e,{target:e,boundingClientRect:t,clientWidth:n,clientHeight:i})}
10
- /* istanbul ignore else @preserve */this._tick||(this._tick=requestAnimationFrame(this._runCallback))}))};unobserve=e=>{
11
+ t.boundingClientRect&&!this.getEntry(e)&&this.entries.set(e,t)
12
+ /* istanbul ignore else @preserve */,this._t||(this._t=requestAnimationFrame(this._rc))}))};unobserve=e=>{
11
13
  /* istanbul ignore else @preserve */
12
- this.entries.has(e)&&this.entries.delete(e)};_runCallback=()=>{
14
+ this.entries.has(e)&&this.entries.delete(e)};_rc=()=>{
13
15
  /* istanbul ignore if @preserve - a guard must be set */
14
- if(!this.entries.size)return void(this._tick=0);const{clientWidth:e,clientHeight:t}=this._root,n=new Promise((n=>{const i=[];this.entries.forEach((({target:n,boundingClientRect:o,clientWidth:r,clientHeight:s})=>{
16
+ if(!this.entries.size)return void(this._t=0);const{clientWidth:e,clientHeight:t}=this._r,n=new Promise((n=>{const i=[];this.entries.forEach((({target:n,boundingClientRect:o,isIntersecting:r})=>{
15
17
  /* istanbul ignore if @preserve - a guard must be set when target has been removed */
16
- this._root.contains(n)&&this._new(n).then((({boundingClientRect:a,isIntersecting:l})=>{
18
+ this._r.contains(n)&&this._n(n).then((s=>{
17
19
  /* istanbul ignore if @preserve - make sure to only count visible entries */
18
- if(!l)return;const{left:c,top:d}=a;
19
- /* istanbul ignore else @preserve - only schedule entries that changed position */if(o.top!==d||o.left!==c||r!==e||s!==t){const o={target:n,boundingClientRect:a,clientHeight:t,clientWidth:e};this.entries.set(n,o),i.push(o)}}))})),n(i)}));this._tick=requestAnimationFrame((async()=>{const e=await n;
20
- /* istanbul ignore else @preserve */e.length&&this._callback(e,this),this._runCallback()}))};_new=e=>new Promise((t=>{new IntersectionObserver((([e],n)=>{n.disconnect(),t(e)})).observe(e)}));getEntry=e=>this.entries.get(e);disconnect=()=>{cancelAnimationFrame(this._tick),this.entries.clear(),this._tick=0}};function F(e,t){return void 0!==e&&t!==e}var U=function(){function t(){var e=this;this.elements=new Map,this.isSetup=!1,this.debugger=null,this._globalCallbackHits={mouse:0,tab:0,total:0},this._globalSettings={debug:false,enableMousePrediction:true,positionHistorySize:8,trajectoryPredictionTime:120,defaultHitSlop:{top:0,left:0,right:0,bottom:0},resizeScrollThrottleDelay:0,debuggerSettings:{isControlPanelDefaultMinimized:C,showNameTags:k},enableTabPrediction:true,tabOffset:2,onAnyCallbackFired:function(e,t){}},this.trajectoryPositions={positions:[],currentPoint:{x:0,y:0},predictedPoint:{x:0,y:0}},this.domObserver=null,this.elementIntersectionObserver=null,this.positionObserver=null,this.lastKeyDown=null,this.globalListenersController=null,this.handleMouseMove=function(t){e.updatePointerState(t),e.elements.forEach((function(t){t.isIntersectingWithViewport&&(t.unregisterOnCallback?e.handleSingleCallbackInteraction(t):e.handleMultiCallbackInteraction(t))})),e.debugger&&e.debugger.updateTrajectoryVisuals(e.trajectoryPositions,e._globalSettings.enableMousePrediction)},this.handleDomMutations=function(t){for(var n=0,i=t;n<i.length;n++){var o=i[n];if("childList"===o.type&&o.removedNodes.length>0)for(var r=0,s=Array.from(e.elements.keys());r<s.length;r++){var a=s[r];a.isConnected||e.unregister(a)}}},this.handleKeyDown=function(t){"Tab"===t.key?e.lastKeyDown=t:e.lastKeyDown=null},this.handleFocusIn=function(t){if(e.lastKeyDown&&e._globalSettings.enableTabPrediction){var n=t.target;if(n instanceof HTMLElement){var i=y(document.documentElement),o=i.findIndex((function(e){return e===n})),r=e.lastKeyDown.shiftKey?-e._globalSettings.tabOffset:e._globalSettings.tabOffset;e.lastKeyDown=null;for(var s=[],a=0;a<i.length;a++){var l=i[a];(r>0?a>=o&&a<=o+r:a<=o&&a>=o+r)&&e.elements.has(l)&&s.push(l)}s.forEach((function(t){e.callCallback(e.elements.get(t),"tab")}))}}},this.handleIntersection=function(t){for(var n,i,o,r,s=0,a=t;s<a.length;s++){var l=a[s],c=e.elements.get(l.target);if(!c)return;c.isIntersectingWithViewport=l.isIntersecting,l.isIntersecting?(c.elementBounds.originalRect=l.boundingClientRect,c.elementBounds.expandedRect=R(c.elementBounds.originalRect,c.elementBounds.hitSlop),e.positionObserver?null===(n=e.positionObserver)||void 0===n||n.observe(l.target):console.warn("ForesightJS: PositionObserver is not initialized. This might lead to incorrect behavior when observing elements."),e._globalSettings.debug&&(null===(i=e.debugger)||void 0===i||i.createOrUpdateElementOverlay(c))):(null===(o=e.positionObserver)||void 0===o||o.unobserve(l.target),e._globalSettings.debug&&(null===(r=e.debugger)||void 0===r||r.removeElement(l.target)))}},this.handlePositionChange=function(t,n){t.forEach((function(t){var n=e.elements.get(t.target);n&&e.updateElementBounds(t.boundingClientRect,n)}))}}return t.initialize=function(e){return this.isInitiated||(t.manager=new t),void 0!==e&&t.manager.alterGlobalSettings(e),t.manager},Object.defineProperty(t.prototype,"getManagerData",{get:function(){var e;return{registeredElements:this.elements,globalSettings:this._globalSettings,globalCallbackHits:this._globalCallbackHits,positionObserverElements:null===(e=this.positionObserver)||void 0===e?void 0:e.entries}},enumerable:!1,configurable:!0}),Object.defineProperty(t,"isInitiated",{get:function(){return!!t.manager},enumerable:!1,configurable:!0}),Object.defineProperty(t,"instance",{get:function(){return this.initialize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"registeredElements",{get:function(){return this.elements},enumerable:!1,configurable:!0}),t.prototype.register=function(e){var t,n,i=this,o=e.element,r=e.callback,s=e.hitSlop,a=e.unregisterOnCallback,l=e.name;if(I())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?_(s,this._globalSettings.debug):this._globalSettings.defaultHitSlop,d=o.getBoundingClientRect(),u={element:o,callback:r,callbackHits:{mouse:0,tab:0,total:0},elementBounds:{originalRect:d,expandedRect:R(d,c),hitSlop:c},isHovering:!1,trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0},name:null!==(t=null!=l?l:o.id)&&void 0!==t?t:"",unregisterOnCallback:null==a||a,isIntersectingWithViewport:!1};return this.elements.set(o,u),null===(n=this.elementIntersectionObserver)||void 0===n||n.observe(o),this.debugger&&this.debugger.createOrUpdateElementOverlay(u),{isTouchDevice:!1,unregister:function(){return i.unregister(o)}}},t.prototype.unregister=function(e){var t;if(this.elements.has(e)){var n=this.elements.get(e);(null==n?void 0:n.trajectoryHitData.trajectoryHitExpirationTimeoutId)&&clearTimeout(n.trajectoryHitData.trajectoryHitExpirationTimeoutId),null===(t=this.elementIntersectionObserver)||void 0===t||t.unobserve(e),this.elements.delete(e),this.debugger&&this.debugger.removeElement(e),0===this.elements.size&&this.isSetup&&this.removeGlobalListeners()}},t.prototype.updateNumericSettings=function(e,t,n,i){return!!F(e,this._globalSettings[t])&&(this._globalSettings[t]=H(e,n,i,this._globalSettings.debug,t),!0)},t.prototype.updateBooleanSetting=function(e,t){return!!F(e,this._globalSettings[t])&&(this._globalSettings[t]=e,!0)},t.prototype.alterGlobalSettings=function(e){var t,n,i=this._globalSettings.positionHistorySize,o=this.updateNumericSettings(null==e?void 0:e.positionHistorySize,"positionHistorySize",2,30);o&&this._globalSettings.positionHistorySize<i&&this.trajectoryPositions.positions.length>this._globalSettings.positionHistorySize&&(this.trajectoryPositions.positions=this.trajectoryPositions.positions.slice(this.trajectoryPositions.positions.length-this._globalSettings.positionHistorySize));var r=this.updateNumericSettings(null==e?void 0:e.trajectoryPredictionTime,"trajectoryPredictionTime",10,200),s=this.updateNumericSettings(null==e?void 0:e.tabOffset,"tabOffset",0,20);void 0!==(null==e?void 0:e.resizeScrollThrottleDelay)&&console.warn("resizeScrollThrottleDelay is deprecated and will be removed in V3.0.0 of ForesightJS");var a=this.updateBooleanSetting(null==e?void 0:e.enableMousePrediction,"enableMousePrediction"),l=this.updateBooleanSetting(null==e?void 0:e.enableTabPrediction,"enableTabPrediction");void 0!==(null==e?void 0:e.onAnyCallbackFired)&&(this._globalSettings.onAnyCallbackFired=e.onAnyCallbackFired);var c=!1;void 0!==(null===(t=null==e?void 0:e.debuggerSettings)||void 0===t?void 0:t.isControlPanelDefaultMinimized)&&(this._globalSettings.debuggerSettings.isControlPanelDefaultMinimized=e.debuggerSettings.isControlPanelDefaultMinimized,c=!0),void 0!==(null===(n=null==e?void 0:e.debuggerSettings)||void 0===n?void 0:n.showNameTags)&&(this._globalSettings.debuggerSettings.showNameTags=e.debuggerSettings.showNameTags,c=!0,this.debugger&&this.debugger.toggleNameTagVisibility());var d=!1;if(void 0!==(null==e?void 0:e.defaultHitSlop)){var u=_(e.defaultHitSlop,this._globalSettings.debug);N(this._globalSettings.defaultHitSlop,u)||(this._globalSettings.defaultHitSlop=u,d=!0,this.forceUpdateAllElementBounds())}var g=!1;void 0!==(null==e?void 0:e.debug)&&this._globalSettings.debug!==e.debug&&"undefined"!=typeof window&&"undefined"!=typeof document&&(this._globalSettings.debug=e.debug,g=!0,this._globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null)),(o||r||s||a||l||c||d||g)&&this.debugger&&this.debugger.updateControlsState(this._globalSettings)},t.prototype.turnOnDebugMode=function(){var e=this;this.debugger?this.debugger.updateControlsState(this._globalSettings):(this.debugger=P.initialize(t.instance,this.trajectoryPositions),this.elements.forEach((function(t){var n;null===(n=e.debugger)||void 0===n||n.createOrUpdateElementOverlay(t)})))},t.prototype.forceUpdateAllElementBounds=function(){var e=this;this.elements.forEach((function(t,n){var i=e.elements.get(n);i&&i.isIntersectingWithViewport&&e.forceUpdateElementBounds(i)}))},t.prototype.updatePointerState=function(t){this.trajectoryPositions.currentPoint={x:t.clientX,y:t.clientY},this.trajectoryPositions.predictedPoint=this._globalSettings.enableMousePrediction?function(e,t,n,i){var o={point:e,time:performance.now()},r=e.x,s=e.y;if(t.push(o),t.length>n&&t.shift(),t.length<2)return{x:r,y:s};var a=t[0],l=t[t.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):e({},this.trajectoryPositions.currentPoint)},t.prototype.handleSingleCallbackInteraction=function(e){var t=e.elementBounds.expandedRect;this._globalSettings.enableMousePrediction?D(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,t)&&this.callCallback(e,"mouse"):B(this.trajectoryPositions.currentPoint,t)&&this.callCallback(e,"mouse")},t.prototype.handleMultiCallbackInteraction=function(t){var n=this,i=t.elementBounds.expandedRect,o=B(this.trajectoryPositions.currentPoint,i),r=o&&!t.isHovering,s=this._globalSettings.enableMousePrediction&&!o&&!t.trajectoryHitData.isTrajectoryHit&&D(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,i);if((r||s)&&this.callCallback(t,"mouse"),o!==t.isHovering||s){var a=e(e({},t),{isHovering:o,trajectoryHitData:e(e({},t.trajectoryHitData),{isTrajectoryHit:s,trajectoryHitTime:s?performance.now():t.trajectoryHitData.trajectoryHitTime})});s&&(a.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(a.trajectoryHitData.trajectoryHitExpirationTimeoutId),a.trajectoryHitData.trajectoryHitExpirationTimeoutId=setTimeout((function(){var e,i=n.elements.get(t.element);i&&i.trajectoryHitData.trajectoryHitTime===a.trajectoryHitData.trajectoryHitTime&&(i.trajectoryHitData.isTrajectoryHit=!1,null===(e=n.debugger)||void 0===e||e.createOrUpdateElementOverlay(i))}),200)),this.elements.set(t.element,a)}},t.prototype.updateHitCounters=function(e,t){"mouse"===t?(e.callbackHits.mouse++,this._globalCallbackHits.mouse++):"tab"===t&&(e.callbackHits.tab++,this._globalCallbackHits.tab++),this._globalCallbackHits.total++},t.prototype.callCallback=function(e,t){e&&(this.updateHitCounters(e,t),e.callback(),this._globalSettings.onAnyCallbackFired(e,this.getManagerData),this.debugger&&(this.debugger.showCallbackAnimation(e),this.debugger.refreshDebuggerElementList()),e.unregisterOnCallback&&this.unregister(e.element))},t.prototype.forceUpdateElementBounds=function(t){var n=t.element.getBoundingClientRect(),i=R(n,t.elementBounds.hitSlop);if(!N(i,t.elementBounds.expandedRect)&&(this.elements.set(t.element,e(e({},t),{elementBounds:e(e({},t.elementBounds),{originalRect:n,expandedRect:i})})),this.debugger)){var o=this.elements.get(t.element);o&&this.debugger.createOrUpdateElementOverlay(o)}},t.prototype.updateElementBounds=function(t,n){var i=R(t,n.elementBounds.hitSlop);if(this.elements.set(n.element,e(e({},n),{elementBounds:e(e({},n.elementBounds),{originalRect:t,expandedRect:i})})),this.debugger){var o=this.elements.get(n.element);o&&this.debugger.createOrUpdateElementOverlay(o)}},t.prototype.initializeGlobalListeners=function(){if(!this.isSetup&&"undefined"!=typeof window&&"undefined"!=typeof document){this.globalListenersController=new AbortController;var e=this.globalListenersController.signal;document.addEventListener("mousemove",this.handleMouseMove,{signal:e}),document.addEventListener("keydown",this.handleKeyDown,{signal:e}),document.addEventListener("focusin",this.handleFocusIn,{signal:e}),this.domObserver=new MutationObserver(this.handleDomMutations),this.domObserver.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1}),this.positionObserver=new q(this.handlePositionChange),this.elementIntersectionObserver=new IntersectionObserver(this.handleIntersection,{root:null,threshold:0,rootMargin:"50px"}),this.isSetup=!0}},t.prototype.removeGlobalListeners=function(){var e,t,n,i;this.isSetup=!1,this.debugger?console.log("%cForesightJS: 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.","color: #28a745; font-weight: bold;"):(null===(e=this.globalListenersController)||void 0===e||e.abort(),this.globalListenersController=null),null===(t=this.domObserver)||void 0===t||t.disconnect(),this.domObserver=null,null===(n=this.elementIntersectionObserver)||void 0===n||n.disconnect(),this.elementIntersectionObserver=null,null===(i=this.positionObserver)||void 0===i||i.disconnect(),this.positionObserver=null},t}();exports.ForesightManager=U;
20
+ if(!s.isIntersecting){if(1===this._cm)return;if(2===this._cm)return void(r&&(this.entries.set(n,s),i.push(s)))}const{left:a,top:l}=s.boundingClientRect;
21
+ /* istanbul ignore else @preserve - only schedule entries that changed position */o.top===l&&o.left===a&&this._w===e&&this._h===t||(this.entries.set(n,s),i.push(s))}))})),this._w=e,this._h=t,n(i)}));this._t=requestAnimationFrame((async()=>{const e=await n;
22
+ /* istanbul ignore else @preserve */e.length&&this._c(e,this),this._rc()}))};_n=e=>new Promise((t=>{new IntersectionObserver((([e],n)=>{n.disconnect(),t(e)}),{threshold:this._th,rootMargin:this._rm}).observe(e)}));getEntry=e=>this.entries.get(e);disconnect=()=>{cancelAnimationFrame(this._t),this.entries.clear(),this._t=0}},U=function(){function t(){var e=this;this.elements=new Map,this.isSetup=!1,this.debugger=null,this._globalCallbackHits={mouse:0,tab:0,total:0},this._globalSettings={debug:false,enableMousePrediction:true,positionHistorySize:8,trajectoryPredictionTime:120,defaultHitSlop:{top:0,left:0,right:0,bottom:0},resizeScrollThrottleDelay:0,debuggerSettings:{isControlPanelDefaultMinimized:C,showNameTags:k},enableTabPrediction:true,tabOffset:2,onAnyCallbackFired:function(e,t){}},this.trajectoryPositions={positions:[],currentPoint:{x:0,y:0},predictedPoint:{x:0,y:0}},this.domObserver=null,this.positionObserver=null,this.lastKeyDown=null,this.globalListenersController=null,this.handleMouseMove=function(t){e.updatePointerState(t),e.elements.forEach((function(t){t.isIntersectingWithViewport&&(t.unregisterOnCallback?e.handleSingleCallbackInteraction(t):e.handleMultiCallbackInteraction(t))})),e.debugger&&e.debugger.updateTrajectoryVisuals(e.trajectoryPositions,e._globalSettings.enableMousePrediction)},this.handleDomMutations=function(t){for(var n=0,i=t;n<i.length;n++){var o=i[n];if("childList"===o.type&&o.removedNodes.length>0)for(var r=0,s=Array.from(e.elements.keys());r<s.length;r++){var a=s[r];a.isConnected||e.unregister(a)}}},this.handleKeyDown=function(t){"Tab"===t.key?e.lastKeyDown=t:e.lastKeyDown=null},this.handleFocusIn=function(t){if(e.lastKeyDown&&e._globalSettings.enableTabPrediction){var n=t.target;if(n instanceof HTMLElement){var i=y(document.documentElement),o=i.findIndex((function(e){return e===n})),r=e.lastKeyDown.shiftKey?-e._globalSettings.tabOffset:e._globalSettings.tabOffset;e.lastKeyDown=null;for(var s=[],a=0;a<i.length;a++){var l=i[a];if((r>0?a>=o&&a<=o+r:a<=o&&a>=o+r)&&e.elements.has(l))for(var c=0;c<r;c++)s.push(i[a+c])}s.forEach((function(t){e.callCallback(e.elements.get(t),"tab")}))}}},this.handlePositionChange=function(t){for(var n,i=0,o=t;i<o.length;i++){var r=o[i],s=e.elements.get(r.target);if(s){var a=s.isIntersectingWithViewport,l=r.isIntersecting;s.isIntersectingWithViewport=l,l?(e.updateElementBounds(r.boundingClientRect,s),B(e.trajectoryPositions.currentPoint,null==s?void 0:s.elementBounds.expandedRect)&&e.callCallback(s,"mouse")):e._globalSettings.debug&&a&&(null===(n=e.debugger)||void 0===n||n.removeElement(r.target))}}}}return t.initialize=function(e){return this.isInitiated||(t.manager=new t),void 0!==e&&t.manager.alterGlobalSettings(e),t.manager},Object.defineProperty(t.prototype,"getManagerData",{get:function(){var e;return{registeredElements:this.elements,globalSettings:this._globalSettings,globalCallbackHits:this._globalCallbackHits,positionObserverElements:null===(e=this.positionObserver)||void 0===e?void 0:e.entries}},enumerable:!1,configurable:!0}),Object.defineProperty(t,"isInitiated",{get:function(){return!!t.manager},enumerable:!1,configurable:!0}),Object.defineProperty(t,"instance",{get:function(){return this.initialize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"registeredElements",{get:function(){return this.elements},enumerable:!1,configurable:!0}),t.prototype.register=function(e){var t,n,i=this,o=e.element,r=e.callback,s=e.hitSlop,a=e.unregisterOnCallback,l=e.name;if(P())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?D(s,this._globalSettings.debug):this._globalSettings.defaultHitSlop,d=o.getBoundingClientRect(),u={element:o,callback:r,callbackHits:{mouse:0,tab:0,total:0},elementBounds:{originalRect:d,expandedRect:N(d,c),hitSlop:c},isHovering:!1,trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0},name:null!==(t=null!=l?l:o.id)&&void 0!==t?t:"",unregisterOnCallback:null==a||a,isIntersectingWithViewport:!0};return this.elements.set(o,u),null===(n=this.positionObserver)||void 0===n||n.observe(o),this.debugger&&this.debugger.createOrUpdateElementOverlay(u),{isTouchDevice:!1,unregister:function(){return i.unregister(o)}}},t.prototype.unregister=function(e){var t;if(this.elements.has(e)){var n=this.elements.get(e);(null==n?void 0:n.trajectoryHitData.trajectoryHitExpirationTimeoutId)&&clearTimeout(n.trajectoryHitData.trajectoryHitExpirationTimeoutId),null===(t=this.positionObserver)||void 0===t||t.unobserve(e),this.elements.delete(e),this.debugger&&this.debugger.removeElement(e),0===this.elements.size&&this.isSetup&&this.removeGlobalListeners()}},t.prototype.updateNumericSettings=function(e,t,n,i){return!!A(e,this._globalSettings[t])&&(this._globalSettings[t]=H(e,n,i,this._globalSettings.debug,t),!0)},t.prototype.updateBooleanSetting=function(e,t){return!!A(e,this._globalSettings[t])&&(this._globalSettings[t]=e,!0)},t.prototype.alterGlobalSettings=function(e){var t,n,i=this._globalSettings.positionHistorySize,o=this.updateNumericSettings(null==e?void 0:e.positionHistorySize,"positionHistorySize",2,30);o&&this._globalSettings.positionHistorySize<i&&this.trajectoryPositions.positions.length>this._globalSettings.positionHistorySize&&(this.trajectoryPositions.positions=this.trajectoryPositions.positions.slice(this.trajectoryPositions.positions.length-this._globalSettings.positionHistorySize));var r=this.updateNumericSettings(null==e?void 0:e.trajectoryPredictionTime,"trajectoryPredictionTime",10,200),s=this.updateNumericSettings(null==e?void 0:e.tabOffset,"tabOffset",0,20);void 0!==(null==e?void 0:e.resizeScrollThrottleDelay)&&console.warn("resizeScrollThrottleDelay is deprecated and will be removed in V3.0.0 of ForesightJS");var a=this.updateBooleanSetting(null==e?void 0:e.enableMousePrediction,"enableMousePrediction"),l=this.updateBooleanSetting(null==e?void 0:e.enableTabPrediction,"enableTabPrediction");void 0!==(null==e?void 0:e.onAnyCallbackFired)&&(this._globalSettings.onAnyCallbackFired=e.onAnyCallbackFired);var c=!1;void 0!==(null===(t=null==e?void 0:e.debuggerSettings)||void 0===t?void 0:t.isControlPanelDefaultMinimized)&&(this._globalSettings.debuggerSettings.isControlPanelDefaultMinimized=e.debuggerSettings.isControlPanelDefaultMinimized,c=!0),void 0!==(null===(n=null==e?void 0:e.debuggerSettings)||void 0===n?void 0:n.showNameTags)&&(this._globalSettings.debuggerSettings.showNameTags=e.debuggerSettings.showNameTags,c=!0,this.debugger&&this.debugger.toggleNameTagVisibility());var d=!1;if(void 0!==(null==e?void 0:e.defaultHitSlop)){var u=D(e.defaultHitSlop,this._globalSettings.debug);R(this._globalSettings.defaultHitSlop,u)||(this._globalSettings.defaultHitSlop=u,d=!0,this.forceUpdateAllElementBounds())}var h=!1;void 0!==(null==e?void 0:e.debug)&&this._globalSettings.debug!==e.debug&&"undefined"!=typeof window&&"undefined"!=typeof document&&(this._globalSettings.debug=e.debug,h=!0,this._globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null)),(o||r||s||a||l||c||d||h)&&this.debugger&&this.debugger.updateControlsState(this._globalSettings)},t.prototype.turnOnDebugMode=function(){var e=this;this.debugger?this.debugger.updateControlsState(this._globalSettings):(this.debugger=O.initialize(t.instance,this.trajectoryPositions),this.elements.forEach((function(t){var n;null===(n=e.debugger)||void 0===n||n.createOrUpdateElementOverlay(t)})))},t.prototype.forceUpdateAllElementBounds=function(){var e=this;this.elements.forEach((function(t,n){var i=e.elements.get(n);i&&i.isIntersectingWithViewport&&e.forceUpdateElementBounds(i)}))},t.prototype.updatePointerState=function(t){this.trajectoryPositions.currentPoint={x:t.clientX,y:t.clientY},this.trajectoryPositions.predictedPoint=this._globalSettings.enableMousePrediction?function(e,t,n,i){var o={point:e,time:performance.now()},r=e.x,s=e.y;if(t.push(o),t.length>n&&t.shift(),t.length<2)return{x:r,y:s};var a=t[0],l=t[t.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):e({},this.trajectoryPositions.currentPoint)},t.prototype.handleSingleCallbackInteraction=function(e){var t=e.elementBounds.expandedRect;this._globalSettings.enableMousePrediction?_(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,t)&&this.callCallback(e,"mouse"):B(this.trajectoryPositions.currentPoint,t)&&this.callCallback(e,"mouse")},t.prototype.handleMultiCallbackInteraction=function(t){var n=this,i=t.elementBounds.expandedRect,o=B(this.trajectoryPositions.currentPoint,i),r=o&&!t.isHovering,s=this._globalSettings.enableMousePrediction&&!o&&!t.trajectoryHitData.isTrajectoryHit&&_(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,i);if((r||s)&&this.callCallback(t,"mouse"),o!==t.isHovering||s){var a=e(e({},t),{isHovering:o,trajectoryHitData:e(e({},t.trajectoryHitData),{isTrajectoryHit:s,trajectoryHitTime:s?performance.now():t.trajectoryHitData.trajectoryHitTime})});s&&(a.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(a.trajectoryHitData.trajectoryHitExpirationTimeoutId),a.trajectoryHitData.trajectoryHitExpirationTimeoutId=setTimeout((function(){var e,i=n.elements.get(t.element);i&&i.trajectoryHitData.trajectoryHitTime===a.trajectoryHitData.trajectoryHitTime&&(i.trajectoryHitData.isTrajectoryHit=!1,null===(e=n.debugger)||void 0===e||e.createOrUpdateElementOverlay(i))}),200)),this.elements.set(t.element,a)}},t.prototype.updateHitCounters=function(e,t){"mouse"===t?(e.callbackHits.mouse++,this._globalCallbackHits.mouse++):"tab"===t&&(e.callbackHits.tab++,this._globalCallbackHits.tab++),this._globalCallbackHits.total++},t.prototype.callCallback=function(e,t){e&&(this.updateHitCounters(e,t),e.callback(),this._globalSettings.onAnyCallbackFired(e,this.getManagerData),this.debugger&&(this.debugger.showCallbackAnimation(e),this.debugger.refreshDebuggerElementList()),e.unregisterOnCallback&&this.unregister(e.element))},t.prototype.forceUpdateElementBounds=function(t){var n=t.element.getBoundingClientRect(),i=N(n,t.elementBounds.hitSlop);if(!R(i,t.elementBounds.expandedRect)&&(this.elements.set(t.element,e(e({},t),{elementBounds:e(e({},t.elementBounds),{originalRect:n,expandedRect:i})})),this.debugger)){var o=this.elements.get(t.element);o&&this.debugger.createOrUpdateElementOverlay(o)}},t.prototype.updateElementBounds=function(t,n){var i=N(t,n.elementBounds.hitSlop);if(this.elements.set(n.element,e(e({},n),{elementBounds:e(e({},n.elementBounds),{originalRect:t,expandedRect:i})})),this.debugger){var o=this.elements.get(n.element);o&&this.debugger.createOrUpdateElementOverlay(o)}},t.prototype.initializeGlobalListeners=function(){if(!this.isSetup&&"undefined"!=typeof window&&"undefined"!=typeof document){this.globalListenersController=new AbortController;var e=this.globalListenersController.signal;document.addEventListener("mousemove",this.handleMouseMove,{signal:e}),document.addEventListener("keydown",this.handleKeyDown,{signal:e}),document.addEventListener("focusin",this.handleFocusIn,{signal:e}),this.domObserver=new MutationObserver(this.handleDomMutations),this.domObserver.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1}),this.positionObserver=new G(this.handlePositionChange,{callbackMode:"update",rootMargin:"20px"}),this.isSetup=!0}},t.prototype.removeGlobalListeners=function(){var e,t,n;this.isSetup=!1,this.debugger?console.log("%cForesightJS: 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.","color: #28a745; font-weight: bold;"):(null===(e=this.globalListenersController)||void 0===e||e.abort(),this.globalListenersController=null),null===(t=this.domObserver)||void 0===t||t.disconnect(),this.domObserver=null,null===(n=this.positionObserver)||void 0===n||n.disconnect(),this.positionObserver=null},t}();exports.ForesightManager=U;
21
23
  //# sourceMappingURL=index.js.map