js.foresight 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../node_modules/.pnpm/@rollup+plugin-typescript@1_25d8bb3f895bd6a0766290a9503c913c/node_modules/tslib/tslib.es6.js","../node_modules/.pnpm/tabbable@6.2.0/node_modules/tabbable/dist/index.esm.js","../src/Manager/constants.ts","../src/Debugger/helpers/objectToMethodCall.ts","../src/Debugger/helpers/createAndAppend.ts","../src/Debugger/helpers/getIntersectingIcon.ts","../src/Debugger/DebuggerControlPanel.ts","../src/Debugger/helpers/updateElementOverlays.ts","../node_modules/.pnpm/position-observer@1.0.0/node_modules/position-observer/dist/index.js","../src/helpers/shouldRegister.ts","../src/Debugger/ForesightDebugger.ts","../src/Debugger/helpers/removeOldDebuggers.ts","../src/Manager/helpers/clampNumber.ts","../src/Manager/helpers/lineSigmentIntersectsRect.ts","../src/Manager/helpers/rectAndHitSlop.ts","../src/Manager/helpers/shouldUpdateSetting.ts","../src/Manager/ForesightManager.ts","../src/Manager/helpers/getFocusedElementIndex.ts","../src/Manager/helpers/predictNextMousePosition.ts","../src/Manager/helpers/getScrollDirection.ts","../src/Manager/helpers/predictNextScrollPosition.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nvar ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","/*!\n* tabbable 6.2.0\n* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE\n*/\n// NOTE: separate `:not()` selectors has broader browser support than the newer\n// `:not([inert], [inert] *)` (Feb 2023)\n// CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes\n// the entire query to fail, resulting in no nodes found, which will break a lot\n// of things... so we have to rely on JS to identify nodes inside an inert container\nvar candidateSelectors = ['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])'];\nvar candidateSelector = /* #__PURE__ */candidateSelectors.join(',');\nvar NoElement = typeof Element === 'undefined';\nvar matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;\nvar getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {\n var _element$getRootNode;\n return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);\n} : function (element) {\n return element === null || element === void 0 ? void 0 : element.ownerDocument;\n};\n\n/**\n * Determines if a node is inert or in an inert ancestor.\n * @param {Element} [node]\n * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to\n * see if any of them are inert. If false, only `node` itself is considered.\n * @returns {boolean} True if inert itself or by way of being in an inert ancestor.\n * False if `node` is falsy.\n */\nvar isInert = function isInert(node, lookUp) {\n var _node$getAttribute;\n if (lookUp === void 0) {\n lookUp = true;\n }\n // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`\n // JS API property; we have to check the attribute, which can either be empty or 'true';\n // if it's `null` (not specified) or 'false', it's an active element\n var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, 'inert');\n var inert = inertAtt === '' || inertAtt === 'true';\n\n // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`\n // if it weren't for `matches()` not being a function on shadow roots; the following\n // code works for any kind of node\n // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`\n // so it likely would not support `:is([inert] *)` either...\n var result = inert || lookUp && node && isInert(node.parentNode); // recursive\n\n return result;\n};\n\n/**\n * Determines if a node's content is editable.\n * @param {Element} [node]\n * @returns True if it's content-editable; false if it's not or `node` is falsy.\n */\nvar isContentEditable = function isContentEditable(node) {\n var _node$getAttribute2;\n // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have\n // to use the attribute directly to check for this, which can either be empty or 'true';\n // if it's `null` (not specified) or 'false', it's a non-editable element\n var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, 'contenteditable');\n return attValue === '' || attValue === 'true';\n};\n\n/**\n * @param {Element} el container to check in\n * @param {boolean} includeContainer add container to check\n * @param {(node: Element) => boolean} filter filter candidates\n * @returns {Element[]}\n */\nvar getCandidates = function getCandidates(el, includeContainer, filter) {\n // even if `includeContainer=false`, we still have to check it for inertness because\n // if it's inert, all its children are inert\n if (isInert(el)) {\n return [];\n }\n var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));\n if (includeContainer && matches.call(el, candidateSelector)) {\n candidates.unshift(el);\n }\n candidates = candidates.filter(filter);\n return candidates;\n};\n\n/**\n * @callback GetShadowRoot\n * @param {Element} element to check for shadow root\n * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.\n */\n\n/**\n * @callback ShadowRootFilter\n * @param {Element} shadowHostNode the element which contains shadow content\n * @returns {boolean} true if a shadow root could potentially contain valid candidates.\n */\n\n/**\n * @typedef {Object} CandidateScope\n * @property {Element} scopeParent contains inner candidates\n * @property {Element[]} candidates list of candidates found in the scope parent\n */\n\n/**\n * @typedef {Object} IterativeOptions\n * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;\n * if a function, implies shadow support is enabled and either returns the shadow root of an element\n * or a boolean stating if it has an undisclosed shadow root\n * @property {(node: Element) => boolean} filter filter candidates\n * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list\n * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;\n */\n\n/**\n * @param {Element[]} elements list of element containers to match candidates from\n * @param {boolean} includeContainer add container list to check\n * @param {IterativeOptions} options\n * @returns {Array.<Element|CandidateScope>}\n */\nvar getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {\n var candidates = [];\n var elementsToCheck = Array.from(elements);\n while (elementsToCheck.length) {\n var element = elementsToCheck.shift();\n if (isInert(element, false)) {\n // no need to look up since we're drilling down\n // anything inside this container will also be inert\n continue;\n }\n if (element.tagName === 'SLOT') {\n // add shadow dom slot scope (slot itself cannot be focusable)\n var assigned = element.assignedElements();\n var content = assigned.length ? assigned : element.children;\n var nestedCandidates = getCandidatesIteratively(content, true, options);\n if (options.flatten) {\n candidates.push.apply(candidates, nestedCandidates);\n } else {\n candidates.push({\n scopeParent: element,\n candidates: nestedCandidates\n });\n }\n } else {\n // check candidate element\n var validCandidate = matches.call(element, candidateSelector);\n if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {\n candidates.push(element);\n }\n\n // iterate over shadow content if possible\n var shadowRoot = element.shadowRoot ||\n // check for an undisclosed shadow\n typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);\n\n // no inert look up because we're already drilling down and checking for inertness\n // on the way down, so all containers to this root node should have already been\n // vetted as non-inert\n var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));\n if (shadowRoot && validShadowRoot) {\n // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed\n // shadow exists, so look at light dom children as fallback BUT create a scope for any\n // child candidates found because they're likely slotted elements (elements that are\n // children of the web component element (which has the shadow), in the light dom, but\n // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,\n // _after_ we return from this recursive call\n var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);\n if (options.flatten) {\n candidates.push.apply(candidates, _nestedCandidates);\n } else {\n candidates.push({\n scopeParent: element,\n candidates: _nestedCandidates\n });\n }\n } else {\n // there's not shadow so just dig into the element's (light dom) children\n // __without__ giving the element special scope treatment\n elementsToCheck.unshift.apply(elementsToCheck, element.children);\n }\n }\n }\n return candidates;\n};\n\n/**\n * @private\n * Determines if the node has an explicitly specified `tabindex` attribute.\n * @param {HTMLElement} node\n * @returns {boolean} True if so; false if not.\n */\nvar hasTabIndex = function hasTabIndex(node) {\n return !isNaN(parseInt(node.getAttribute('tabindex'), 10));\n};\n\n/**\n * Determine the tab index of a given node.\n * @param {HTMLElement} node\n * @returns {number} Tab order (negative, 0, or positive number).\n * @throws {Error} If `node` is falsy.\n */\nvar getTabIndex = function getTabIndex(node) {\n if (!node) {\n throw new Error('No node provided');\n }\n if (node.tabIndex < 0) {\n // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default\n // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,\n // yet they are still part of the regular tab order; in FF, they get a default\n // `tabIndex` of 0; since Chrome still puts those elements in the regular tab\n // order, consider their tab index to be 0.\n // Also browsers do not return `tabIndex` correctly for contentEditable nodes;\n // so if they don't have a tabindex attribute specifically set, assume it's 0.\n if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {\n return 0;\n }\n }\n return node.tabIndex;\n};\n\n/**\n * Determine the tab index of a given node __for sort order purposes__.\n * @param {HTMLElement} node\n * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,\n * has tabIndex -1, but needs to be sorted by document order in order for its content to be\n * inserted into the correct sort position.\n * @returns {number} Tab order (negative, 0, or positive number).\n */\nvar getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {\n var tabIndex = getTabIndex(node);\n if (tabIndex < 0 && isScope && !hasTabIndex(node)) {\n return 0;\n }\n return tabIndex;\n};\nvar sortOrderedTabbables = function sortOrderedTabbables(a, b) {\n return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;\n};\nvar isInput = function isInput(node) {\n return node.tagName === 'INPUT';\n};\nvar isHiddenInput = function isHiddenInput(node) {\n return isInput(node) && node.type === 'hidden';\n};\nvar isDetailsWithSummary = function isDetailsWithSummary(node) {\n var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {\n return child.tagName === 'SUMMARY';\n });\n return r;\n};\nvar getCheckedRadio = function getCheckedRadio(nodes, form) {\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i].checked && nodes[i].form === form) {\n return nodes[i];\n }\n }\n};\nvar isTabbableRadio = function isTabbableRadio(node) {\n if (!node.name) {\n return true;\n }\n var radioScope = node.form || getRootNode(node);\n var queryRadios = function queryRadios(name) {\n return radioScope.querySelectorAll('input[type=\"radio\"][name=\"' + name + '\"]');\n };\n var radioSet;\n if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {\n radioSet = queryRadios(window.CSS.escape(node.name));\n } else {\n try {\n radioSet = queryRadios(node.name);\n } catch (err) {\n // eslint-disable-next-line no-console\n 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', err.message);\n return false;\n }\n }\n var checked = getCheckedRadio(radioSet, node.form);\n return !checked || checked === node;\n};\nvar isRadio = function isRadio(node) {\n return isInput(node) && node.type === 'radio';\n};\nvar isNonTabbableRadio = function isNonTabbableRadio(node) {\n return isRadio(node) && !isTabbableRadio(node);\n};\n\n// determines if a node is ultimately attached to the window's document\nvar isNodeAttached = function isNodeAttached(node) {\n var _nodeRoot;\n // The root node is the shadow root if the node is in a shadow DOM; some document otherwise\n // (but NOT _the_ document; see second 'If' comment below for more).\n // If rootNode is shadow root, it'll have a host, which is the element to which the shadow\n // is attached, and the one we need to check if it's in the document or not (because the\n // shadow, and all nodes it contains, is never considered in the document since shadows\n // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,\n // is hidden, or is not in the document itself but is detached, it will affect the shadow's\n // visibility, including all the nodes it contains). The host could be any normal node,\n // or a custom element (i.e. web component). Either way, that's the one that is considered\n // part of the document, not the shadow root, nor any of its children (i.e. the node being\n // tested).\n // To further complicate things, we have to look all the way up until we find a shadow HOST\n // that is attached (or find none) because the node might be in nested shadows...\n // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the\n // document (per the docs) and while it's a Document-type object, that document does not\n // appear to be the same as the node's `ownerDocument` for some reason, so it's safer\n // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,\n // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when\n // node is actually detached.\n // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible\n // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed\n // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then\n // `ownerDocument` will be `null`, hence the optional chaining on it.\n var nodeRoot = node && getRootNode(node);\n var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;\n\n // in some cases, a detached node will return itself as the root instead of a document or\n // shadow root object, in which case, we shouldn't try to look further up the host chain\n var attached = false;\n if (nodeRoot && nodeRoot !== node) {\n var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;\n attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));\n while (!attached && nodeRootHost) {\n var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;\n // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,\n // which means we need to get the host's host and check if that parent host is contained\n // in (i.e. attached to) the document\n nodeRoot = getRootNode(nodeRootHost);\n nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;\n attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));\n }\n }\n return attached;\n};\nvar isZeroArea = function isZeroArea(node) {\n var _node$getBoundingClie = node.getBoundingClientRect(),\n width = _node$getBoundingClie.width,\n height = _node$getBoundingClie.height;\n return width === 0 && height === 0;\n};\nvar isHidden = function isHidden(node, _ref) {\n var displayCheck = _ref.displayCheck,\n getShadowRoot = _ref.getShadowRoot;\n // NOTE: visibility will be `undefined` if node is detached from the document\n // (see notes about this further down), which means we will consider it visible\n // (this is legacy behavior from a very long way back)\n // NOTE: we check this regardless of `displayCheck=\"none\"` because this is a\n // _visibility_ check, not a _display_ check\n if (getComputedStyle(node).visibility === 'hidden') {\n return true;\n }\n var isDirectSummary = matches.call(node, 'details>summary:first-of-type');\n var nodeUnderDetails = isDirectSummary ? node.parentElement : node;\n if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {\n return true;\n }\n if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {\n if (typeof getShadowRoot === 'function') {\n // figure out if we should consider the node to be in an undisclosed shadow and use the\n // 'non-zero-area' fallback\n var originalNode = node;\n while (node) {\n var parentElement = node.parentElement;\n var rootNode = getRootNode(node);\n if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow\n ) {\n // node has an undisclosed shadow which means we can only treat it as a black box, so we\n // fall back to a non-zero-area test\n return isZeroArea(node);\n } else if (node.assignedSlot) {\n // iterate up slot\n node = node.assignedSlot;\n } else if (!parentElement && rootNode !== node.ownerDocument) {\n // cross shadow boundary\n node = rootNode.host;\n } else {\n // iterate up normal dom\n node = parentElement;\n }\n }\n node = originalNode;\n }\n // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support\n // (i.e. it does not also presume that all nodes might have undisclosed shadows); or\n // it might be a falsy value, which means shadow DOM support is disabled\n\n // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)\n // now we can just test to see if it would normally be visible or not, provided it's\n // attached to the main document.\n // NOTE: We must consider case where node is inside a shadow DOM and given directly to\n // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.\n\n if (isNodeAttached(node)) {\n // this works wherever the node is: if there's at least one client rect, it's\n // somehow displayed; it also covers the CSS 'display: contents' case where the\n // node itself is hidden in place of its contents; and there's no need to search\n // up the hierarchy either\n return !node.getClientRects().length;\n }\n\n // Else, the node isn't attached to the document, which means the `getClientRects()`\n // API will __always__ return zero rects (this can happen, for example, if React\n // is used to render nodes onto a detached tree, as confirmed in this thread:\n // https://github.com/facebook/react/issues/9117#issuecomment-284228870)\n //\n // It also means that even window.getComputedStyle(node).display will return `undefined`\n // because styles are only computed for nodes that are in the document.\n //\n // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable\n // somehow. Though it was never stated officially, anyone who has ever used tabbable\n // APIs on nodes in detached containers has actually implicitly used tabbable in what\n // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck=\"none\"` mode -- essentially\n // considering __everything__ to be visible because of the innability to determine styles.\n //\n // v6.0.0: As of this major release, the default 'full' option __no longer treats detached\n // nodes as visible with the 'none' fallback.__\n if (displayCheck !== 'legacy-full') {\n return true; // hidden\n }\n // else, fallback to 'none' mode and consider the node visible\n } else if (displayCheck === 'non-zero-area') {\n // NOTE: Even though this tests that the node's client rect is non-zero to determine\n // whether it's displayed, and that a detached node will __always__ have a zero-area\n // client rect, we don't special-case for whether the node is attached or not. In\n // this mode, we do want to consider nodes that have a zero area to be hidden at all\n // times, and that includes attached or not.\n return isZeroArea(node);\n }\n\n // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume\n // it's visible\n return false;\n};\n\n// form fields (nested) inside a disabled fieldset are not focusable/tabbable\n// unless they are in the _first_ <legend> element of the top-most disabled\n// fieldset\nvar isDisabledFromFieldset = function isDisabledFromFieldset(node) {\n if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {\n var parentNode = node.parentElement;\n // check if `node` is contained in a disabled <fieldset>\n while (parentNode) {\n if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {\n // look for the first <legend> among the children of the disabled <fieldset>\n for (var i = 0; i < parentNode.children.length; i++) {\n var child = parentNode.children.item(i);\n // when the first <legend> (in document order) is found\n if (child.tagName === 'LEGEND') {\n // if its parent <fieldset> is not nested in another disabled <fieldset>,\n // return whether `node` is a descendant of its first <legend>\n return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);\n }\n }\n // the disabled <fieldset> containing `node` has no <legend>\n return true;\n }\n parentNode = parentNode.parentElement;\n }\n }\n\n // else, node's tabbable/focusable state should not be affected by a fieldset's\n // enabled/disabled state\n return false;\n};\nvar isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {\n if (node.disabled ||\n // we must do an inert look up to filter out any elements inside an inert ancestor\n // because we're limited in the type of selectors we can use in JSDom (see related\n // note related to `candidateSelectors`)\n isInert(node) || isHiddenInput(node) || isHidden(node, options) ||\n // For a details element with a summary, the summary element gets the focus\n isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {\n return false;\n }\n return true;\n};\nvar isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {\n if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {\n return false;\n }\n return true;\n};\nvar isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {\n var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);\n if (isNaN(tabIndex) || tabIndex >= 0) {\n return true;\n }\n // If a custom element has an explicit negative tabindex,\n // browsers will not allow tab targeting said element's children.\n return false;\n};\n\n/**\n * @param {Array.<Element|CandidateScope>} candidates\n * @returns Element[]\n */\nvar sortByOrder = function sortByOrder(candidates) {\n var regularTabbables = [];\n var orderedTabbables = [];\n candidates.forEach(function (item, i) {\n var isScope = !!item.scopeParent;\n var element = isScope ? item.scopeParent : item;\n var candidateTabindex = getSortOrderTabIndex(element, isScope);\n var elements = isScope ? sortByOrder(item.candidates) : element;\n if (candidateTabindex === 0) {\n isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);\n } else {\n orderedTabbables.push({\n documentOrder: i,\n tabIndex: candidateTabindex,\n item: item,\n isScope: isScope,\n content: elements\n });\n }\n });\n return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {\n sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);\n return acc;\n }, []).concat(regularTabbables);\n};\nvar tabbable = function tabbable(container, options) {\n options = options || {};\n var candidates;\n if (options.getShadowRoot) {\n candidates = getCandidatesIteratively([container], options.includeContainer, {\n filter: isNodeMatchingSelectorTabbable.bind(null, options),\n flatten: false,\n getShadowRoot: options.getShadowRoot,\n shadowRootFilter: isValidShadowRootTabbable\n });\n } else {\n candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));\n }\n return sortByOrder(candidates);\n};\nvar focusable = function focusable(container, options) {\n options = options || {};\n var candidates;\n if (options.getShadowRoot) {\n candidates = getCandidatesIteratively([container], options.includeContainer, {\n filter: isNodeMatchingSelectorFocusable.bind(null, options),\n flatten: true,\n getShadowRoot: options.getShadowRoot\n });\n } else {\n candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));\n }\n return candidates;\n};\nvar isTabbable = function isTabbable(node, options) {\n options = options || {};\n if (!node) {\n throw new Error('No node provided');\n }\n if (matches.call(node, candidateSelector) === false) {\n return false;\n }\n return isNodeMatchingSelectorTabbable(options, node);\n};\nvar focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');\nvar isFocusable = function isFocusable(node, options) {\n options = options || {};\n if (!node) {\n throw new Error('No node provided');\n }\n if (matches.call(node, focusableCandidateSelector) === false) {\n return false;\n }\n return isNodeMatchingSelectorFocusable(options, node);\n};\n\nexport { focusable, getTabIndex, isFocusable, isTabbable, tabbable };\n//# sourceMappingURL=index.esm.js.map\n","import type { SortElementList } from \"../types/types\"\r\n\r\n//IMPORTANT: when altering these values change the type jsDocs/actual docs for BaseForesightManagerProps\r\nexport const MIN_TRAJECTORY_PREDICTION_TIME: number = 10\r\nexport const MAX_TRAJECTORY_PREDICTION_TIME: number = 200\r\nexport const DEFAULT_TRAJECTORY_PREDICTION_TIME: number = 120\r\nexport const TRAJECTORY_PREDICTION_TIME_UNIT: string = \"ms\"\r\n\r\nexport const MIN_POSITION_HISTORY_SIZE: number = 2\r\nexport const MAX_POSITION_HISTORY_SIZE: number = 30\r\nexport const DEFAULT_POSITION_HISTORY_SIZE: number = 8\r\nexport const POSITION_HISTORY_SIZE_UNIT: string = \"points\"\r\n\r\nexport const MIN_TAB_OFFSET: number = 0\r\nexport const MAX_TAB_OFFSET: number = 20\r\nexport const DEFAULT_TAB_OFFSET: number = 2\r\nexport const TAB_OFFSET_UNIT: string = \"tabs\"\r\n\r\nexport const MIN_HITSLOP: number = 0\r\nexport const MAX_HITSLOP: number = 2000\r\nexport const DEFAULT_HITSLOP: number = 0\r\n\r\nexport const DEFAULT_SCROLL_MARGIN: number = 150\r\nexport const MIN_SCROLL_MARGIN: number = 30\r\nexport const MAX_SCROLL_MARGIN: number = 300\r\nexport const SCROLL_MARGIN_UNIT: string = \"px\"\r\n\r\nexport const DEFAULT_ENABLE_TAB_PREDICTION: boolean = true\r\nexport const DEFAULT_ENABLE_MOUSE_PREDICTION: boolean = true\r\nexport const DEFAULT_ENABLE_SCROLL_PREDICTION: boolean = true\r\nexport const DEFAULT_IS_DEBUGGER_MINIMIZED: boolean = false\r\nexport const DEFAULT_SHOW_NAME_TAGS: boolean = true\r\nexport const DEFAULT_IS_DEBUG: boolean = false\r\nexport const DEFAULT_SORT_ELEMENT_LIST: SortElementList = \"visibility\"\r\n","/**\r\n * Converts a JavaScript object into a readable method call string format.\r\n *\r\n * This utility is designed for copying object configurations and transforming them\r\n * into method call syntax for easy copy-pasting of global settings or configurations.\r\n *\r\n * @template T - The type of the input object, constrained to Record<string, any>\r\n * @param obj - The object to convert to method call format\r\n * @param methodName - The name of the method to wrap the object in (e.g., 'ForesightManager.initialize')\r\n * @returns A formatted string representing the object as a method call with proper indentation\r\n *\r\n * @example\r\n * ```typescript\r\n * const config = {\r\n * debug: true,\r\n * settings: { enabled: false }\r\n * };\r\n *\r\n * const result = objectToMethodCall(config, 'MyClass.configure');\r\n * // Returns:\r\n * // MyClass.configure({\r\n * // debug: true,\r\n * // settings: {\r\n * // enabled: false\r\n * // }\r\n * // })\r\n * ```\r\n */\r\nexport function objectToMethodCall<T extends Record<string, any>>(\r\n obj: T,\r\n methodName: string\r\n): string {\r\n const entries = Object.entries(obj) as Array<[keyof T, T[keyof T]]>\r\n\r\n // Filter out deprecated keys\r\n const filteredEntries = entries.filter(([key]) => {\r\n const keyStr = String(key)\r\n if (keyStr === \"resizeScrollThrottleDelay\") {\r\n return false\r\n }\r\n return true\r\n })\r\n\r\n const formattedEntries = filteredEntries\r\n .map(([key, value]) => ` ${String(key)}: ${formatValue(value)}`)\r\n .join(\",\\n\")\r\n\r\n return `${methodName}({\\n${formattedEntries}\\n})`\r\n}\r\n\r\n/**\r\n * Formats a value with proper indentation and type-appropriate string representation.\r\n *\r\n * @param value - The value to format (can be any type)\r\n * @param indent - The current indentation level (defaults to 2 spaces)\r\n * @returns A formatted string representation of the value\r\n */\r\nconst formatValue = (value: unknown, indent: number = 2): string => {\r\n const spaces = \" \".repeat(indent)\r\n\r\n if (typeof value === \"object\" && value !== null && !Array.isArray(value)) {\r\n const entries = Object.entries(value as Record<string, unknown>)\r\n if (entries.length === 0) return \"{}\"\r\n\r\n const formattedEntries = entries\r\n .map(([key, val]) => `${spaces} ${key}: ${formatValue(val, indent + 2)}`)\r\n .join(\",\\n\")\r\n\r\n return `{\\n${formattedEntries}\\n${spaces}}`\r\n }\r\n\r\n if (typeof value === \"string\") return `'${value}'`\r\n if (typeof value === \"boolean\" || typeof value === \"number\") return String(value)\r\n if (value === null) return \"null\"\r\n if (value === undefined) return \"undefined\"\r\n if (Array.isArray(value)) return JSON.stringify(value)\r\n\r\n return String(value)\r\n}\r\n","type attributes = {\r\n className?: string\r\n data?: string\r\n id?: string\r\n}\r\n\r\nexport function createAndAppendElement(\r\n tag: string,\r\n parent: Node,\r\n attributes: attributes\r\n): HTMLElement {\r\n const element = document.createElement(tag)\r\n if (attributes.id) element.id = attributes.id\r\n if (attributes.className) element.className = attributes.className\r\n if (attributes.data) element.setAttribute(\"data-value\", attributes.data)\r\n return parent.appendChild(element)\r\n}\r\n\r\nexport function createAndAppendStyle(\r\n styleSheet: string,\r\n parent: Node,\r\n id: string\r\n): HTMLStyleElement {\r\n const element = document.createElement(\"style\")\r\n element.textContent = styleSheet\r\n element.id = id\r\n return parent.appendChild(element)\r\n}\r\n","export const getIntersectingIcon = (isIntersectingWithViewport: boolean): string =>\r\n isIntersectingWithViewport ? \"👁️\" : \"🚫\"\r\n","// DebuggerControlPanel.ts\r\nimport type { ForesightManager } from \"../Manager/ForesightManager\"\r\nimport type {\r\n ForesightElementData,\r\n ForesightElement,\r\n DebuggerSettings,\r\n NumericSettingKeys,\r\n BooleanSettingKeys,\r\n ForesightManagerSettings,\r\n SortElementList,\r\n} from \"../types/types\"\r\nimport {\r\n DEFAULT_IS_DEBUGGER_MINIMIZED,\r\n DEFAULT_SHOW_NAME_TAGS,\r\n MAX_POSITION_HISTORY_SIZE,\r\n MAX_SCROLL_MARGIN,\r\n MAX_TAB_OFFSET,\r\n MAX_TRAJECTORY_PREDICTION_TIME,\r\n MIN_POSITION_HISTORY_SIZE,\r\n MIN_SCROLL_MARGIN,\r\n MIN_TAB_OFFSET,\r\n MIN_TRAJECTORY_PREDICTION_TIME,\r\n POSITION_HISTORY_SIZE_UNIT,\r\n SCROLL_MARGIN_UNIT,\r\n TAB_OFFSET_UNIT,\r\n TRAJECTORY_PREDICTION_TIME_UNIT,\r\n} from \"../Manager/constants\"\r\nimport { objectToMethodCall } from \"./helpers/objectToMethodCall\"\r\nimport { createAndAppendStyle } from \"./helpers/createAndAppend\"\r\nimport { getIntersectingIcon } from \"./helpers/getIntersectingIcon\"\r\n\r\ntype SectionStates = {\r\n mouse: boolean\r\n keyboard: boolean\r\n scroll: boolean\r\n general: boolean\r\n}\r\n\r\nconst COPY_SVG_ICON = `<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>`\r\nconst TICK_SVG_ICON = `<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>`\r\nconst SORT_SVG_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polygon points=\"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3\"></polygon></svg>`\r\nconst NO_ELEMENTS_STRING = \"<em>No elements registered.</em>\"\r\n\r\nexport class DebuggerControlPanel {\r\n private foresightManagerInstance: ForesightManager\r\n private static debuggerControlPanelInstance: DebuggerControlPanel\r\n\r\n // These properties will be assigned in _setupDOMAndListeners\r\n private shadowRoot!: ShadowRoot\r\n private controlsContainer!: HTMLElement\r\n private controlPanelStyleElement!: HTMLStyleElement\r\n private elementListItemsContainer: HTMLElement | null = null\r\n private elementCountSpan: HTMLSpanElement | null = null\r\n private callbackCountSpan: HTMLSpanElement | null = null\r\n private elementListItems: Map<ForesightElement, HTMLElement> = new Map()\r\n\r\n private trajectoryEnabledCheckbox: HTMLInputElement | null = null\r\n private tabEnabledCheckbox: HTMLInputElement | null = null\r\n private scrollEnabledCheckbox: HTMLInputElement | null = null\r\n private historySizeSlider: HTMLInputElement | null = null\r\n private historyValueSpan: HTMLSpanElement | null = null\r\n private predictionTimeSlider: HTMLInputElement | null = null\r\n private predictionValueSpan: HTMLSpanElement | null = null\r\n private tabOffsetSlider: HTMLInputElement | null = null\r\n private tabOffsetValueSpan: HTMLSpanElement | null = null\r\n private scrollMarginSlider: HTMLInputElement | null = null\r\n private scrollMarginValueSpan: HTMLSpanElement | null = null\r\n private showNameTagsCheckbox: HTMLInputElement | null = null\r\n private sortOptionsPopup: HTMLDivElement | null = null\r\n private sortButton: HTMLButtonElement | null = null\r\n\r\n private containerMinimizeButton: HTMLButtonElement | null = null\r\n private allSettingsSectionsContainer: HTMLElement | null = null\r\n private debuggerElementsSection: HTMLElement | null = null\r\n private isContainerMinimized: boolean = false\r\n\r\n private isMouseSettingsMinimized: boolean = true\r\n private isKeyboardSettingsMinimized: boolean = true\r\n private isScrollSettingsMinimized: boolean = true\r\n private isGeneralSettingsMinimized: boolean = true\r\n private readonly SESSION_STORAGE_KEY = \"jsforesightDebuggerSectionStates\"\r\n\r\n private copySettingsButton: HTMLButtonElement | null = null\r\n private copyTimeoutId: ReturnType<typeof setTimeout> | null = null\r\n private closeSortDropdownHandler: ((e: MouseEvent) => void) | null = null\r\n\r\n /**\r\n * The constructor is now minimal, only storing the manager instance.\r\n * The actual setup is deferred to _setupDOMAndListeners.\r\n */\r\n private constructor(foresightManager: ForesightManager) {\r\n this.foresightManagerInstance = foresightManager\r\n }\r\n\r\n /**\r\n * All DOM creation and event listener setup logic is moved here.\r\n * This method can be called to \"revive\" a cleaned-up instance.\r\n */\r\n private _setupDOMAndListeners(shadowRoot: ShadowRoot, debuggerSettings: DebuggerSettings) {\r\n // Guard clause to prevent re-running if the UI is already active.\r\n if (this.controlsContainer) {\r\n return\r\n }\r\n\r\n this.shadowRoot = shadowRoot\r\n this.isContainerMinimized =\r\n debuggerSettings.isControlPanelDefaultMinimized ?? DEFAULT_IS_DEBUGGER_MINIMIZED\r\n this.controlsContainer = this.createControlContainer()\r\n this.shadowRoot.appendChild(this.controlsContainer)\r\n\r\n this.controlPanelStyleElement = createAndAppendStyle(\r\n this.getStyles(),\r\n this.shadowRoot,\r\n \"debug-control-panel\"\r\n )\r\n this.queryDOMElements()\r\n this.originalSectionStates()\r\n this.setupEventListeners()\r\n this.updateContainerVisibilityState()\r\n }\r\n\r\n /**\r\n * The initialize method now creates the instance if needed,\r\n * then calls the setup method to ensure the UI is ready.\r\n */\r\n public static initialize(\r\n foresightManager: ForesightManager,\r\n shadowRoot: ShadowRoot,\r\n debuggerSettings: DebuggerSettings\r\n ): DebuggerControlPanel {\r\n if (!DebuggerControlPanel.isInitiated) {\r\n DebuggerControlPanel.debuggerControlPanelInstance = new DebuggerControlPanel(foresightManager)\r\n }\r\n\r\n const instance = DebuggerControlPanel.debuggerControlPanelInstance\r\n\r\n // This will build the DOM on first run or rebuild it on subsequent runs after cleanup.\r\n instance._setupDOMAndListeners(shadowRoot, debuggerSettings)\r\n\r\n return instance\r\n }\r\n\r\n private static get isInitiated(): boolean {\r\n return !!DebuggerControlPanel.debuggerControlPanelInstance\r\n }\r\n\r\n private loadSectionStatesFromSessionStorage(): Partial<SectionStates> {\r\n const storedStatesRaw = sessionStorage.getItem(this.SESSION_STORAGE_KEY)\r\n let loadedStates: Partial<SectionStates> = {}\r\n\r\n if (storedStatesRaw) {\r\n loadedStates = JSON.parse(storedStatesRaw)\r\n }\r\n\r\n this.isMouseSettingsMinimized = loadedStates.mouse ?? true\r\n this.isKeyboardSettingsMinimized = loadedStates.keyboard ?? true\r\n this.isScrollSettingsMinimized = loadedStates.scroll ?? true\r\n this.isGeneralSettingsMinimized = loadedStates.general ?? true\r\n return loadedStates\r\n }\r\n\r\n private saveSectionStatesToSessionStorage() {\r\n const states: SectionStates = {\r\n mouse: this.isMouseSettingsMinimized,\r\n keyboard: this.isKeyboardSettingsMinimized,\r\n scroll: this.isScrollSettingsMinimized,\r\n general: this.isGeneralSettingsMinimized,\r\n }\r\n try {\r\n sessionStorage.setItem(this.SESSION_STORAGE_KEY, JSON.stringify(states))\r\n } catch (e) {\r\n console.error(\"Foresight Debugger: Could not save section states to session storage.\", e)\r\n }\r\n }\r\n\r\n private queryDOMElements() {\r\n this.trajectoryEnabledCheckbox = this.controlsContainer.querySelector(\"#trajectory-enabled\")\r\n this.tabEnabledCheckbox = this.controlsContainer.querySelector(\"#tab-enabled\")\r\n this.scrollEnabledCheckbox = this.controlsContainer.querySelector(\"#scroll-enabled\")\r\n this.historySizeSlider = this.controlsContainer.querySelector(\"#history-size\")\r\n this.historyValueSpan = this.controlsContainer.querySelector(\"#history-value\")\r\n this.predictionTimeSlider = this.controlsContainer.querySelector(\"#prediction-time\")\r\n this.predictionValueSpan = this.controlsContainer.querySelector(\"#prediction-value\")\r\n this.tabOffsetSlider = this.controlsContainer.querySelector(\"#tab-offset\")\r\n this.tabOffsetValueSpan = this.controlsContainer.querySelector(\"#tab-offset-value\")\r\n this.scrollMarginSlider = this.controlsContainer.querySelector(\"#scroll-margin\")\r\n this.scrollMarginValueSpan = this.controlsContainer.querySelector(\"#scroll-margin-value\")\r\n this.elementListItemsContainer = this.controlsContainer.querySelector(\r\n \"#element-list-items-container\"\r\n )\r\n this.showNameTagsCheckbox = this.controlsContainer.querySelector(\"#toggle-name-tags\")\r\n this.sortOptionsPopup = this.controlsContainer.querySelector(\"#sort-options-popup\")\r\n this.sortButton = this.controlsContainer.querySelector(\".sort-button\")\r\n this.elementCountSpan = this.controlsContainer.querySelector(\"#element-count\")\r\n this.callbackCountSpan = this.controlsContainer.querySelector(\"#callback-count\")\r\n this.containerMinimizeButton = this.controlsContainer.querySelector(\".minimize-button\")\r\n this.allSettingsSectionsContainer = this.controlsContainer.querySelector(\r\n \".all-settings-sections-container\"\r\n )\r\n this.debuggerElementsSection = this.controlsContainer.querySelector(\".debugger-elements\")\r\n this.copySettingsButton = this.controlsContainer.querySelector(\".copy-settings-button\")\r\n }\r\n\r\n private handleCopySettings() {\r\n if (!this.copySettingsButton) return\r\n navigator.clipboard\r\n .writeText(\r\n objectToMethodCall(\r\n this.foresightManagerInstance.getManagerData.globalSettings,\r\n \"ForesightManager.initialize\"\r\n )\r\n )\r\n .then(() => {\r\n this.copySettingsButton!.innerHTML = TICK_SVG_ICON\r\n if (this.copyTimeoutId) {\r\n clearTimeout(this.copyTimeoutId)\r\n }\r\n this.copyTimeoutId = setTimeout(() => {\r\n if (this.copySettingsButton) {\r\n this.copySettingsButton.innerHTML = COPY_SVG_ICON\r\n }\r\n this.copyTimeoutId = null\r\n }, 3000)\r\n })\r\n .catch((err) => {\r\n console.error(\"Foresight Debugger: Could not copy settings to clipboard\", err)\r\n })\r\n }\r\n\r\n private createInputEventListener(\r\n element: HTMLInputElement | null,\r\n spanElement: HTMLSpanElement | null,\r\n unit: string,\r\n setting: NumericSettingKeys\r\n ) {\r\n if (!element || !spanElement) {\r\n return\r\n }\r\n element.addEventListener(\"input\", (e) => {\r\n const value = parseInt((e.target as HTMLInputElement).value, 10)\r\n spanElement.textContent = `${value} ${unit}`\r\n this.foresightManagerInstance.alterGlobalSettings({\r\n [setting]: value,\r\n })\r\n })\r\n }\r\n\r\n private createChangeEventListener(\r\n element: HTMLElement | null,\r\n setting: BooleanSettingKeys | \"name-tag\"\r\n ) {\r\n if (!element) {\r\n return\r\n }\r\n element.addEventListener(\"change\", (e) => {\r\n if (setting === \"name-tag\") {\r\n this.foresightManagerInstance.alterGlobalSettings({\r\n debuggerSettings: {\r\n showNameTags: (e.target as HTMLInputElement).checked,\r\n },\r\n })\r\n } else {\r\n this.foresightManagerInstance.alterGlobalSettings({\r\n [setting]: (e.target as HTMLInputElement).checked,\r\n })\r\n }\r\n })\r\n }\r\n\r\n private createSectionVisibilityToggleEventListener(\r\n section: HTMLDivElement | null,\r\n isMinimizedFlagName:\r\n | \"isMouseSettingsMinimized\"\r\n | \"isKeyboardSettingsMinimized\"\r\n | \"isScrollSettingsMinimized\"\r\n | \"isGeneralSettingsMinimized\"\r\n ) {\r\n const sectionHeader = section?.querySelector(\".debugger-section-header\")\r\n sectionHeader?.addEventListener(\"click\", (e) => {\r\n e.stopPropagation()\r\n this.toggleMinimizeSection(section, (this[isMinimizedFlagName] = !this[isMinimizedFlagName]))\r\n })\r\n }\r\n\r\n private setupEventListeners() {\r\n this.createChangeEventListener(this.trajectoryEnabledCheckbox, \"enableMousePrediction\")\r\n this.createChangeEventListener(this.tabEnabledCheckbox, \"enableTabPrediction\")\r\n this.createChangeEventListener(this.scrollEnabledCheckbox, \"enableScrollPrediction\")\r\n this.createChangeEventListener(this.showNameTagsCheckbox, \"name-tag\")\r\n this.createInputEventListener(\r\n this.historySizeSlider,\r\n this.historyValueSpan,\r\n POSITION_HISTORY_SIZE_UNIT,\r\n \"positionHistorySize\"\r\n )\r\n\r\n this.createInputEventListener(\r\n this.predictionTimeSlider,\r\n this.predictionValueSpan,\r\n TRAJECTORY_PREDICTION_TIME_UNIT,\r\n \"trajectoryPredictionTime\"\r\n )\r\n\r\n this.createInputEventListener(\r\n this.tabOffsetSlider,\r\n this.tabOffsetValueSpan,\r\n TAB_OFFSET_UNIT,\r\n \"tabOffset\"\r\n )\r\n\r\n this.createInputEventListener(\r\n this.scrollMarginSlider,\r\n this.scrollMarginValueSpan,\r\n SCROLL_MARGIN_UNIT,\r\n \"scrollMargin\"\r\n )\r\n\r\n this.sortButton?.addEventListener(\"click\", (e) => {\r\n e.stopPropagation()\r\n this.sortOptionsPopup?.classList.toggle(\"active\")\r\n })\r\n\r\n this.sortOptionsPopup?.addEventListener(\"click\", (e) => {\r\n const target = e.target as HTMLElement\r\n const sortButton = target.closest(\"[data-sort]\") as HTMLElement | null\r\n if (!sortButton) return\r\n\r\n const value = sortButton.dataset.sort as SortElementList\r\n this.foresightManagerInstance.alterGlobalSettings({\r\n debuggerSettings: {\r\n sortElementList: value,\r\n },\r\n })\r\n console.log(\"here\")\r\n this.sortAndReorderElements()\r\n this.updateSortOptionUI(value)\r\n this.sortOptionsPopup?.classList.remove(\"active\")\r\n })\r\n\r\n this.closeSortDropdownHandler = (e: MouseEvent) => {\r\n if (\r\n this.sortOptionsPopup?.classList.contains(\"active\") &&\r\n !this.sortButton?.contains(e.target as Node)\r\n ) {\r\n this.sortOptionsPopup.classList.remove(\"active\")\r\n }\r\n }\r\n document.addEventListener(\"click\", this.closeSortDropdownHandler)\r\n\r\n this.containerMinimizeButton?.addEventListener(\"click\", () => {\r\n this.isContainerMinimized = !this.isContainerMinimized\r\n this.updateContainerVisibilityState()\r\n })\r\n this.copySettingsButton?.addEventListener(\"click\", this.handleCopySettings.bind(this))\r\n\r\n this.createSectionVisibilityToggleEventListener(\r\n this.controlsContainer.querySelector(\".mouse-settings-section\"),\r\n \"isMouseSettingsMinimized\"\r\n )\r\n this.createSectionVisibilityToggleEventListener(\r\n this.controlsContainer.querySelector(\".keyboard-settings-section\"),\r\n \"isKeyboardSettingsMinimized\"\r\n )\r\n this.createSectionVisibilityToggleEventListener(\r\n this.controlsContainer.querySelector(\".scroll-settings-section\"),\r\n \"isScrollSettingsMinimized\"\r\n )\r\n this.createSectionVisibilityToggleEventListener(\r\n this.controlsContainer.querySelector(\".general-settings-section\"),\r\n \"isGeneralSettingsMinimized\"\r\n )\r\n }\r\n\r\n private toggleMinimizeSection(section: HTMLDivElement | null, shouldMinimize: boolean) {\r\n if (!section) {\r\n return\r\n }\r\n const sectionContent: HTMLDivElement | null = section.querySelector(\".debugger-section-content\")\r\n const minimizeButton: HTMLButtonElement | null = section.querySelector(\r\n \".section-minimize-button\"\r\n )\r\n if (sectionContent && minimizeButton) {\r\n if (shouldMinimize) {\r\n sectionContent.style.display = \"none\"\r\n minimizeButton.textContent = \"+\"\r\n } else {\r\n sectionContent.style.display = \"flex\"\r\n minimizeButton.textContent = \"-\"\r\n }\r\n }\r\n this.saveSectionStatesToSessionStorage()\r\n }\r\n\r\n private originalSectionStates() {\r\n const states = this.loadSectionStatesFromSessionStorage()\r\n this.toggleMinimizeSection(\r\n this.controlsContainer.querySelector(\".mouse-settings-section\"),\r\n states.mouse ?? true\r\n )\r\n this.toggleMinimizeSection(\r\n this.controlsContainer.querySelector(\".keyboard-settings-section\"),\r\n states.keyboard ?? true\r\n )\r\n this.toggleMinimizeSection(\r\n this.controlsContainer.querySelector(\".scroll-settings-section\"),\r\n states.scroll ?? true\r\n )\r\n this.toggleMinimizeSection(\r\n this.controlsContainer.querySelector(\".general-settings-section\"),\r\n states.general ?? true\r\n )\r\n // Ensure the element list is always open by default\r\n const elementListContent = this.debuggerElementsSection?.querySelector(\r\n \".debugger-section-content\"\r\n )\r\n if (elementListContent) {\r\n ;(elementListContent as HTMLElement).style.display = \"flex\"\r\n }\r\n }\r\n\r\n private updateContainerVisibilityState() {\r\n if (!this.containerMinimizeButton) return\r\n if (this.isContainerMinimized) {\r\n this.controlsContainer.classList.add(\"minimized\")\r\n this.containerMinimizeButton.textContent = \"+\"\r\n if (this.allSettingsSectionsContainer)\r\n this.allSettingsSectionsContainer.style.display = \"none\"\r\n if (this.debuggerElementsSection) this.debuggerElementsSection.style.display = \"none\"\r\n if (this.copySettingsButton) this.copySettingsButton.style.display = \"none\"\r\n } else {\r\n this.controlsContainer.classList.remove(\"minimized\")\r\n this.containerMinimizeButton.textContent = \"-\"\r\n if (this.allSettingsSectionsContainer) this.allSettingsSectionsContainer.style.display = \"\"\r\n if (this.debuggerElementsSection) this.debuggerElementsSection.style.display = \"\"\r\n if (this.copySettingsButton) this.copySettingsButton.style.display = \"\"\r\n }\r\n }\r\n\r\n // Adds a tick before the choosen sort option\r\n private updateSortOptionUI(currentSort: SortElementList) {\r\n this.sortOptionsPopup?.querySelectorAll(\"[data-sort]\").forEach((button) => {\r\n const btn = button as HTMLElement\r\n if (btn.dataset.sort === currentSort) {\r\n btn.classList.add(\"active-sort-option\")\r\n } else {\r\n btn.classList.remove(\"active-sort-option\")\r\n }\r\n })\r\n }\r\n\r\n public updateControlsState(settings: ForesightManagerSettings) {\r\n if (this.trajectoryEnabledCheckbox) {\r\n this.trajectoryEnabledCheckbox.checked = settings.enableMousePrediction\r\n }\r\n if (this.tabEnabledCheckbox) {\r\n this.tabEnabledCheckbox.checked = settings.enableTabPrediction\r\n }\r\n if (this.scrollEnabledCheckbox) {\r\n this.scrollEnabledCheckbox.checked = settings.enableScrollPrediction\r\n }\r\n if (this.showNameTagsCheckbox) {\r\n this.showNameTagsCheckbox.checked =\r\n settings.debuggerSettings.showNameTags ?? DEFAULT_SHOW_NAME_TAGS\r\n }\r\n this.updateSortOptionUI(settings.debuggerSettings.sortElementList ?? \"visibility\")\r\n if (this.historySizeSlider && this.historyValueSpan) {\r\n this.historySizeSlider.value = settings.positionHistorySize.toString()\r\n this.historyValueSpan.textContent = `${settings.positionHistorySize} ${POSITION_HISTORY_SIZE_UNIT}`\r\n }\r\n if (this.predictionTimeSlider && this.predictionValueSpan) {\r\n this.predictionTimeSlider.value = settings.trajectoryPredictionTime.toString()\r\n this.predictionValueSpan.textContent = `${settings.trajectoryPredictionTime} ${TRAJECTORY_PREDICTION_TIME_UNIT}`\r\n }\r\n if (this.tabOffsetSlider && this.tabOffsetValueSpan) {\r\n this.tabOffsetSlider.value = settings.tabOffset.toString()\r\n this.tabOffsetValueSpan.textContent = `${settings.tabOffset} ${TAB_OFFSET_UNIT}`\r\n }\r\n if (this.scrollMarginSlider && this.scrollMarginValueSpan) {\r\n this.scrollMarginSlider.value = settings.scrollMargin.toString()\r\n this.scrollMarginValueSpan.textContent = `${settings.scrollMargin} ${SCROLL_MARGIN_UNIT}`\r\n }\r\n }\r\n\r\n private refreshRegisteredElementCountDisplay(\r\n elementsMap: ReadonlyMap<Element, ForesightElementData>\r\n ) {\r\n if (!this.elementCountSpan || !this.callbackCountSpan) {\r\n return\r\n }\r\n\r\n let visibleElementCount = 0\r\n elementsMap.forEach((data) => {\r\n if (data.isIntersectingWithViewport) {\r\n visibleElementCount++\r\n }\r\n })\r\n const totalElements = elementsMap.size\r\n const { tab, mouse, scroll, total } =\r\n this.foresightManagerInstance.getManagerData.globalCallbackHits\r\n this.elementCountSpan.textContent = `Visible: ${visibleElementCount}/${totalElements} ~ `\r\n this.elementCountSpan.title = [\r\n \"Element Visibility Status\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n `Visible in Viewport: ${visibleElementCount}`,\r\n `Not in Viewport: ${totalElements - visibleElementCount}`,\r\n `Total Registered Elements: ${totalElements}`,\r\n \"\",\r\n \"Note: Only elements visible in the viewport\",\r\n \"are actively tracked by intersection observers.\",\r\n ].join(\"\\n\")\r\n this.callbackCountSpan.textContent = `Mouse: ${mouse.hover + mouse.trajectory} Tab: ${\r\n tab.forwards + tab.reverse\r\n } Scroll: ${scroll.down + scroll.left + scroll.right + scroll.up}`\r\n this.callbackCountSpan.title = [\r\n \"Callback Execution Stats\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Mouse Callbacks\",\r\n ` • Trajectory: ${mouse.trajectory}`,\r\n ` • Hover: ${mouse.hover}`,\r\n ` • Subtotal: ${mouse.hover + mouse.trajectory}`,\r\n \"\",\r\n \"Keyboard Callbacks:\",\r\n ` • Tab Forward: ${tab.forwards}`,\r\n ` • Tab Reverse: ${tab.reverse}`,\r\n ` • Subtotal: ${tab.forwards + tab.reverse}`,\r\n \"\",\r\n \"Scroll Callbacks:\",\r\n ` • Up: ${scroll.up} | Down: ${scroll.down}`,\r\n ` • Left: ${scroll.left} | Right: ${scroll.right}`,\r\n ` • Subtotal: ${scroll.up + scroll.down + scroll.left + scroll.right}`,\r\n \"\",\r\n \"Total Callbacks: \" + total,\r\n ].join(\"\\n\")\r\n }\r\n\r\n public removeElementFromList(elementData: ForesightElementData) {\r\n if (!this.elementListItemsContainer) return\r\n\r\n const listItem = this.elementListItems.get(elementData.element)\r\n\r\n if (listItem) {\r\n listItem.remove()\r\n this.elementListItems.delete(elementData.element)\r\n const elementsMap = this.foresightManagerInstance.registeredElements\r\n this.refreshRegisteredElementCountDisplay(elementsMap)\r\n\r\n if (this.elementListItems.size === 0) {\r\n this.elementListItemsContainer.innerHTML = NO_ELEMENTS_STRING\r\n }\r\n }\r\n }\r\n\r\n public updateElementVisibilityStatus(elementData: ForesightElementData) {\r\n if (!this.elementListItemsContainer) return\r\n const listItem = this.elementListItems.get(elementData.element)\r\n if (!listItem) {\r\n this.addElementToList(elementData)\r\n return\r\n }\r\n\r\n listItem.classList.toggle(\"not-in-viewport\", !elementData.isIntersectingWithViewport)\r\n const intersectingElement = listItem.querySelector(\".intersecting-indicator\")\r\n if (intersectingElement) {\r\n const intersectingIcon = getIntersectingIcon(elementData.isIntersectingWithViewport)\r\n intersectingElement.textContent = intersectingIcon\r\n }\r\n this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements)\r\n this.sortAndReorderElements()\r\n }\r\n\r\n private sortAndReorderElements() {\r\n if (!this.elementListItemsContainer) return\r\n\r\n const sortOrder =\r\n this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings\r\n .sortElementList ?? \"visibility\"\r\n\r\n const elementsData = Array.from(this.foresightManagerInstance.registeredElements.values())\r\n\r\n if (sortOrder !== \"insertionOrder\") {\r\n const sortByDocumentPosition = (a: ForesightElementData, b: ForesightElementData) => {\r\n const position = a.element.compareDocumentPosition(b.element)\r\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1\r\n if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1\r\n return 0\r\n }\r\n\r\n if (sortOrder === \"visibility\") {\r\n elementsData.sort((a, b) => {\r\n if (a.isIntersectingWithViewport !== b.isIntersectingWithViewport) {\r\n return a.isIntersectingWithViewport ? -1 : 1\r\n }\r\n return sortByDocumentPosition(a, b)\r\n })\r\n } else if (sortOrder === \"documentOrder\") {\r\n elementsData.sort(sortByDocumentPosition)\r\n }\r\n }\r\n\r\n const fragment = document.createDocumentFragment()\r\n\r\n if (elementsData.length) {\r\n elementsData.forEach((elementData) => {\r\n const listItem = this.elementListItems.get(elementData.element)\r\n if (listItem) {\r\n // Appending to the fragment is cheap (it's off-screen)\r\n fragment.appendChild(listItem)\r\n }\r\n })\r\n\r\n this.elementListItemsContainer.innerHTML = \"\"\r\n this.elementListItemsContainer.appendChild(fragment)\r\n }\r\n }\r\n\r\n public addElementToList(elementData: ForesightElementData, sort: boolean = true) {\r\n if (!this.elementListItemsContainer) return\r\n if (this.elementListItemsContainer.innerHTML === NO_ELEMENTS_STRING) {\r\n this.elementListItemsContainer.innerHTML = \"\"\r\n }\r\n if (this.elementListItems.has(elementData.element)) return\r\n const listItem = document.createElement(\"div\")\r\n listItem.className = \"element-list-item\"\r\n this.updateListItemContent(listItem, elementData)\r\n this.elementListItemsContainer!.appendChild(listItem)\r\n this.elementListItems.set(elementData.element, listItem)\r\n this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements)\r\n if (sort) {\r\n this.sortAndReorderElements()\r\n }\r\n }\r\n\r\n private updateListItemContent(listItem: HTMLElement, elementData: ForesightElementData) {\r\n // Determine the viewport icon based on current visibility status\r\n const intersectingIcon = getIntersectingIcon(elementData.isIntersectingWithViewport)\r\n listItem.classList.toggle(\"not-in-viewport\", !elementData.isIntersectingWithViewport)\r\n const hitBehaviorText = elementData.unregisterOnCallback ? \"Single\" : \"Multi\"\r\n let hitSlopText = \"N/A\"\r\n\r\n if (elementData.elementBounds.hitSlop) {\r\n const { top, right, bottom, left } = elementData.elementBounds.hitSlop\r\n hitSlopText = `T:${top} R:${right} B:${bottom} L:${left}`\r\n }\r\n\r\n // Create comprehensive title with all information\r\n const comprehensiveTitle = [\r\n `${elementData.name || \"Unnamed Element\"}`,\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Viewport Status:\",\r\n elementData.isIntersectingWithViewport\r\n ? \" ✓ In viewport - actively tracked by observers\"\r\n : \" ✗ Not in viewport - not being tracked\",\r\n \"\",\r\n \"Hit Behavior:\",\r\n elementData.unregisterOnCallback\r\n ? \" • Single: Callback triggers once\"\r\n : \" • Multi: Callback can trigger multiple times\",\r\n \"\",\r\n \"Hit Slop:\",\r\n elementData.elementBounds.hitSlop\r\n ? [\r\n ` Top: ${elementData.elementBounds.hitSlop.top}px, Bottom: ${elementData.elementBounds.hitSlop.bottom}px `,\r\n ` Right: ${elementData.elementBounds.hitSlop.right}px, Left: ${elementData.elementBounds.hitSlop.left}px`,\r\n ].join(\"\\n\")\r\n : \" • Not defined - using element's natural boundaries\",\r\n \"\",\r\n ].join(\"\\n\")\r\n\r\n listItem.title = comprehensiveTitle\r\n\r\n listItem.innerHTML = `\r\n <span class=\"intersecting-indicator\">${intersectingIcon}</span>\r\n <span class=\"element-name\">${elementData.name || \"Unnamed Element\"}</span>\r\n <span class=\"hit-slop\">${hitSlopText}</span>\r\n <span class=\"hit-behavior\">${hitBehaviorText}</span>\r\n `\r\n }\r\n /**\r\n * The cleanup method is updated to be more thorough, nullifying all\r\n * DOM-related properties to put the instance in a dormant state.\r\n */\r\n public cleanup() {\r\n this.controlsContainer?.remove()\r\n this.controlPanelStyleElement?.remove()\r\n\r\n if (this.copyTimeoutId) {\r\n clearTimeout(this.copyTimeoutId)\r\n this.copyTimeoutId = null\r\n }\r\n\r\n if (this.closeSortDropdownHandler) {\r\n document.removeEventListener(\"click\", this.closeSortDropdownHandler)\r\n this.closeSortDropdownHandler = null\r\n }\r\n\r\n // Nullify all DOM-related properties to signal it's \"cleaned up\"\r\n this.controlsContainer = null!\r\n this.controlPanelStyleElement = null!\r\n this.elementListItemsContainer = null\r\n this.elementCountSpan = null\r\n this.callbackCountSpan = null\r\n this.elementListItems.clear()\r\n this.containerMinimizeButton = null\r\n this.allSettingsSectionsContainer = null\r\n this.debuggerElementsSection = null\r\n this.trajectoryEnabledCheckbox = null\r\n this.tabEnabledCheckbox = null\r\n this.scrollEnabledCheckbox = null\r\n this.historySizeSlider = null\r\n this.historyValueSpan = null\r\n this.predictionTimeSlider = null\r\n this.predictionValueSpan = null\r\n this.tabOffsetSlider = null\r\n this.tabOffsetValueSpan = null\r\n this.scrollMarginSlider = null\r\n this.scrollMarginValueSpan = null\r\n this.showNameTagsCheckbox = null\r\n this.sortOptionsPopup = null\r\n this.sortButton = null\r\n this.copySettingsButton = null\r\n }\r\n\r\n private createControlContainer(): HTMLElement {\r\n const container = document.createElement(\"div\")\r\n container.id = \"debug-controls\"\r\n container.innerHTML = `\r\n <div class=\"debugger-title-container\">\r\n <button class=\"minimize-button\">-</button>\r\n <div class=\"title-group\">\r\n <h2>Foresight Debugger</h2>\r\n <span class=\"info-icon\" title=\"${[\r\n \"Foresight Debugger Information\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Session-Only Changes:\",\r\n \"All adjustments made here apply only to the\",\r\n \"current browser session and won't persist.\",\r\n \"\",\r\n \"Permanent Configuration:\",\r\n \"To make lasting changes, update the initial\",\r\n \"values in your ForesightManager.initialize().\",\r\n \"\",\r\n \"You can copy the current debugger settings\",\r\n \"with the button on the right\",\r\n ].join(\"\\n\")}\">i</span>\r\n </div>\r\n <button class=\"copy-settings-button\" title=\"${[\r\n \"Copy Settings to Clipboard\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Copies the current configuration as a\",\r\n \"formatted method call that you can paste\",\r\n \"directly into your code.\",\r\n ].join(\"\\n\")}\">\r\n ${COPY_SVG_ICON}\r\n </button>\r\n </div>\r\n\r\n <div class=\"all-settings-sections-container\">\r\n <div class=\"debugger-section mouse-settings-section\">\r\n <div class=\"debugger-section-header collapsible\">\r\n <h3>Mouse Settings</h3>\r\n <button class=\"section-minimize-button\">-</button>\r\n </div>\r\n <div class=\"debugger-section-content mouse-settings-content\">\r\n <div class=\"control-row\">\r\n <label for=\"trajectory-enabled\">\r\n Enable Mouse Prediction\r\n <span class=\"info-icon\" title=\"${[\r\n \"Mouse Prediction Control\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"When enabled: Predicts mouse movement\",\r\n \"trajectory and triggers callbacks before\",\r\n \"the cursor reaches the target element.\",\r\n \"\",\r\n \"When disabled: Only direct hover events\",\r\n \"trigger actions (next to tab/scroll).\",\r\n \"\",\r\n \"Property: enableMousePrediction\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"checkbox\" id=\"trajectory-enabled\">\r\n </div>\r\n <div class=\"control-row\">\r\n <label for=\"history-size\">\r\n History Size\r\n <span class=\"info-icon\" title=\"${[\r\n \"Position History\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Controls how many past mouse positions\",\r\n \"are stored for velocity calculations.\",\r\n \"\",\r\n \"Higher values:\",\r\n \" • More accurate trajectory predictions\",\r\n \" • Smoother movement detection\",\r\n \" • Slightly increased processing overhead\",\r\n \"\",\r\n \"Lower values:\",\r\n \" • Faster response to direction changes\",\r\n \" • Less memory usage\",\r\n \" • May be less accurate for fast movements\",\r\n \"\",\r\n \"Property: positionHistorySize\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"range\" id=\"history-size\" min=\"${MIN_POSITION_HISTORY_SIZE}\" max=\"${MAX_POSITION_HISTORY_SIZE}\">\r\n <span id=\"history-value\"></span>\r\n </div>\r\n <div class=\"control-row\">\r\n <label for=\"prediction-time\">\r\n Prediction Time\r\n <span class=\"info-icon\" title=\"${[\r\n \"Trajectory Prediction Time\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n `How far into the future (in ${TRAJECTORY_PREDICTION_TIME_UNIT})`,\r\n \"to calculate the mouse trajectory path.\",\r\n \"\",\r\n \"Larger values:\",\r\n \" • Elements are detected sooner\",\r\n \" • More time for preloading/preparation\",\r\n \" • May trigger false positives for curved paths\",\r\n \"\",\r\n \"Smaller values:\",\r\n \" • More precise targeting\",\r\n \" • Reduced false positive rate\",\r\n \" • Less time for preparation\",\r\n \"\",\r\n \"Property: trajectoryPredictionTime\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"range\" id=\"prediction-time\" min=\"${MIN_TRAJECTORY_PREDICTION_TIME}\" max=\"${MAX_TRAJECTORY_PREDICTION_TIME}\" step=\"10\">\r\n <span id=\"prediction-value\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"debugger-section keyboard-settings-section\">\r\n <div class=\"debugger-section-header collapsible\">\r\n <h3>Keyboard Settings</h3>\r\n <button class=\"section-minimize-button\">-</button>\r\n </div>\r\n <div class=\"debugger-section-content keyboard-settings-content\">\r\n <div class=\"control-row\">\r\n <label for=\"tab-enabled\">\r\n Enable Tab Prediction\r\n <span class=\"info-icon\" title=\"${[\r\n \"Tab Navigation Prediction\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"When enabled: Callbacks are executed when\",\r\n `the user is ${this.foresightManagerInstance.getManagerData.globalSettings.tabOffset} (tabOffset) ${TAB_OFFSET_UNIT} away from`,\r\n \"a registered element during tab navigation.\",\r\n \"\",\r\n \"(works with Shift+Tab too).\",\r\n \"\",\r\n \"Property: enableTabPrediction\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"checkbox\" id=\"tab-enabled\">\r\n </div>\r\n <div class=\"control-row\">\r\n <label for=\"tab-offset\">\r\n Tab Offset\r\n <span class=\"info-icon\" title=\"${[\r\n \"Tab Offset\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Number of tabbable elements to look ahead\",\r\n \"when predicting tab navigation targets.\",\r\n \"\",\r\n \"How it works:\",\r\n \" • Tracks the current focused element\",\r\n \" • Looks ahead by the specified offset\",\r\n \" • Triggers callbacks for registered elements\",\r\n \" within that range\",\r\n \"\",\r\n \"Property: tabOffset\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"range\" id=\"tab-offset\" min=\"${MIN_TAB_OFFSET}\" max=\"${MAX_TAB_OFFSET}\" step=\"1\">\r\n <span id=\"tab-offset-value\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"debugger-section scroll-settings-section\">\r\n <div class=\"debugger-section-header collapsible\">\r\n <h3>Scroll Settings</h3>\r\n <button class=\"section-minimize-button\">-</button>\r\n </div>\r\n <div class=\"debugger-section-content scroll-settings-content\">\r\n <div class=\"control-row\">\r\n <label for=\"scroll-enabled\">\r\n Enable Scroll Prediction\r\n <span class=\"info-icon\" title=\"${[\r\n \"Scroll Prediction\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Enables predictive scrolling based on mouse\",\r\n \"position and scroll direction.\",\r\n \"\",\r\n \"When enabled, calculates scroll direction from\",\r\n \"mouse movement and triggers callbacks for\",\r\n \"elements that intersect the predicted path.\",\r\n \"\",\r\n \"Property: enableScrollPrediction\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"checkbox\" id=\"scroll-enabled\">\r\n </div>\r\n <div class=\"control-row\">\r\n <label for=\"scroll-margin\">\r\n Scroll Margin\r\n <span class=\"info-icon\" title=\"${[\r\n \"Scroll Margin\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Sets the pixel distance to check from the\",\r\n \"mouse position in the scroll direction.\",\r\n \"\",\r\n \"Higher values check further ahead, allowing\",\r\n \"earlier detection of elements that will come\",\r\n \"into view during scrolling.\",\r\n \"\",\r\n \"Property: scrollMargin\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"range\" id=\"scroll-margin\" min=\"${MIN_SCROLL_MARGIN}\" max=\"${MAX_SCROLL_MARGIN}\" step=\"10\">\r\n <span id=\"scroll-margin-value\"></span>\r\n </div>\r\n </div>\r\n\r\n <div class=\"debugger-section general-settings-section\">\r\n <div class=\"debugger-section-header collapsible\">\r\n <h3>General Settings</h3>\r\n <button class=\"section-minimize-button\">-</button>\r\n </div>\r\n <div class=\"debugger-section-content general-settings-content\">\r\n <div class=\"control-row\">\r\n <label for=\"toggle-name-tags\">\r\n Show Name Tags\r\n <span class=\"info-icon\" title=\"${[\r\n \"Visual Debug Name Tags\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"When enabled: Displays name tags over\",\r\n \"each registered element in debug mode.\",\r\n \"\",\r\n \"Property: debuggerSettings.showNameTags\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"checkbox\" id=\"toggle-name-tags\">\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"debugger-section debugger-elements\">\r\n <div class=\"debugger-section-header elements-list-header\">\r\n <h3>Elements <span id=\"element-count\"></span> <span id=\"callback-count\"></span></h3>\r\n <div class=\"header-controls\">\r\n <div class=\"sort-control-container\">\r\n <button class=\"sort-button\" title=\"Change element list sort order\">\r\n ${SORT_SVG_ICON}\r\n </button>\r\n <div id=\"sort-options-popup\">\r\n <button\r\n data-sort=\"visibility\"\r\n title=\"${[\r\n \"Sort by Visibility\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Sorts elements by their viewport visibility\",\r\n \"(visible elements first), with a secondary\",\r\n \"sort by their order in the document.\",\r\n \"\",\r\n \"Property: debuggerSettings.sortElementList\",\r\n \"Value: 'visibility'\",\r\n ].join(\"\\n\")}\"\r\n>\r\n Visibility\r\n</button>\r\n<button\r\n data-sort=\"documentOrder\"\r\n title=\"${[\r\n \"Sort by Document Order\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Sorts elements based on their order of\",\r\n \"appearance in the document's structure\",\r\n \"(matching the HTML source).\",\r\n \"\",\r\n \"Property: debuggerSettings.sortElementList\",\r\n \"Value: 'documentOrder'\",\r\n ].join(\"\\n\")}\"\r\n>\r\n Document Order\r\n</button>\r\n<button\r\n data-sort=\"insertionOrder\"\r\n title=\"${[\r\n \"Sort by Insertion Order\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Sorts elements based on the order they\",\r\n \"were registered with the ForesightManager.\",\r\n \"\",\r\n \"Property: debuggerSettings.sortElementList\",\r\n \"Value: 'insertionOrder'\",\r\n ].join(\"\\n\")}\"\r\n>\r\n Insertion Order\r\n</button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"debugger-section-content element-list\">\r\n <div id=\"element-list-items-container\">\r\n </div>\r\n </div>\r\n </div>\r\n `\r\n return container\r\n }\r\n\r\n private getStyles(): string {\r\n const elementItemHeight = 35 // px\r\n const elementListGap = 3 // px\r\n const elementListItemsContainerPadding = 6 // px\r\n const numRowsToShow = 6\r\n const numItemsPerRow = 1\r\n\r\n const rowsContentHeight =\r\n elementItemHeight * numRowsToShow + elementListGap * (numRowsToShow - 1)\r\n const elementListContainerHeight = rowsContentHeight + elementListItemsContainerPadding * 2\r\n\r\n return `\r\n #debug-controls {\r\n position: fixed; bottom: 10px; right: 10px;\r\n background-color: rgba(0, 0, 0, 0.90); color: white; padding: 12px;\r\n border-radius: 5px; font-family: Arial, sans-serif; font-size: 13px;\r\n z-index: 10001; pointer-events: auto; display: flex; flex-direction: column; gap: 8px;\r\n width: 400px;\r\n transition: width 0.3s ease, height 0.3s ease;\r\n }\r\n #debug-controls.minimized {\r\n width: 220px;\r\n overflow: hidden;\r\n padding: 12px 0; \r\n }\r\n #debug-controls.minimized .debugger-title-container {\r\n justify-content: flex-start; \r\n padding-left: 10px; \r\n padding-right: 10px;\r\n gap: 10px; \r\n }\r\n #debug-controls.minimized .debugger-title-container h2 {\r\n display: inline;\r\n font-size: 14px;\r\n margin: 0;\r\n white-space: nowrap;\r\n }\r\n #debug-controls.minimized .info-icon {\r\n display: none;\r\n }\r\n\r\n #element-count,#callback-count {\r\n font-size: 12px;\r\n color: #9e9e9e;\r\n }\r\n\r\n .debugger-title-container {\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between; \r\n padding: 0 0px; \r\n }\r\n .title-group { \r\n display: flex;\r\n align-items: center;\r\n gap: 8px; \r\n\r\n }\r\n .minimize-button {\r\n background: none; border: none; color: white;\r\n font-size: 22px; cursor: pointer;\r\n line-height: 1;\r\n }\r\n .debugger-title-container h2 { margin: 0; font-size: 15px; }\r\n\r\n .copy-settings-button {\r\n background: none; border: none; color: white;\r\n cursor: pointer; padding: 0;\r\n display: flex; align-items: center; justify-content: center;\r\n }\r\n .copy-settings-button svg {\r\n width: 16px; height: 16px;\r\n stroke: white;\r\n }\r\n\r\n .all-settings-sections-container {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 8px;\r\n }\r\n\r\n .debugger-section-header {\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n margin-top: 5px;\r\n margin-bottom: 2px;\r\n padding-bottom: 2px;\r\n border-bottom: 1px solid #444;\r\n }\r\n .debugger-section-header.collapsible {\r\n cursor: pointer;\r\n }\r\n .debugger-section-header h3 {\r\n margin: 0;\r\n font-size: 14px;\r\n font-weight: bold;\r\n color: #b0c4de;\r\n flex-grow: 1;\r\n }\r\n\r\n .section-minimize-button {\r\n background: none;\r\n border: none;\r\n color: white;\r\n font-size: 18px;\r\n cursor: pointer;\r\n padding: 0;\r\n line-height: 1;\r\n }\r\n\r\n #debug-controls .control-row {\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n gap: 8px;\r\n }\r\n #debug-controls label {\r\n display: flex;\r\n align-items: center;\r\n gap: 5px;\r\n cursor: pointer;\r\n }\r\n #debug-controls .control-row:has(input[type=\"checkbox\"]) label {\r\n flex-grow: 1;\r\n }\r\n #debug-controls .control-row input[type=\"checkbox\"] {\r\n appearance: none; -webkit-appearance: none; -moz-appearance: none;\r\n position: relative; width: 40px; height: 18px;\r\n background-color: #555; border-radius: 10px; cursor: pointer;\r\n outline: none; transition: background-color 0.2s ease;\r\n vertical-align: middle; flex-shrink: 0; margin: 0;\r\n }\r\n #debug-controls .control-row input[type=\"checkbox\"]::before {\r\n content: \"\"; position: absolute; width: 14px; height: 14px;\r\n border-radius: 50%; background-color: white; top: 2px; left: 2px;\r\n transition: transform 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.4);\r\n }\r\n #debug-controls .control-row input[type=\"checkbox\"]:checked {\r\n background-color: #b0c4de;\r\n }\r\n #debug-controls .control-row input[type=\"checkbox\"]:checked::before {\r\n transform: translateX(22px);\r\n }\r\n #debug-controls .control-row:has(input[type=\"range\"]) label {\r\n flex-basis: 170px; flex-shrink: 0;\r\n }\r\n #debug-controls input[type=\"range\"] {\r\n flex-grow: 1; margin: 0; cursor: pointer; -webkit-appearance: none;\r\n appearance: none; background: transparent; height: 18px; vertical-align: middle;\r\n }\r\n #debug-controls input[type=\"range\"]::-webkit-slider-runnable-track {\r\n height: 6px; background: #555; border-radius: 3px;\r\n }\r\n #debug-controls input[type=\"range\"]::-moz-range-track {\r\n height: 6px; background: #555; border-radius: 3px;\r\n }\r\n #debug-controls input[type=\"range\"]::-webkit-slider-thumb {\r\n -webkit-appearance: none; appearance: none; margin-top: -5px;\r\n background: #b0c4de; height: 16px; width: 16px;\r\n border-radius: 50%; border: 1px solid #333;\r\n }\r\n #debug-controls input[type=\"range\"]::-moz-range-thumb {\r\n background: #b0c4de; height: 16px; width: 16px;\r\n border-radius: 50%; border: 1px solid #333; border: none;\r\n }\r\n #debug-controls .control-row:has(input[type=\"range\"]) span:not(.info-icon) {\r\n width: 55px; min-width: 55px; text-align: right; flex-shrink: 0;\r\n }\r\n .info-icon {\r\n display: inline-flex; align-items: center; justify-content: center;\r\n width: 16px; height: 16px; border-radius: 50%;\r\n background-color: #555; color: white; font-size: 10px;\r\n font-style: italic; font-weight: bold; font-family: 'Georgia', serif;\r\n cursor: help; user-select: none; flex-shrink: 0;\r\n }\r\n .debugger-section {\r\n display: flex; flex-direction: column; gap: 6px;\r\n }\r\n .debugger-section-content {\r\n display: none; flex-direction: column; gap: 8px;\r\n }\r\n\r\n /* Element List Styles */\r\n .elements-list-header { cursor: default; }\r\n .header-controls {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n }\r\n .sort-control-container {\r\n position: relative;\r\n }\r\n .sort-button {\r\n background: none; border: none; color: white; cursor: pointer;\r\n padding: 0; display: flex; align-items: center; justify-content: center;\r\n }\r\n .sort-button svg {\r\n width: 16px; height: 16px; stroke: #b0c4de; transition: stroke 0.2s;\r\n }\r\n .sort-button:hover svg { stroke: white; }\r\n \r\n #sort-options-popup {\r\n position: absolute;\r\n bottom: calc(100% + 5px);\r\n right: -5px;\r\n z-index: 10;\r\n display: none;\r\n flex-direction: column;\r\n gap: 4px;\r\n background-color: #3a3a3a;\r\n border: 1px solid #555;\r\n border-radius: 4px;\r\n padding: 3px;\r\n width: 200px;\r\n box-shadow: 0 4px 8px rgba(0,0,0,0.3);\r\n }\r\n #sort-options-popup.active {\r\n display: flex;\r\n }\r\n #sort-options-popup button {\r\n background: none; border: none; color: #ccc;\r\n font-size: 12px; text-align: left; padding: 5px 8px;\r\n cursor: pointer; border-radius: 3px;\r\n transition: background-color 0.2s, color 0.2s;\r\n display: flex;\r\n align-items: center;\r\n height: 26px;\r\n }\r\n #sort-options-popup button:hover {\r\n background-color: #555;\r\n color: white;\r\n }\r\n #sort-options-popup button.active-sort-option {\r\n color: #b0c4de;\r\n font-weight: bold;\r\n }\r\n #sort-options-popup button.active-sort-option::before {\r\n content: '✓';\r\n margin-right: 6px;\r\n width: 10px;\r\n }\r\n #sort-options-popup button::before {\r\n content: '';\r\n margin-right: 6px;\r\n width: 10px;\r\n }\r\n\r\n .element-list { /* Scroll container */\r\n min-height: ${elementListContainerHeight}px;\r\n max-height: ${elementListContainerHeight}px; \r\n overflow-y: auto;\r\n background-color: rgba(20, 20, 20, 0.5);\r\n border-radius: 3px;\r\n padding: 0;\r\n display: flex;\r\n }\r\n\r\n /* Modern Scrollbar Styling */\r\n .element-list::-webkit-scrollbar { width: 8px; }\r\n .element-list::-webkit-scrollbar-track { background: rgba(30, 30, 30, 0.5); border-radius: 4px; }\r\n .element-list::-webkit-scrollbar-thumb { background-color: rgba(176, 196, 222, 0.5); border-radius: 4px; border: 2px solid rgba(0, 0, 0, 0.2); }\r\n .element-list::-webkit-scrollbar-thumb:hover { background-color: rgba(176, 196, 222, 0.7); }\r\n .element-list { scrollbar-width: thin; scrollbar-color: rgba(176, 196, 222, 0.5) rgba(30, 30, 30, 0.5); }\r\n\r\n #element-list-items-container { \r\n display: flex;\r\n flex-wrap: wrap;\r\n gap: ${elementListGap}px;\r\n padding: ${elementListItemsContainerPadding}px;\r\n min-height: ${rowsContentHeight}px;\r\n box-sizing: border-box;\r\n align-content: flex-start;\r\n }\r\n #element-list-items-container > em {\r\n flex-basis: 100%;\r\n text-align: center;\r\n padding: 10px 0;\r\n font-style: italic;\r\n color: #ccc;\r\n font-size: 12px;\r\n }\r\n .element-list-item {\r\n flex-basis: calc((100% - (${\r\n numItemsPerRow - 1\r\n } * ${elementListGap}px)) / ${numItemsPerRow});\r\n flex-grow: 0;\r\n flex-shrink: 0;\r\n height: ${elementItemHeight}px;\r\n box-sizing: border-box;\r\n padding: 3px 5px;\r\n border-radius: 2px;\r\n display: flex;\r\n align-items: center;\r\n gap: 5px;\r\n background-color: rgba(50,50,50,0.7);\r\n transition: background-color 0.2s ease, opacity 0.2s ease;\r\n font-size: 11px; \r\n overflow: hidden;\r\n }\r\n \r\n /* Viewport intersection styling */\r\n .element-list-item.not-in-viewport { opacity: 0.4; }\r\n \r\n .element-list-item .element-name {\r\n flex-grow: 1;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n font-size: 12px; \r\n font-weight: bold;\r\n }\r\n .element-list-item .intersecting-indicator {\r\n font-size: 12px;\r\n flex-shrink: 0;\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n width: 16px;\r\n height: 16px;\r\n }\r\n .element-list-item .hit-behavior,\r\n .element-list-item .hit-slop {\r\n font-size: 10px; \r\n color: #b0b0b0;\r\n padding: 2px 5px; \r\n border-radius: 3px; \r\n background-color: rgba(0,0,0,0.2);\r\n flex-shrink: 0;\r\n }\r\n `\r\n }\r\n}\r\n","import type { ForesightElementData } from \"../../types/types\"\r\nimport type { ElementOverlays } from \"../ForesightDebugger\"\r\n\r\nexport function updateElementOverlays(\r\n currentOverlays: ElementOverlays,\r\n newData: ForesightElementData,\r\n showNameTags: boolean\r\n) {\r\n const { expandedOverlay, nameLabel } = currentOverlays\r\n const { expandedRect } = newData.elementBounds\r\n\r\n const expandedWidth = expandedRect.right - expandedRect.left\r\n const expandedHeight = expandedRect.bottom - expandedRect.top\r\n expandedOverlay.style.width = `${expandedWidth}px`\r\n expandedOverlay.style.height = `${expandedHeight}px`\r\n expandedOverlay.style.transform = `translate3d(${expandedRect.left}px, ${expandedRect.top}px, 0)`\r\n expandedOverlay.style.display = \"block\"\r\n\r\n nameLabel.textContent = newData.name\r\n if (newData.name === \"\" || !showNameTags) {\r\n nameLabel.style.display = \"none\"\r\n } else {\r\n nameLabel.style.display = \"block\"\r\n nameLabel.style.transform = `translate3d(${expandedRect.left}px, ${expandedRect.top - 25}px, 0)`\r\n }\r\n}\r\n","// src/utilities/Rect.ts\nvar Rect = class {\n /**\n * Intersects two DOMRects.\n *\n * @param rect1 - The first DOMRect.\n * @param rect2 - The second DOMRect.\n * @returns The intersection of the two DOMRects.\n */\n static intersect(rect1, rect2) {\n const left = Math.max(rect1.left, rect2.left);\n const right = Math.min(rect1.right, rect2.right);\n const top = Math.max(rect1.top, rect2.top);\n const bottom = Math.min(rect1.bottom, rect2.bottom);\n const width = Math.max(0, right - left);\n const height = Math.max(0, bottom - top);\n return new DOMRect(left, top, width, height);\n }\n /**\n * Clips a DOMRect to a given rectangle.\n *\n * @param rect - The DOMRect to clip.\n * @param clip - The rectangle to clip the DOMRect to.\n * @returns The clipped DOMRect.\n */\n static clip(rect, clip) {\n const updatedRect = {\n ...rect.toJSON(),\n top: rect.top + clip.top,\n left: rect.left + clip.left,\n bottom: rect.bottom - clip.bottom,\n right: rect.right - clip.right\n };\n updatedRect.width = updatedRect.right - updatedRect.left;\n updatedRect.height = updatedRect.bottom - updatedRect.top;\n return updatedRect;\n }\n /**\n * Calculates the offsets of a clipped DOMRect.\n *\n * @param rect - The DOMRect to calculate the offsets for.\n * @param clippedRect - The clipped DOMRect.\n * @returns The offsets of the clipped DOMRect.\n */\n static clipOffsets(rect, clippedRect) {\n return {\n top: clippedRect.top - rect.top,\n left: clippedRect.left - rect.left,\n bottom: rect.bottom - clippedRect.bottom,\n right: rect.right - clippedRect.right\n };\n }\n /**\n * Checks if two DOMRects are equal.\n *\n * @param rect1 - The first DOMRect.\n * @param rect2 - The second DOMRect.\n * @returns True if the DOMRects are equal, false otherwise.\n */\n static equals(rect1, rect2) {\n if (rect1 == null || rect2 == null) return rect1 === rect2;\n return rect1.x === rect2.x && rect1.y === rect2.y && rect1.width === rect2.width && rect1.height === rect2.height;\n }\n static sizeEqual(rect1, rect2) {\n return Math.round(rect1.width) === Math.round(rect2.width) && Math.round(rect1.height) === Math.round(rect2.height);\n }\n};\n\n// src/utilities/rootMargin.ts\nvar INSET = -1;\nvar MIN_SIZE = 1 - INSET * 2;\nfunction rootMargin(rect, rootBounds) {\n const width = Math.max(rect.width, MIN_SIZE);\n const height = Math.max(rect.height, MIN_SIZE);\n const top = rect.top - rootBounds.top - INSET;\n const left = rect.left - rootBounds.left - INSET;\n const right = rootBounds.right - rect.left - width - INSET;\n const bottom = rootBounds.bottom - rect.top - height - INSET;\n return `${-Math.round(top)}px ${-Math.round(right)}px ${-Math.round(bottom)}px ${-Math.round(left)}px`;\n}\n\n// src/utilities/threshold.ts\nvar threshold = [\n ...Array.from({ length: 1e3 }, (_, i) => i / 1e3),\n 1\n];\n\n// src/observers/PositionIntersectionObserver.ts\nvar PositionIntersectionObserver = class {\n constructor(element, callback, options) {\n this.#callback = callback;\n this.#options = options;\n this.#clientRect = options.clientRect;\n this.#observe(element);\n }\n #callback;\n #observer = void 0;\n #options;\n #clientRect;\n #previousIntersectionRatio = void 0;\n /**\n * The visible rectangle of the element within the root.\n *\n * @returns The visible rectangle of the element within the root.\n */\n get visibleRect() {\n const clip = this.#options.clip;\n return clip ? Rect.clip(this.#clientRect, clip) : this.#clientRect;\n }\n /**\n * Whether the element is intersecting with the root.\n *\n * @returns Whether the element is intersecting with the root.\n */\n get isIntersecting() {\n const { width, height } = this.visibleRect;\n return width > 0 && height > 0;\n }\n /**\n * Observes the element.\n */\n #observe(element) {\n const { root, rootBounds } = this.#options;\n const { visibleRect } = this;\n this.#observer?.disconnect();\n this.#observer = new IntersectionObserver(this.#onIntersection, {\n root,\n rootMargin: rootMargin(visibleRect, rootBounds),\n threshold\n });\n this.#observer.observe(element);\n }\n /**\n * The callback function for the intersection observer.\n */\n #onIntersection = (entries) => {\n if (!this.#observer) return;\n const entry = entries[entries.length - 1];\n if (entry) {\n const { intersectionRatio, boundingClientRect } = entry;\n const previousClientRect = this.#clientRect;\n this.#clientRect = boundingClientRect;\n const previousIntersectionRatio = this.#previousIntersectionRatio;\n const clientRectChanged = !Rect.equals(\n boundingClientRect,\n previousClientRect\n );\n if (intersectionRatio !== this.#previousIntersectionRatio || clientRectChanged) {\n const rootBounds = this.#options.rootBounds;\n const rootIntersection = Rect.intersect(boundingClientRect, rootBounds);\n const isIntersecting = rootIntersection.width > 0 && rootIntersection.height > 0;\n if (!isIntersecting) {\n return;\n }\n this.#previousIntersectionRatio = intersectionRatio;\n if (previousIntersectionRatio != null || clientRectChanged) {\n this.#callback(\n new PositionIntersectionObserverEntry(\n entry.target,\n boundingClientRect,\n entry.intersectionRect,\n isIntersecting,\n rootBounds\n ),\n this\n );\n this.#observe(entry.target);\n }\n }\n }\n };\n /**\n * Disconnects the position intersection observer.\n */\n disconnect() {\n this.#observer?.disconnect();\n }\n};\nvar PositionIntersectionObserverEntry = class {\n constructor(target, boundingClientRect, intersectionRect, isIntersecting, rootBounds) {\n this.target = target;\n this.boundingClientRect = boundingClientRect;\n this.intersectionRect = intersectionRect;\n this.isIntersecting = isIntersecting;\n this.rootBounds = rootBounds;\n }\n};\n\n// src/observers/RootBoundsObserver.ts\nvar RootBoundsObserver = class {\n /**\n * Creates a new root bounds observer.\n *\n * @param root - The root element to observe.\n * @param callback - The callback function to call when the root bounds change.\n */\n constructor(target, callback) {\n const root = getRoot(target);\n if (isElement(root)) {\n const ownerDocument = root.ownerDocument ?? document;\n this.rootBounds = root.getBoundingClientRect();\n this.#resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const [{ inlineSize: width, blockSize: height }] = entry.borderBoxSize;\n if (Rect.sizeEqual(this.rootBounds, { width, height })) {\n continue;\n }\n const rect = entry.target.getBoundingClientRect();\n this.rootBounds = rect;\n callback(rect, this);\n }\n });\n this.#resizeObserver.observe(root);\n ownerDocument.addEventListener(\n \"scroll\",\n (event) => {\n if (event.target && event.target !== root && isNode(event.target) && event.target.contains(root)) {\n this.rootBounds = root.getBoundingClientRect();\n callback(this.rootBounds, this);\n }\n },\n { capture: true, passive: true, signal: this.#controller.signal }\n );\n } else {\n const viewport = root.visualViewport ?? root;\n this.rootBounds = getWindowRect(root);\n const handleResize = () => {\n const rect = getWindowRect(root);\n if (Rect.equals(this.rootBounds, rect)) return;\n this.rootBounds = rect;\n callback(rect, this);\n };\n viewport.addEventListener(\"resize\", handleResize, {\n signal: this.#controller.signal\n });\n }\n }\n /**\n * The resize observer if the root is an element.\n */\n #resizeObserver;\n /**\n * The controller to disconnect the root bounds resize and scroll listeners.\n */\n #controller = new AbortController();\n /**\n * The bounds of the root element.\n */\n rootBounds;\n /**\n * Disconnects the root bounds observer.\n */\n disconnect() {\n this.#resizeObserver?.disconnect();\n this.#controller.abort();\n }\n};\nfunction getWindowRect(window2) {\n const width = window2.visualViewport?.width ?? window2.innerWidth;\n const height = window2.visualViewport?.height ?? window2.innerHeight;\n return new DOMRect(0, 0, width, height);\n}\nfunction isNode(target) {\n return \"nodeType\" in target;\n}\nfunction isElement(target) {\n return isNode(target) && target.nodeType === Node.ELEMENT_NODE;\n}\nfunction isDocument(root) {\n return root.nodeType === Node.DOCUMENT_NODE;\n}\nfunction getRoot(target) {\n return !target || isDocument(target) ? target?.defaultView ?? window : target;\n}\n\n// src/observers/VisibilityObserver.ts\nvar VisibilityObserver = class {\n constructor(callback, options) {\n this.#options = options;\n this.#callback = (entries) => {\n const changedEntries = [];\n for (const entry of entries) {\n const previousIntersection = this.intersections.get(entry.target);\n this.intersections.set(entry.target, entry);\n if (previousIntersection?.isIntersecting !== entry.isIntersecting || !Rect.equals(\n previousIntersection?.intersectionRect,\n entry.intersectionRect\n )) {\n changedEntries.push(entry);\n }\n }\n if (changedEntries.length > 0) {\n callback(changedEntries, this);\n }\n };\n }\n /**\n * The callback function to be invoked when the intersection entries change.\n */\n #callback;\n /**\n * The visibility observer for each document.\n */\n #observers = /* @__PURE__ */ new Map();\n /**\n * The options for the visibility observer.\n */\n #options;\n /**\n * The latest intersection entries for the observed elements.\n */\n intersections = /* @__PURE__ */ new WeakMap();\n /**\n * Observes an element.\n *\n * @param element - The element to observe.\n */\n observe(element) {\n const document2 = element.ownerDocument;\n if (!document2) return;\n let observer = this.#observers.get(document2);\n if (!observer) {\n observer = new IntersectionObserver(this.#callback, {\n ...this.#options,\n threshold\n });\n this.#observers.set(document2, observer);\n }\n observer.observe(element);\n }\n /**\n * Unobserves an element.\n *\n * @param element - The element to unobserve.\n */\n unobserve(element) {\n const document2 = element.ownerDocument;\n if (!document2) return;\n const observer = this.#observers.get(document2);\n if (!observer) return;\n observer.unobserve(element);\n this.intersections.delete(element);\n }\n /**\n * Disconnects the visibility observer.\n */\n disconnect() {\n for (const observer of this.#observers.values()) {\n observer.disconnect();\n }\n this.#observers.clear();\n }\n};\n\n// src/PositionObserver.ts\nvar PositionObserver = class {\n constructor(callback, options) {\n this.#callback = callback;\n this.#options = options;\n this.#rootBoundsObserver = new RootBoundsObserver(\n options?.root,\n this.#onRootBoundsChange\n );\n this.#visibilityObserver = new VisibilityObserver(\n this.#onVisibilityChange,\n options\n );\n this.#resizeObserver = new ResizeObserver(this.#onResize);\n }\n /**\n * The callback function to be invoked when the position changes.\n */\n #callback;\n /**\n * The options for the position observer.\n */\n #options;\n /**\n * The position observers for the observed elements.\n */\n #positionObservers = /* @__PURE__ */ new Map();\n /**\n * The resize observer for the observed elements.\n */\n #resizeObserver;\n /**\n * The positions of the observed elements.\n */\n #positions = /* @__PURE__ */ new WeakMap();\n /**\n * The root bounds observer for the observed elements.\n */\n #rootBoundsObserver;\n /**\n * The visibility observer for the observed elements.\n */\n #visibilityObserver;\n /**\n * Observes an element.\n *\n * @param element - The element to observe.\n */\n observe(element) {\n this.#visibilityObserver.observe(element);\n }\n /**\n * Unobserves an element.\n *\n * @param element - The element to unobserve. If not provided, the position observer is disconnected.\n */\n unobserve(element) {\n if (element) {\n this.#positionObservers.get(element)?.disconnect();\n this.#visibilityObserver.unobserve(element);\n } else {\n this.disconnect();\n }\n }\n /**\n * Disconnects the observer.\n */\n disconnect() {\n for (const positionObserver of this.#positionObservers.values()) {\n positionObserver.disconnect();\n }\n this.#resizeObserver.disconnect();\n this.#rootBoundsObserver.disconnect();\n this.#visibilityObserver.disconnect();\n }\n /**\n * Notifies the position observer of the changes.\n *\n * @param entries - The entries to notify.\n */\n #notify(entries) {\n const records = [];\n for (const entry of entries) {\n const { target } = entry;\n const previousEntry = this.#positions.get(target);\n if (isEntryEqual(entry, previousEntry)) continue;\n this.#positions.set(target, entry);\n records.push(entry);\n }\n if (records.length > 0) {\n this.#callback(records);\n }\n }\n /**\n * The callback function to be invoked when the root bounds change.\n */\n #onRootBoundsChange = (rootBounds) => {\n const entries = [];\n for (const [element] of this.#positionObservers) {\n const boundingClientRect = element.getBoundingClientRect();\n const observer = this.#observePosition(element, boundingClientRect);\n entries.push(\n new PositionObserverEntry(\n element,\n boundingClientRect,\n observer.visibleRect,\n observer.isIntersecting,\n rootBounds\n )\n );\n }\n this.#notify(entries);\n };\n /**\n * Observes the position of an element.\n *\n * @param element - The element to observe.\n * @param clientRect - The client rect of the element.\n */\n #observePosition(element, clientRect) {\n const visibilityObserver = this.#visibilityObserver;\n this.#positionObservers.get(element)?.disconnect();\n const positionObserver = new PositionIntersectionObserver(\n element,\n this.#onPositionChange,\n {\n clientRect,\n root: this.#options?.root,\n rootBounds: this.#rootBoundsObserver.rootBounds,\n get clip() {\n const intersection = visibilityObserver.intersections.get(element);\n if (!intersection) return;\n const { intersectionRect, boundingClientRect } = intersection;\n return Rect.clipOffsets(boundingClientRect, intersectionRect);\n }\n }\n );\n this.#positionObservers.set(element, positionObserver);\n return positionObserver;\n }\n /**\n * The callback function to be invoked when the visibility changes.\n */\n #onVisibilityChange = (entries) => {\n const records = [];\n for (const entry of entries) {\n const { target, isIntersecting, boundingClientRect } = entry;\n if (isIntersecting) {\n this.#observePosition(target, boundingClientRect);\n this.#resizeObserver.observe(target);\n } else {\n this.#positionObservers.get(target)?.disconnect();\n this.#positionObservers.delete(target);\n this.#resizeObserver.unobserve(target);\n }\n const observer = this.#positionObservers.get(target);\n records.push(\n new PositionObserverEntry(\n target,\n boundingClientRect,\n observer?.visibleRect ?? entry.intersectionRect,\n isIntersecting,\n this.#rootBoundsObserver.rootBounds\n )\n );\n }\n this.#notify(records);\n };\n /**\n * The callback function to be invoked when the position changes.\n */\n #onPositionChange = (entry, observer) => {\n this.#notify([\n new PositionObserverEntry(\n entry.target,\n entry.boundingClientRect,\n observer.visibleRect,\n entry.isIntersecting,\n this.#rootBoundsObserver.rootBounds\n )\n ]);\n };\n /**\n * The callback function to be invoked when the resize observer entries change.\n */\n #onResize = (entries) => {\n const records = [];\n for (const entry of entries) {\n const { target, borderBoxSize } = entry;\n const previous = this.#positions.get(target);\n if (previous) {\n const [{ inlineSize: width, blockSize: height }] = borderBoxSize;\n if (Rect.sizeEqual(previous.boundingClientRect, { width, height })) {\n continue;\n }\n }\n const boundingClientRect = target.getBoundingClientRect();\n const observer = this.#observePosition(target, boundingClientRect);\n records.push(\n new PositionObserverEntry(\n target,\n boundingClientRect,\n observer.visibleRect,\n this.#visibilityObserver.intersections.get(target)?.isIntersecting ?? false,\n this.#rootBoundsObserver.rootBounds\n )\n );\n }\n this.#notify(records);\n };\n};\nvar PositionObserverEntry = class {\n constructor(target, boundingClientRect, intersectionRect, isIntersecting, rootBounds) {\n this.target = target;\n this.boundingClientRect = boundingClientRect;\n this.intersectionRect = intersectionRect;\n this.isIntersecting = isIntersecting;\n this.rootBounds = rootBounds;\n }\n};\nfunction isEntryEqual(first, second) {\n if (second == null) return false;\n return first.target === second.target && first.isIntersecting === second.isIntersecting && Rect.equals(first.boundingClientRect, second.boundingClientRect) && Rect.equals(first.intersectionRect, second.intersectionRect);\n}\nexport {\n PositionObserver,\n PositionObserverEntry\n};\n//# sourceMappingURL=index.js.map","type ShouldRegister = {\r\n shouldRegister: boolean\r\n isTouchDevice: boolean\r\n isLimitedConnection: boolean\r\n}\r\n\r\nexport function evaluateRegistrationConditions(): ShouldRegister {\r\n const isTouchDevice = userUsesTouchDevice()\r\n console.log(isTouchDevice)\r\n const isLimitedConnection = hasConnectionLimitations()\r\n const shouldRegister = !isTouchDevice && !isLimitedConnection\r\n return { isTouchDevice, isLimitedConnection, shouldRegister }\r\n}\r\n\r\n/**\r\n * Detects if the current device is likely a touch-enabled device.\r\n * It checks for coarse pointer media query and the presence of touch points.\r\n *\r\n * @returns `true` if the device is likely touch-enabled, `false` otherwise.\r\n */\r\nfunction userUsesTouchDevice(): boolean {\r\n return window.matchMedia(\"(pointer: coarse)\").matches && navigator.maxTouchPoints > 0\r\n}\r\n\r\n/**\r\n * Checks if the user has connection limitations (slow network or data saver enabled).\r\n *\r\n * @returns {boolean} True if connection is limited, false if safe to prefetch\r\n * @example\r\n * if (!hasConnectionLimitations()) {\r\n * prefetchResource('/api/data');\r\n * }\r\n */\r\nfunction hasConnectionLimitations(): boolean {\r\n const connection = (navigator as any).connection\r\n if (!connection) return false\r\n\r\n return /2g/.test(connection.effectiveType) || connection.saveData\r\n}\r\n","import { ForesightManager } from \"../Manager/ForesightManager\"\r\nimport { DebuggerControlPanel } from \"./DebuggerControlPanel\"\r\nimport type {\r\n ForesightElementData,\r\n ForesightElement,\r\n TrajectoryPositions,\r\n ForesightManagerSettings,\r\n Point,\r\n HitSlop,\r\n} from \"../types/types\"\r\nimport { createAndAppendElement, createAndAppendStyle } from \"./helpers/createAndAppend\"\r\nimport { updateElementOverlays } from \"./helpers/updateElementOverlays\"\r\nimport { removeOldDebuggers } from \"./helpers/removeOldDebuggers\"\r\nimport { DEFAULT_SHOW_NAME_TAGS } from \"../Manager/constants\"\r\nimport { PositionObserver, type PositionObserverEntry } from \"position-observer\"\r\nimport { evaluateRegistrationConditions } from \"../helpers/shouldRegister\"\r\n\r\nexport type ElementOverlays = {\r\n expandedOverlay: HTMLElement\r\n nameLabel: HTMLElement\r\n}\r\n\r\ntype callbackAnimation = {\r\n hitSlop: Exclude<HitSlop, number>\r\n overlay: HTMLElement\r\n timeoutId: ReturnType<typeof setTimeout>\r\n}\r\nexport class ForesightDebugger {\r\n private static debuggerInstance: ForesightDebugger\r\n private callbackAnimations: Map<Element, callbackAnimation> = new Map()\r\n private foresightManagerInstance: ForesightManager\r\n private shadowHost!: HTMLElement\r\n private shadowRoot!: ShadowRoot\r\n private debugContainer!: HTMLElement\r\n private controlPanel!: DebuggerControlPanel\r\n\r\n private debugElementOverlays: Map<ForesightElement, ElementOverlays> = new Map()\r\n private predictedMouseIndicator: HTMLElement | null = null\r\n private mouseTrajectoryLine: HTMLElement | null = null\r\n private scrollTrajectoryLine: HTMLElement | null = null\r\n\r\n private constructor(foresightManager: ForesightManager) {\r\n this.foresightManagerInstance = foresightManager\r\n }\r\n private animationPositionObserver: PositionObserver | null = null\r\n\r\n private _setupDOM() {\r\n // If for some reason we call this on an already-setup instance, do nothing.\r\n if (this.shadowHost) {\r\n return\r\n }\r\n\r\n this.shadowHost = createAndAppendElement(\"div\", document.body, {\r\n id: \"jsforesight-debugger-shadow-host\",\r\n })\r\n this.shadowRoot = this.shadowHost.attachShadow({ mode: \"open\" })\r\n this.debugContainer = createAndAppendElement(\"div\", this.shadowRoot, {\r\n id: \"jsforesight-debug-container\",\r\n })\r\n this.predictedMouseIndicator = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-mouse-predicted\",\r\n })\r\n this.mouseTrajectoryLine = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-trajectory-line\",\r\n })\r\n this.scrollTrajectoryLine = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-scroll-trajectory-line\",\r\n })\r\n this.controlPanel = DebuggerControlPanel.initialize(\r\n this.foresightManagerInstance,\r\n this.shadowRoot,\r\n this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings\r\n )\r\n createAndAppendStyle(debuggerCSS, this.shadowRoot, \"screen-visuals\")\r\n\r\n this.animationPositionObserver = new PositionObserver(this.handleAnimationPositionChange)\r\n }\r\n\r\n private handleAnimationPositionChange = (entries: PositionObserverEntry[]) => {\r\n for (const entry of entries) {\r\n const animationData = this.callbackAnimations.get(entry.target)\r\n if (animationData) {\r\n const rect = entry.boundingClientRect\r\n const { hitSlop, overlay } = animationData\r\n\r\n const newLeft = rect.left - hitSlop.left\r\n const newTop = rect.top - hitSlop.top\r\n const newWidth = rect.width + hitSlop.left + hitSlop.right\r\n const newHeight = rect.height + hitSlop.top + hitSlop.bottom\r\n\r\n overlay.style.transform = `translate3d(${newLeft}px, ${newTop}px, 0)`\r\n overlay.style.width = `${newWidth}px`\r\n overlay.style.height = `${newHeight}px`\r\n }\r\n }\r\n }\r\n\r\n private static get isInitiated(): boolean {\r\n return !!ForesightDebugger.debuggerInstance\r\n }\r\n\r\n public static initialize(\r\n foresightManager: ForesightManager,\r\n trajectoryPositions: TrajectoryPositions\r\n ): ForesightDebugger | null {\r\n removeOldDebuggers()\r\n if (typeof window === \"undefined\" || !evaluateRegistrationConditions().shouldRegister) {\r\n return null\r\n }\r\n\r\n if (!ForesightDebugger.isInitiated) {\r\n ForesightDebugger.debuggerInstance = new ForesightDebugger(foresightManager)\r\n }\r\n\r\n const instance = ForesightDebugger.debuggerInstance\r\n\r\n if (!instance.shadowHost) {\r\n instance._setupDOM()\r\n }\r\n\r\n instance.updateMouseTrajectoryVisuals(\r\n trajectoryPositions,\r\n foresightManager.getManagerData.globalSettings.enableMousePrediction\r\n )\r\n\r\n return instance\r\n }\r\n\r\n private createElementOverlays(elementData: ForesightElementData) {\r\n const expandedOverlay = createAndAppendElement(\"div\", this.debugContainer!, {\r\n className: \"jsforesight-expanded-overlay\",\r\n data: elementData.name,\r\n })\r\n const nameLabel = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-name-label\",\r\n })\r\n const overlays = { expandedOverlay, nameLabel }\r\n this.debugElementOverlays.set(elementData.element, overlays)\r\n return overlays\r\n }\r\n\r\n public createOrUpdateElementOverlay(newData: ForesightElementData) {\r\n if (!this.debugContainer || !this.shadowRoot) return\r\n\r\n let overlays = this.debugElementOverlays.get(newData.element)\r\n if (!overlays) {\r\n overlays = this.createElementOverlays(newData)\r\n }\r\n\r\n updateElementOverlays(\r\n overlays,\r\n newData,\r\n this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags ??\r\n DEFAULT_SHOW_NAME_TAGS\r\n )\r\n }\r\n\r\n public toggleNameTagVisibility() {\r\n this.foresightManagerInstance.registeredElements.forEach((elementData) => {\r\n const overlays = this.debugElementOverlays.get(elementData.element)\r\n if (!overlays) return\r\n updateElementOverlays(\r\n overlays,\r\n elementData,\r\n this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags ??\r\n DEFAULT_SHOW_NAME_TAGS\r\n )\r\n })\r\n }\r\n\r\n /**\r\n * Removes all debug overlays and data associated with an element.\r\n *\r\n * This method cleans up the link overlay, expanded overlay, and name label\r\n * for the specified element, removes it from internal tracking maps, and\r\n * refreshes the control panel's element list to reflect the removal.\r\n *\r\n * @param element - The ForesightElement to remove from debugging visualization\r\n */\r\n public removeElement(elementData: ForesightElementData) {\r\n this.removeElementOverlay(elementData)\r\n this.controlPanel?.removeElementFromList(elementData)\r\n }\r\n\r\n public removeElementOverlay(elementData: ForesightElementData) {\r\n const overlays = this.debugElementOverlays.get(elementData.element)\r\n if (overlays) {\r\n overlays.expandedOverlay.remove()\r\n overlays.nameLabel.remove()\r\n this.debugElementOverlays.delete(elementData.element)\r\n }\r\n }\r\n\r\n public addElement(elementData: ForesightElementData, sort: boolean = true) {\r\n this.createOrUpdateElementOverlay(elementData)\r\n this.controlPanel.addElementToList(elementData, sort)\r\n }\r\n\r\n public updateMouseTrajectoryVisuals(\r\n trajectoryPositions: TrajectoryPositions,\r\n enableMousePrediction: boolean\r\n ) {\r\n if (!this.shadowRoot || !this.debugContainer) {\r\n return\r\n }\r\n if (!this.predictedMouseIndicator || !this.mouseTrajectoryLine) {\r\n return\r\n }\r\n const { predictedPoint, currentPoint } = trajectoryPositions\r\n\r\n // Use transform for positioning to avoid layout reflow.\r\n // The CSS handles centering the element with `translate(-50%, -50%)`.\r\n this.predictedMouseIndicator.style.transform = `translate3d(${predictedPoint.x}px, ${predictedPoint.y}px, 0) translate3d(-50%, -50%, 0)`\r\n this.predictedMouseIndicator.style.display = enableMousePrediction ? \"block\" : \"none\"\r\n\r\n // This hides the circle from the UI at the top-left corner when refreshing the page with the cursor outside of the window\r\n if (predictedPoint.x === 0 && predictedPoint.y === 0) {\r\n this.predictedMouseIndicator.style.display = \"none\"\r\n return\r\n }\r\n\r\n if (!enableMousePrediction) {\r\n this.mouseTrajectoryLine.style.display = \"none\"\r\n return\r\n }\r\n\r\n const dx = predictedPoint.x - currentPoint.x\r\n const dy = predictedPoint.y - currentPoint.y\r\n\r\n const length = Math.sqrt(dx * dx + dy * dy)\r\n const angle = (Math.atan2(dy, dx) * 180) / Math.PI\r\n\r\n // Use a single transform to position, rotate, and scale the line,\r\n // avoiding reflow from top/left changes.\r\n this.mouseTrajectoryLine.style.transform = `translate3d(${currentPoint.x}px, ${currentPoint.y}px, 0) rotate(${angle}deg)`\r\n this.mouseTrajectoryLine.style.width = `${length}px`\r\n this.mouseTrajectoryLine.style.display = \"block\"\r\n }\r\n\r\n public updateScrollTrajectoryVisuals(currentPoint: Point, predictedScrollPoint: Point) {\r\n if (!this.scrollTrajectoryLine) return\r\n const dx = predictedScrollPoint.x - currentPoint.x\r\n const dy = predictedScrollPoint.y - currentPoint.y\r\n\r\n const length = Math.sqrt(dx * dx + dy * dy)\r\n const angle = (Math.atan2(dy, dx) * 180) / Math.PI\r\n\r\n this.scrollTrajectoryLine.style.transform = `translate3d(${currentPoint.x}px, ${currentPoint.y}px, 0) rotate(${angle}deg)`\r\n this.scrollTrajectoryLine.style.width = `${length}px`\r\n this.scrollTrajectoryLine.style.display = \"block\"\r\n }\r\n\r\n public hideScrollTrajectoryVisuals() {\r\n if (this.scrollTrajectoryLine) {\r\n this.scrollTrajectoryLine.style.display = \"none\"\r\n }\r\n }\r\n\r\n public updateControlsState(settings: ForesightManagerSettings) {\r\n this.controlPanel?.updateControlsState(settings)\r\n }\r\n\r\n public updateElementVisibilityStatus(elementData: ForesightElementData) {\r\n this.controlPanel?.updateElementVisibilityStatus(elementData)\r\n }\r\n\r\n public removeElementFromList(elementData: ForesightElementData) {\r\n this.controlPanel?.removeElementFromList(elementData)\r\n }\r\n\r\n public showCallbackAnimation(elementData: ForesightElementData) {\r\n const { element, elementBounds } = elementData\r\n const existingAnimation = this.callbackAnimations.get(element)\r\n\r\n // If an animation is already running for this element, reset it\r\n if (existingAnimation) {\r\n clearTimeout(existingAnimation.timeoutId)\r\n existingAnimation.overlay.remove()\r\n this.animationPositionObserver?.unobserve(element)\r\n this.callbackAnimations.delete(element)\r\n }\r\n\r\n const animationOverlay = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-callback-indicator\",\r\n })\r\n\r\n const { left, top, right, bottom } = elementBounds.expandedRect\r\n const width = right - left\r\n const height = bottom - top\r\n\r\n animationOverlay.style.display = \"block\"\r\n animationOverlay.style.transform = `translate3d(${left}px, ${top}px, 0)`\r\n animationOverlay.style.width = `${width}px`\r\n animationOverlay.style.height = `${height}px`\r\n\r\n animationOverlay.classList.add(\"animate\")\r\n\r\n const animationDuration = 500\r\n\r\n const timeoutId = setTimeout(() => {\r\n animationOverlay.remove()\r\n this.callbackAnimations.delete(element)\r\n this.animationPositionObserver?.unobserve(element)\r\n }, animationDuration)\r\n\r\n this.callbackAnimations.set(element, {\r\n hitSlop: elementData.elementBounds.hitSlop,\r\n overlay: animationOverlay,\r\n timeoutId: timeoutId,\r\n })\r\n\r\n this.animationPositionObserver?.observe(element)\r\n }\r\n\r\n public cleanup() {\r\n this.controlPanel?.cleanup()\r\n this.shadowHost?.remove()\r\n this.debugElementOverlays.clear()\r\n this.shadowHost = null!\r\n this.shadowRoot = null!\r\n this.debugContainer = null!\r\n this.predictedMouseIndicator = null\r\n this.mouseTrajectoryLine = null\r\n this.scrollTrajectoryLine = null\r\n this.controlPanel = null!\r\n }\r\n}\r\n\r\nconst debuggerCSS = `\r\n #jsforesight-debug-container { \r\n position: fixed; top: 0; left: 0; width: 100%; height: 100%;\r\n pointer-events: none; z-index: 9999;\r\n }\r\n\r\n .jsforesight-expanded-overlay, \r\n .jsforesight-name-label, \r\n .jsforesight-callback-indicator,\r\n .jsforesight-mouse-predicted,\r\n .jsforesight-scroll-trajectory-line,\r\n .jsforesight-trajectory-line {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n will-change: transform; \r\n }\r\n .jsforesight-expanded-overlay {\r\n border: 1px dashed rgba(100, 116, 139, 0.4);\r\n background-color: rgba(100, 116, 139, 0.05);\r\n box-sizing: border-box;\r\n border-radius: 8px;\r\n }\r\n .jsforesight-mouse-predicted {\r\n width: 20px;\r\n height: 20px;\r\n border-radius: 50%;\r\n border: 2px solid #6b98e1;\r\n background-color: rgba(176, 196, 222, 0.3);\r\n z-index: 10000;\r\n /* transform is now set dynamically via JS for performance */\r\n }\r\n .jsforesight-trajectory-line {\r\n height: 2px;\r\n background-color: #6b98e1;\r\n transform-origin: left center;\r\n z-index: 9999;\r\n border-radius: 1px;\r\n /* width and transform are set dynamically via JS for performance */\r\n }\r\n .jsforesight-name-label {\r\n background-color: rgba(27, 31, 35, 0.85);\r\n backdrop-filter: blur(4px);\r\n color: white;\r\n padding: 4px 8px;\r\n font-size: 11px;\r\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\";\r\n border-radius: 4px;\r\n z-index: 10001;\r\n white-space: nowrap;\r\n pointer-events: none;\r\n }\r\n .jsforesight-callback-indicator {\r\n border: 4px solid oklch(65% 0.22 280); \r\n border-radius: 8px;\r\n box-sizing: border-box;\r\n pointer-events: none;\r\n opacity: 0;\r\n z-index: 10002;\r\n display: none; \r\n }\r\n .jsforesight-callback-indicator.animate {\r\n animation: jsforesight-callback-pulse 0.5s ease-out forwards;\r\n }\r\n \r\n .jsforesight-scroll-trajectory-line {\r\n height: 2px;\r\n background: repeating-linear-gradient(\r\n 90deg,\r\n oklch(68% 0.18 145) 0px,\r\n oklch(68% 0.18 145) 6px,\r\n transparent 6px,\r\n transparent 10px\r\n );\r\n transform-origin: left center;\r\n z-index: 9999;\r\n border-radius: 1px;\r\n display: none;\r\n animation: scroll-dash-flow 1.8s linear infinite;\r\n position: relative;\r\n }\r\n\r\n .jsforesight-scroll-trajectory-line::after {\r\n content: '';\r\n position: absolute;\r\n right: -2px;\r\n top: 50%;\r\n transform: translateY(-50%);\r\n width: 6px;\r\n height: 6px;\r\n background: oklch(68% 0.18 145);\r\n border-radius: 50%;\r\n animation: scroll-escape-squeeze 2.2s ease-in-out infinite;\r\n }\r\n\r\n @keyframes scroll-dash-flow {\r\n 0% { background-position: 0px 0px; }\r\n 100% { background-position: 10px 0px; }\r\n }\r\n\r\n @keyframes scroll-escape-squeeze {\r\n 0%, 100% { \r\n transform: translateY(-50%) scale(1);\r\n right: -2px;\r\n }\r\n 25% {\r\n transform: translateY(-50%) scaleX(1.3) scaleY(0.7);\r\n right: -3px;\r\n }\r\n 50% {\r\n transform: translateY(-50%) scaleX(0.8) scaleY(1.2);\r\n right: -1px;\r\n }\r\n 75% {\r\n transform: translateY(-50%) scaleX(1.2) scaleY(0.8);\r\n right: -3px;\r\n }\r\n }\r\n\r\n \r\n @keyframes jsforesight-callback-pulse {\r\n 0% {\r\n opacity: 1;\r\n box-shadow: 0 0 15px oklch(65% 0.22 280 / 0.7);\r\n }\r\n 100% {\r\n opacity: 0;\r\n box-shadow: 0 0 25px oklch(65% 0.22 280 / 0);\r\n }\r\n }\r\n `\r\n","/**\r\n * removes stale debuggers that might have been left behind in the dom\r\n */\r\nexport function removeOldDebuggers() {\r\n const oldDebuggers = document.querySelectorAll(\"#jsforesight-debugger-shadow-host\")\r\n oldDebuggers.forEach((element) => element.remove())\r\n}\r\n","export function clampNumber(\r\n number: number,\r\n lowerBound: number,\r\n upperBound: number,\r\n isDebug: boolean,\r\n settingName: string\r\n) {\r\n if (isDebug) {\r\n if (number < lowerBound) {\r\n console.warn(\r\n `ForesightJS: \"${settingName}\" value ${number} is below minimum bound ${lowerBound}, clamping to ${lowerBound}`\r\n )\r\n } else if (number > upperBound) {\r\n console.warn(\r\n `ForesightJS: \"${settingName}\" value ${number} is above maximum bound ${upperBound}, clamping to ${upperBound}`\r\n )\r\n }\r\n }\r\n\r\n return Math.min(Math.max(number, lowerBound), upperBound)\r\n}\r\n","import type { Point, Rect } from \"../../types/types\"\r\n\r\n/**\r\n * Determines if a line segment intersects with a given rectangle.\r\n * This function implements the Liang-Barsky line clipping algorithm.\r\n *\r\n * @param p1 - The starting {@link Point} of the line segment.\r\n * @param p2 - The ending {@link Point} of the line segment.\r\n * @param rect - The {@link Rect} to check for intersection.\r\n * @returns `true` if the line segment intersects the rectangle, `false` otherwise.\r\n */\r\nexport function lineSegmentIntersectsRect(p1: Point, p2: Point, rect: Rect): boolean {\r\n let t0 = 0.0\r\n let t1 = 1.0\r\n const dx = p2.x - p1.x\r\n const dy = p2.y - p1.y\r\n\r\n const clipTest = (p: number, q: number): boolean => {\r\n if (p === 0) {\r\n // Line is parallel to this clipping edge\r\n if (q < 0) return false // Line is outside the clipping edge\r\n } else {\r\n const r = q / p\r\n if (p < 0) {\r\n // Line proceeds from outside to inside\r\n if (r > t1) return false // Line segment ends before crossing edge\r\n if (r > t0) t0 = r // Update entry point\r\n } else {\r\n // Line proceeds from inside to outside\r\n if (r < t0) return false // Line segment starts after crossing edge\r\n if (r < t1) t1 = r // Update exit point\r\n }\r\n }\r\n return true\r\n }\r\n\r\n // Clip against all four edges of the rectangle\r\n if (!clipTest(-dx, p1.x - rect.left)) return false // Left edge\r\n if (!clipTest(dx, rect.right - p1.x)) return false // Right edge\r\n if (!clipTest(-dy, p1.y - rect.top)) return false // Top edge\r\n if (!clipTest(dy, rect.bottom - p1.y)) return false // Bottom edge\r\n\r\n // If t0 <= t1, the line segment intersects the rectangle (or lies within it)\r\n return t0 <= t1\r\n}\r\n","import type { HitSlop, Point, Rect } from \"../../types/types\"\r\nimport { MAX_HITSLOP, MIN_HITSLOP } from \"../constants\"\r\nimport { clampNumber } from \"./clampNumber\"\r\n\r\n/**\r\n * Normalizes a `hitSlop` value into a {@link Rect} object.\r\n * If `hitSlop` is a number, it's applied uniformly to all sides (top, left, right, bottom).\r\n * If `hitSlop` is already a `Rect` object, it's returned as is.\r\n *\r\n * @param hitSlop - A number for uniform slop, or a {@link Rect} object for specific slop per side.\r\n * @returns A {@link Rect} object with `top`, `left`, `right`, and `bottom` properties.\r\n */\r\nexport function normalizeHitSlop(hitSlop: HitSlop, isDebug: boolean): Rect {\r\n if (typeof hitSlop === \"number\") {\r\n const clampedValue = clampNumber(hitSlop, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop\")\r\n return {\r\n top: clampedValue,\r\n left: clampedValue,\r\n right: clampedValue,\r\n bottom: clampedValue,\r\n }\r\n }\r\n\r\n return {\r\n top: clampNumber(hitSlop.top, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop - top\"),\r\n left: clampNumber(hitSlop.left, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop - left\"),\r\n right: clampNumber(hitSlop.right, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop - right\"),\r\n bottom: clampNumber(hitSlop.bottom, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop - bottom\"),\r\n }\r\n}\r\n\r\n/**\r\n * Calculates an expanded rectangle by applying a `hitSlop` to a base rectangle.\r\n * The `hitSlop` values define how much to extend each side of the `baseRect` outwards.\r\n *\r\n * @param baseRect - The original {@link Rect} or `DOMRect` to expand.\r\n * @param hitSlop - A {@link Rect} object defining how much to expand each side\r\n * (e.g., `hitSlop.left` expands the left boundary further to the left).\r\n * @returns A new {@link Rect} object representing the expanded area.\r\n */\r\nexport function getExpandedRect(baseRect: Rect | DOMRect, hitSlop: Rect): Rect {\r\n return {\r\n left: baseRect.left - hitSlop.left,\r\n right: baseRect.right + hitSlop.right,\r\n top: baseRect.top - hitSlop.top,\r\n bottom: baseRect.bottom + hitSlop.bottom,\r\n }\r\n}\r\n\r\n/**\r\n * Checks if two rectangle objects are equal by comparing their respective\r\n * `top`, `left`, `right`, and `bottom` properties.\r\n * Handles cases where one or both rects might be null or undefined.\r\n *\r\n * @param rect1 - The first {@link Rect} object to compare.\r\n * @param rect2 - The second {@link Rect} object to compare.\r\n * @returns `true` if the rectangles have identical dimensions or if both are null/undefined,\r\n * `false` otherwise.\r\n */\r\nexport function areRectsEqual(rect1: Rect, rect2: Rect): boolean {\r\n if (!rect1 || !rect2) return rect1 === rect2\r\n return (\r\n rect1.left === rect2.left &&\r\n rect1.right === rect2.right &&\r\n rect1.top === rect2.top &&\r\n rect1.bottom === rect2.bottom\r\n )\r\n}\r\n\r\nexport function isPointInRectangle(point: Point, rect: Rect): boolean {\r\n return (\r\n point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom\r\n )\r\n}\r\n","/**\r\n * Checks if a setting should be updated.\r\n * Returns true if the newValue is defined and different from the currentValue.\r\n * Uses a type predicate to narrow the type of newValue in the calling scope.\r\n *\r\n * @param newValue The potentially new value for the setting (can be undefined).\r\n * @param currentValue The current value of the setting.\r\n * @returns True if the setting should be updated, false otherwise.\r\n */\r\nexport function shouldUpdateSetting<T>(\r\n newValue: T | undefined,\r\n currentValue: T\r\n): newValue is NonNullable<T> {\r\n // NonNullable<T> ensures that if T itself could be undefined (e.g. T = number | undefined),\r\n // the predicate narrows to the non-undefined part (e.g. number).\r\n // If T is already non-nullable (e.g. T = number), it remains T (e.g. number).\r\n return newValue !== undefined && currentValue !== newValue\r\n}\r\n","import { tabbable, type FocusableElement } from \"tabbable\"\r\nimport { ForesightDebugger } from \"../Debugger/ForesightDebugger\"\r\nimport { evaluateRegistrationConditions } from \"../helpers/shouldRegister\"\r\nimport type {\r\n BooleanSettingKeys,\r\n CallbackHits,\r\n ForesightElement,\r\n ForesightElementData,\r\n ForesightManagerData,\r\n ForesightManagerSettings,\r\n ForesightRegisterOptions,\r\n ForesightRegisterResult,\r\n HitType,\r\n NumericSettingKeys,\r\n Point,\r\n ScrollDirection,\r\n TrajectoryPositions,\r\n UpdateForsightManagerSettings,\r\n} from \"../types/types\"\r\nimport {\r\n DEFAULT_ENABLE_MOUSE_PREDICTION,\r\n DEFAULT_ENABLE_SCROLL_PREDICTION,\r\n DEFAULT_ENABLE_TAB_PREDICTION,\r\n DEFAULT_HITSLOP,\r\n DEFAULT_IS_DEBUG,\r\n DEFAULT_IS_DEBUGGER_MINIMIZED,\r\n DEFAULT_POSITION_HISTORY_SIZE,\r\n DEFAULT_SCROLL_MARGIN,\r\n DEFAULT_SHOW_NAME_TAGS,\r\n DEFAULT_SORT_ELEMENT_LIST,\r\n DEFAULT_TAB_OFFSET,\r\n DEFAULT_TRAJECTORY_PREDICTION_TIME,\r\n MAX_POSITION_HISTORY_SIZE,\r\n MAX_SCROLL_MARGIN,\r\n MAX_TAB_OFFSET,\r\n MAX_TRAJECTORY_PREDICTION_TIME,\r\n MIN_POSITION_HISTORY_SIZE,\r\n MIN_SCROLL_MARGIN,\r\n MIN_TAB_OFFSET,\r\n MIN_TRAJECTORY_PREDICTION_TIME,\r\n} from \"./constants\"\r\nimport { clampNumber } from \"./helpers/clampNumber\"\r\nimport { lineSegmentIntersectsRect } from \"./helpers/lineSigmentIntersectsRect\"\r\nimport { predictNextMousePosition } from \"./helpers/predictNextMousePosition\"\r\nimport {\r\n areRectsEqual,\r\n getExpandedRect,\r\n isPointInRectangle,\r\n normalizeHitSlop,\r\n} from \"./helpers/rectAndHitSlop\"\r\nimport { shouldUpdateSetting } from \"./helpers/shouldUpdateSetting\"\r\n\r\nimport { getScrollDirection } from \"./helpers/getScrollDirection\"\r\nimport { predictNextScrollPosition } from \"./helpers/predictNextScrollPosition\"\r\nimport { getFocusedElementIndex } from \"./helpers/getFocusedElementIndex\"\r\nimport { PositionObserver, PositionObserverEntry } from \"position-observer\"\r\n\r\n/**\r\n * Manages the prediction of user intent based on mouse trajectory and element interactions.\r\n *\r\n * ForesightManager is a singleton class responsible for:\r\n * - Registering HTML elements to monitor.\r\n * - Tracking mouse movements and predicting future cursor positions.\r\n * - Detecting when a predicted trajectory intersects with a registered element's bounds.\r\n * - Invoking callbacks associated with elements upon predicted or actual interaction.\r\n * - Optionally unregistering elements after their callback is triggered.\r\n * - Handling global settings for prediction behavior (e.g., history size, prediction time).\r\n * - Optionally enabling a {@link ForesightDebugger} for visual feedback.\r\n * - Automatically updating element bounds on resize using {@link ResizeObserver}.\r\n * - Automatically unregistering elements removed from the DOM using {@link MutationObserver}.\r\n * - Detecting broader layout shifts via {@link MutationObserver} to update element positions.\r\n *\r\n * It should be initialized once using {@link ForesightManager.initialize} and then\r\n * accessed via the static getter {@link ForesightManager.instance}.\r\n */\r\n\r\nexport class ForesightManager {\r\n private static manager: ForesightManager\r\n private elements: Map<ForesightElement, ForesightElementData> = new Map()\r\n private isSetup: boolean = false\r\n private debugger: ForesightDebugger | null = null\r\n private _globalCallbackHits: CallbackHits = {\r\n mouse: {\r\n hover: 0,\r\n trajectory: 0,\r\n },\r\n tab: {\r\n forwards: 0,\r\n reverse: 0,\r\n },\r\n scroll: {\r\n down: 0,\r\n left: 0,\r\n right: 0,\r\n up: 0,\r\n },\r\n total: 0,\r\n }\r\n private _globalSettings: ForesightManagerSettings = {\r\n debug: DEFAULT_IS_DEBUG,\r\n enableMousePrediction: DEFAULT_ENABLE_MOUSE_PREDICTION,\r\n enableScrollPrediction: DEFAULT_ENABLE_SCROLL_PREDICTION,\r\n positionHistorySize: DEFAULT_POSITION_HISTORY_SIZE,\r\n trajectoryPredictionTime: DEFAULT_TRAJECTORY_PREDICTION_TIME,\r\n scrollMargin: DEFAULT_SCROLL_MARGIN,\r\n defaultHitSlop: {\r\n top: DEFAULT_HITSLOP,\r\n left: DEFAULT_HITSLOP,\r\n right: DEFAULT_HITSLOP,\r\n bottom: DEFAULT_HITSLOP,\r\n },\r\n resizeScrollThrottleDelay: 0,\r\n debuggerSettings: {\r\n isControlPanelDefaultMinimized: DEFAULT_IS_DEBUGGER_MINIMIZED,\r\n showNameTags: DEFAULT_SHOW_NAME_TAGS,\r\n sortElementList: DEFAULT_SORT_ELEMENT_LIST,\r\n },\r\n enableTabPrediction: DEFAULT_ENABLE_TAB_PREDICTION,\r\n tabOffset: DEFAULT_TAB_OFFSET,\r\n onAnyCallbackFired: (\r\n _elementData: ForesightElementData,\r\n _managerData: ForesightManagerData\r\n ) => {},\r\n }\r\n private trajectoryPositions: TrajectoryPositions = {\r\n positions: [],\r\n currentPoint: { x: 0, y: 0 },\r\n predictedPoint: { x: 0, y: 0 },\r\n }\r\n\r\n private tabbableElementsCache: FocusableElement[] = []\r\n private lastFocusedIndex: number | null = null\r\n\r\n private predictedScrollPoint: Point | null = null\r\n private scrollDirection: ScrollDirection | null = null\r\n private domObserver: MutationObserver | null = null\r\n private positionObserver: PositionObserver | null = null\r\n // Track the last keydown event to determine if focus change was due to Tab\r\n private lastKeyDown: KeyboardEvent | null = null\r\n\r\n // AbortController for managing global event listeners\r\n private globalListenersController: AbortController | null = null\r\n\r\n // Never put something in the constructor, use initialize instead\r\n private constructor() {}\r\n\r\n public static initialize(props?: Partial<UpdateForsightManagerSettings>): ForesightManager {\r\n if (!this.isInitiated) {\r\n ForesightManager.manager = new ForesightManager()\r\n }\r\n if (props !== undefined) {\r\n ForesightManager.manager.alterGlobalSettings(props)\r\n }\r\n return ForesightManager.manager\r\n }\r\n\r\n public get getManagerData(): Readonly<ForesightManagerData> {\r\n return {\r\n registeredElements: this.elements,\r\n globalSettings: this._globalSettings,\r\n globalCallbackHits: this._globalCallbackHits,\r\n }\r\n }\r\n\r\n public static get isInitiated(): Readonly<boolean> {\r\n return !!ForesightManager.manager\r\n }\r\n\r\n public static get instance(): ForesightManager {\r\n return this.initialize()\r\n }\r\n\r\n public get registeredElements(): ReadonlyMap<ForesightElement, ForesightElementData> {\r\n return this.elements\r\n }\r\n\r\n public register({\r\n element,\r\n callback,\r\n hitSlop,\r\n unregisterOnCallback,\r\n name,\r\n }: ForesightRegisterOptions): ForesightRegisterResult {\r\n const { shouldRegister, isTouchDevice, isLimitedConnection } = evaluateRegistrationConditions()\r\n if (!shouldRegister) {\r\n return {\r\n isLimitedConnection,\r\n isTouchDevice,\r\n isRegistered: false,\r\n unregister: () => {},\r\n }\r\n }\r\n\r\n // Setup global listeners on every first element added to the manager. It gets removed again when the map is emptied\r\n if (!this.isSetup) {\r\n this.initializeGlobalListeners()\r\n }\r\n\r\n const normalizedHitSlop = hitSlop\r\n ? normalizeHitSlop(hitSlop, this._globalSettings.debug)\r\n : this._globalSettings.defaultHitSlop\r\n // const elementRect = element.getBoundingClientRect()\r\n const elementData: ForesightElementData = {\r\n element: element,\r\n callback,\r\n callbackHits: {\r\n mouse: {\r\n hover: 0,\r\n trajectory: 0,\r\n },\r\n tab: {\r\n forwards: 0,\r\n reverse: 0,\r\n },\r\n scroll: {\r\n down: 0,\r\n left: 0,\r\n right: 0,\r\n up: 0,\r\n },\r\n total: 0,\r\n },\r\n elementBounds: {\r\n originalRect: undefined,\r\n expandedRect: { top: 0, left: 0, right: 0, bottom: 0 },\r\n hitSlop: normalizedHitSlop,\r\n },\r\n isHovering: false,\r\n trajectoryHitData: {\r\n isTrajectoryHit: false,\r\n trajectoryHitTime: 0,\r\n trajectoryHitExpirationTimeoutId: undefined,\r\n },\r\n name: name ?? element.id ?? \"\",\r\n unregisterOnCallback: unregisterOnCallback ?? true,\r\n isIntersectingWithViewport: true,\r\n }\r\n\r\n this.elements.set(element, elementData)\r\n\r\n this.positionObserver?.observe(element)\r\n\r\n if (this.debugger) {\r\n this.debugger.addElement(elementData)\r\n }\r\n\r\n return {\r\n isTouchDevice,\r\n isLimitedConnection,\r\n isRegistered: true,\r\n unregister: () => this.unregister(element),\r\n }\r\n }\r\n\r\n private unregister(element: ForesightElement) {\r\n const isRegistered = this.elements.has(element)\r\n if (!isRegistered) {\r\n // The element is already unregistered by something else (e.g. after hitting callback)\r\n return\r\n }\r\n const foresightElementData = this.elements.get(element)\r\n\r\n // Clear any pending trajectory expiration timeout\r\n if (foresightElementData?.trajectoryHitData.trajectoryHitExpirationTimeoutId) {\r\n clearTimeout(foresightElementData.trajectoryHitData.trajectoryHitExpirationTimeoutId)\r\n }\r\n\r\n this.positionObserver?.unobserve(element)\r\n this.elements.delete(element)\r\n\r\n if (this.debugger && foresightElementData) {\r\n this.debugger.removeElement(foresightElementData)\r\n }\r\n\r\n if (this.elements.size === 0 && this.isSetup) {\r\n this.removeGlobalListeners()\r\n }\r\n }\r\n\r\n private updateNumericSettings(\r\n newValue: number | undefined,\r\n setting: NumericSettingKeys,\r\n min: number,\r\n max: number\r\n ) {\r\n if (!shouldUpdateSetting(newValue, this._globalSettings[setting])) {\r\n return false\r\n }\r\n\r\n this._globalSettings[setting] = clampNumber(\r\n newValue,\r\n min,\r\n max,\r\n this._globalSettings.debug,\r\n setting\r\n )\r\n\r\n return true\r\n }\r\n\r\n private updateBooleanSetting(\r\n newValue: boolean | undefined,\r\n setting: BooleanSettingKeys\r\n ): boolean {\r\n if (!shouldUpdateSetting(newValue, this._globalSettings[setting])) {\r\n return false\r\n }\r\n this._globalSettings[setting] = newValue\r\n return true\r\n }\r\n\r\n public alterGlobalSettings(props?: Partial<UpdateForsightManagerSettings>): void {\r\n // Call each update function and store whether it made a change.\r\n // This ensures every update function is executed.\r\n const oldPositionHistorySize = this._globalSettings.positionHistorySize\r\n const positionHistoryChanged = this.updateNumericSettings(\r\n props?.positionHistorySize,\r\n \"positionHistorySize\",\r\n MIN_POSITION_HISTORY_SIZE,\r\n MAX_POSITION_HISTORY_SIZE\r\n )\r\n\r\n if (\r\n positionHistoryChanged &&\r\n this._globalSettings.positionHistorySize < oldPositionHistorySize\r\n ) {\r\n if (this.trajectoryPositions.positions.length > this._globalSettings.positionHistorySize) {\r\n this.trajectoryPositions.positions = this.trajectoryPositions.positions.slice(\r\n this.trajectoryPositions.positions.length - this._globalSettings.positionHistorySize\r\n )\r\n }\r\n }\r\n\r\n const trajectoryTimeChanged = this.updateNumericSettings(\r\n props?.trajectoryPredictionTime,\r\n \"trajectoryPredictionTime\",\r\n MIN_TRAJECTORY_PREDICTION_TIME,\r\n MAX_TRAJECTORY_PREDICTION_TIME\r\n )\r\n\r\n const scrollMarginChanged = this.updateNumericSettings(\r\n props?.scrollMargin,\r\n \"scrollMargin\",\r\n MIN_SCROLL_MARGIN,\r\n MAX_SCROLL_MARGIN\r\n )\r\n\r\n const tabOffsetChanged = this.updateNumericSettings(\r\n props?.tabOffset,\r\n \"tabOffset\",\r\n MIN_TAB_OFFSET,\r\n MAX_TAB_OFFSET\r\n )\r\n\r\n if (props?.resizeScrollThrottleDelay !== undefined) {\r\n console.warn(\r\n \"resizeScrollThrottleDelay is deprecated and will be removed in V3.0.0 of ForesightJS\"\r\n )\r\n }\r\n\r\n const mousePredictionChanged = this.updateBooleanSetting(\r\n props?.enableMousePrediction,\r\n \"enableMousePrediction\"\r\n )\r\n\r\n const scrollPredictionChanged = this.updateBooleanSetting(\r\n props?.enableScrollPrediction,\r\n \"enableScrollPrediction\"\r\n )\r\n\r\n const tabPredictionChanged = this.updateBooleanSetting(\r\n props?.enableTabPrediction,\r\n \"enableTabPrediction\"\r\n )\r\n\r\n if (props?.onAnyCallbackFired !== undefined) {\r\n this._globalSettings.onAnyCallbackFired = props.onAnyCallbackFired\r\n }\r\n\r\n let debuggerSettingsChanged = false\r\n if (props?.debuggerSettings?.isControlPanelDefaultMinimized !== undefined) {\r\n this._globalSettings.debuggerSettings.isControlPanelDefaultMinimized =\r\n props.debuggerSettings.isControlPanelDefaultMinimized\r\n debuggerSettingsChanged = true\r\n }\r\n\r\n if (props?.debuggerSettings?.showNameTags !== undefined) {\r\n this._globalSettings.debuggerSettings.showNameTags = props.debuggerSettings.showNameTags\r\n debuggerSettingsChanged = true\r\n if (this.debugger) {\r\n this.debugger.toggleNameTagVisibility()\r\n }\r\n }\r\n\r\n if (props?.debuggerSettings?.sortElementList !== undefined) {\r\n this._globalSettings.debuggerSettings.sortElementList = props.debuggerSettings.sortElementList\r\n debuggerSettingsChanged = true\r\n if (this.debugger) {\r\n // this.debugger.()\r\n }\r\n }\r\n\r\n let hitSlopChanged = false\r\n if (props?.defaultHitSlop !== undefined) {\r\n const normalizedNewHitSlop = normalizeHitSlop(\r\n props.defaultHitSlop,\r\n this._globalSettings.debug\r\n )\r\n if (!areRectsEqual(this._globalSettings.defaultHitSlop, normalizedNewHitSlop)) {\r\n this._globalSettings.defaultHitSlop = normalizedNewHitSlop\r\n hitSlopChanged = true\r\n this.forceUpdateAllElementBounds()\r\n }\r\n }\r\n\r\n let debugModeChanged = false\r\n if (props?.debug !== undefined && this._globalSettings.debug !== props.debug) {\r\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\r\n this._globalSettings.debug = props.debug\r\n debugModeChanged = true\r\n if (this._globalSettings.debug) {\r\n this.turnOnDebugMode()\r\n } else {\r\n if (this.debugger) {\r\n this.debugger.cleanup()\r\n this.debugger = null\r\n }\r\n }\r\n }\r\n }\r\n\r\n const settingsActuallyChanged =\r\n positionHistoryChanged ||\r\n trajectoryTimeChanged ||\r\n tabOffsetChanged ||\r\n mousePredictionChanged ||\r\n tabPredictionChanged ||\r\n scrollPredictionChanged ||\r\n debuggerSettingsChanged ||\r\n hitSlopChanged ||\r\n scrollMarginChanged ||\r\n debugModeChanged\r\n\r\n if (settingsActuallyChanged && this.debugger) {\r\n this.debugger.updateControlsState(this._globalSettings)\r\n }\r\n }\r\n private turnOnDebugMode() {\r\n if (!this.debugger) {\r\n this.debugger = ForesightDebugger.initialize(\r\n ForesightManager.instance,\r\n this.trajectoryPositions\r\n )\r\n const elementsArray = Array.from(this.elements.values())\r\n elementsArray.forEach((elementData, index) => {\r\n const isLastElement = index === elementsArray.length - 1\r\n this.debugger?.addElement(elementData, isLastElement)\r\n })\r\n } else {\r\n this.debugger.updateControlsState(this._globalSettings)\r\n }\r\n }\r\n\r\n private forceUpdateAllElementBounds() {\r\n this.elements.forEach((_, element) => {\r\n const elementData = this.elements.get(element)\r\n // For performance only update rects that are currently intersecting with the viewport\r\n if (elementData && elementData.isIntersectingWithViewport) {\r\n this.forceUpdateElementBounds(elementData)\r\n }\r\n })\r\n }\r\n\r\n private updatePointerState(e: MouseEvent): void {\r\n this.trajectoryPositions.currentPoint = { x: e.clientX, y: e.clientY }\r\n this.trajectoryPositions.predictedPoint = this._globalSettings.enableMousePrediction\r\n ? predictNextMousePosition(\r\n this.trajectoryPositions.currentPoint,\r\n this.trajectoryPositions.positions, // History before the currentPoint was added\r\n this._globalSettings.positionHistorySize,\r\n this._globalSettings.trajectoryPredictionTime\r\n )\r\n : { ...this.trajectoryPositions.currentPoint }\r\n }\r\n\r\n /**\r\n * Processes elements that unregister after a single callback.\r\n *\r\n * This is a \"fire-and-forget\" handler. Its only goal is to trigger the\r\n * callback once. It does so if the mouse trajectory is predicted to hit the\r\n * element (if prediction is on) OR if the mouse physically hovers over it.\r\n * It does not track state, as the element is immediately unregistered.\r\n *\r\n * @param elementData - The data object for the foresight element.\r\n * @param element - The HTML element being interacted with.\r\n */\r\n private handleSingleCallbackInteraction(elementData: ForesightElementData) {\r\n const { expandedRect } = elementData.elementBounds\r\n\r\n // when enable mouse prediction is off, we only check if the mouse is physically hovering over the element\r\n if (!this._globalSettings.enableMousePrediction) {\r\n if (isPointInRectangle(this.trajectoryPositions.currentPoint, expandedRect)) {\r\n this.callCallback(elementData, { kind: \"mouse\", subType: \"hover\" })\r\n return\r\n }\r\n } else if (\r\n lineSegmentIntersectsRect(\r\n this.trajectoryPositions.currentPoint,\r\n this.trajectoryPositions.predictedPoint,\r\n expandedRect\r\n )\r\n ) {\r\n this.callCallback(elementData, { kind: \"mouse\", subType: \"trajectory\" })\r\n }\r\n }\r\n\r\n /**\r\n * Processes persistent elements that can have multiple callbacks and require state tracking.\r\n *\r\n * This handler is responsible for elements where `unregisterOnCallback` is false.\r\n * It triggers callbacks only on the \"leading edge\" of an interaction—that is,\r\n * the first moment the mouse enters an element or the first moment a trajectory\r\n * is predicted to hit it. This prevents the callback from firing on every\r\n * mouse move. It also manages the element's state (`isHovering`, `isTrajectoryHit`)\r\n * for visual feedback in the {@link ForesightDebugger}.\r\n *\r\n * @param elementData - The current data object for the foresight element.\r\n * @param element - The HTML element being interacted with.\r\n */\r\n private handleMultiCallbackInteraction(elementData: ForesightElementData) {\r\n const { expandedRect } = elementData.elementBounds\r\n const isHovering = isPointInRectangle(this.trajectoryPositions.currentPoint, expandedRect)\r\n\r\n const isNewPhysicalHover = isHovering && !elementData.isHovering\r\n const isNewTrajectoryHit =\r\n this._globalSettings.enableMousePrediction &&\r\n !isHovering &&\r\n !elementData.trajectoryHitData.isTrajectoryHit &&\r\n lineSegmentIntersectsRect(\r\n this.trajectoryPositions.currentPoint,\r\n this.trajectoryPositions.predictedPoint,\r\n expandedRect\r\n )\r\n\r\n if (isNewPhysicalHover || isNewTrajectoryHit) {\r\n this.callCallback(elementData, {\r\n kind: \"mouse\",\r\n subType: isNewPhysicalHover ? \"hover\" : \"trajectory\",\r\n })\r\n }\r\n\r\n const hasStateChanged = isHovering !== elementData.isHovering || isNewTrajectoryHit\r\n\r\n if (hasStateChanged) {\r\n const newElementData: ForesightElementData = {\r\n ...elementData,\r\n isHovering: isHovering,\r\n trajectoryHitData: {\r\n ...elementData.trajectoryHitData,\r\n isTrajectoryHit: isNewTrajectoryHit,\r\n trajectoryHitTime: isNewTrajectoryHit\r\n ? performance.now()\r\n : elementData.trajectoryHitData.trajectoryHitTime,\r\n },\r\n }\r\n if (isNewTrajectoryHit) {\r\n if (newElementData.trajectoryHitData.trajectoryHitExpirationTimeoutId) {\r\n clearTimeout(newElementData.trajectoryHitData.trajectoryHitExpirationTimeoutId)\r\n }\r\n newElementData.trajectoryHitData.trajectoryHitExpirationTimeoutId = setTimeout(() => {\r\n const currentData = this.elements.get(elementData.element)\r\n if (\r\n currentData &&\r\n currentData.trajectoryHitData.trajectoryHitTime ===\r\n newElementData.trajectoryHitData.trajectoryHitTime\r\n ) {\r\n currentData.trajectoryHitData.isTrajectoryHit = false\r\n this.debugger?.createOrUpdateElementOverlay(currentData)\r\n }\r\n }, 200)\r\n }\r\n this.elements.set(elementData.element, newElementData)\r\n }\r\n }\r\n\r\n private handleMouseMove = (e: MouseEvent) => {\r\n this.updatePointerState(e)\r\n\r\n this.elements.forEach((currentData) => {\r\n if (!currentData.isIntersectingWithViewport) {\r\n return\r\n }\r\n\r\n if (!currentData.unregisterOnCallback) {\r\n this.handleMultiCallbackInteraction(currentData)\r\n } else {\r\n this.handleSingleCallbackInteraction(currentData)\r\n }\r\n })\r\n\r\n if (this.debugger) {\r\n this.debugger.hideScrollTrajectoryVisuals()\r\n this.debugger.updateMouseTrajectoryVisuals(\r\n this.trajectoryPositions,\r\n this._globalSettings.enableMousePrediction\r\n )\r\n }\r\n }\r\n\r\n /**\r\n * Detects when registered elements are removed from the DOM and automatically unregisters them to prevent stale references.\r\n *\r\n * @param mutationsList - Array of MutationRecord objects describing the DOM changes\r\n *\r\n */\r\n private handleDomMutations = (mutationsList: MutationRecord[]) => {\r\n // Invalidate tabbale elements cache\r\n if (mutationsList.length) {\r\n this.tabbableElementsCache = []\r\n this.lastFocusedIndex = null\r\n }\r\n for (const mutation of mutationsList) {\r\n if (mutation.type === \"childList\" && mutation.removedNodes.length > 0) {\r\n for (const element of Array.from(this.elements.keys())) {\r\n if (!element.isConnected) {\r\n this.unregister(element)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // We store the last key for the FocusIn event, meaning we know if the user is tabbing around the page.\r\n // We dont use handleKeyDown for the full event because of 2 main reasons:\r\n // 1: handleKeyDown e.target returns the target on which the keydown is pressed (meaning we dont know which target got the focus)\r\n // 2: handleKeyUp does return the correct e.target however when holding tab the event doesnt repeat (handleKeyDown does)\r\n private handleKeyDown = (e: KeyboardEvent) => {\r\n if (e.key === \"Tab\") {\r\n this.lastKeyDown = e\r\n }\r\n }\r\n\r\n private handleFocusIn = (e: FocusEvent) => {\r\n if (!this.lastKeyDown || !this._globalSettings.enableTabPrediction) {\r\n return\r\n }\r\n const targetElement = e.target\r\n if (!(targetElement instanceof HTMLElement)) {\r\n return\r\n }\r\n\r\n // tabbable uses element.GetBoundingClientRect under the hood, to avoid alot of computations we cache its values\r\n if (!this.tabbableElementsCache.length) {\r\n this.tabbableElementsCache = tabbable(document.documentElement)\r\n if (this._globalSettings.debug) {\r\n console.log(\"ForesightJS: Recomputed tabbable elements cache because of DOM change\")\r\n }\r\n }\r\n\r\n // Determine the range of elements to check based on the tab direction and offset\r\n const isReversed = this.lastKeyDown.shiftKey\r\n\r\n const currentIndex: number = getFocusedElementIndex(\r\n isReversed,\r\n this.lastFocusedIndex,\r\n this.tabbableElementsCache,\r\n targetElement\r\n )\r\n\r\n this.lastFocusedIndex = currentIndex\r\n\r\n this.lastKeyDown = null\r\n const elementsToPredict: ForesightElement[] = []\r\n for (let i = 0; i <= this._globalSettings.tabOffset; i++) {\r\n if (isReversed) {\r\n const element = this.tabbableElementsCache[currentIndex - i]\r\n if (this.elements.has(element as ForesightElement)) {\r\n elementsToPredict.push(element as ForesightElement)\r\n }\r\n } else {\r\n const element = this.tabbableElementsCache[currentIndex + i]\r\n if (this.elements.has(element as ForesightElement)) {\r\n elementsToPredict.push(element as ForesightElement)\r\n }\r\n }\r\n }\r\n\r\n elementsToPredict.forEach((element) => {\r\n this.callCallback(this.elements.get(element), {\r\n kind: \"tab\",\r\n subType: isReversed ? \"reverse\" : \"forwards\",\r\n })\r\n })\r\n }\r\n\r\n private updateHitCounters(elementData: ForesightElementData, hitType: HitType) {\r\n switch (hitType.kind) {\r\n case \"mouse\":\r\n elementData.callbackHits.mouse[hitType.subType]++\r\n this._globalCallbackHits.mouse[hitType.subType]++\r\n break\r\n case \"tab\":\r\n elementData.callbackHits.tab[hitType.subType]++\r\n this._globalCallbackHits.tab[hitType.subType]++\r\n break\r\n case \"scroll\":\r\n elementData.callbackHits.scroll[hitType.subType]++\r\n this._globalCallbackHits.scroll[hitType.subType]++\r\n break\r\n }\r\n elementData.callbackHits.total++\r\n this._globalCallbackHits.total++\r\n }\r\n\r\n private callCallback(elementData: ForesightElementData | undefined, hitType: HitType) {\r\n if (elementData) {\r\n this.updateHitCounters(elementData, hitType)\r\n elementData.callback()\r\n this._globalSettings.onAnyCallbackFired(elementData, this.getManagerData)\r\n if (this.debugger) {\r\n this.debugger.showCallbackAnimation(elementData)\r\n }\r\n // Do everything and then unregister. Always keep this at the end of the function\r\n if (elementData.unregisterOnCallback) {\r\n this.unregister(elementData.element)\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 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.\r\n * We need an observer for that\r\n */\r\n private forceUpdateElementBounds(elementData: ForesightElementData) {\r\n const newOriginalRect = elementData.element.getBoundingClientRect()\r\n const expandedRect = getExpandedRect(newOriginalRect, elementData.elementBounds.hitSlop)\r\n\r\n // Since its a force update, rects can be equal.\r\n if (!areRectsEqual(expandedRect, elementData.elementBounds.expandedRect)) {\r\n this.elements.set(elementData.element, {\r\n ...elementData,\r\n elementBounds: {\r\n ...elementData.elementBounds,\r\n originalRect: newOriginalRect,\r\n expandedRect,\r\n },\r\n })\r\n\r\n if (this.debugger) {\r\n const updatedData = this.elements.get(elementData.element)\r\n if (updatedData) this.debugger.createOrUpdateElementOverlay(updatedData)\r\n }\r\n }\r\n }\r\n\r\n private updateElementBounds(newRect: DOMRect, elementData: ForesightElementData) {\r\n // We dont check if rects are equal like we do in forceUpdateElementBounds, since rects can never be equal here\r\n this.elements.set(elementData.element, {\r\n ...elementData,\r\n elementBounds: {\r\n ...elementData.elementBounds,\r\n originalRect: newRect,\r\n expandedRect: getExpandedRect(newRect, elementData.elementBounds.hitSlop),\r\n },\r\n })\r\n\r\n if (this.debugger) {\r\n const updatedData = this.elements.get(elementData.element)\r\n if (updatedData) this.debugger.createOrUpdateElementOverlay(updatedData)\r\n }\r\n }\r\n\r\n private handleScrollPrefetch(elementData: ForesightElementData, newRect: DOMRect) {\r\n if (this._globalSettings.enableScrollPrediction) {\r\n // This means the foresightmanager is initializing registered elements, we dont want to calc the scroll direction here\r\n if (!elementData.elementBounds.originalRect) {\r\n return\r\n }\r\n // ONCE per animation frame we decide what the scroll direction is\r\n this.scrollDirection =\r\n this.scrollDirection ?? getScrollDirection(elementData.elementBounds.originalRect, newRect)\r\n if (this.scrollDirection === \"none\") {\r\n return\r\n }\r\n\r\n // ONCE per animation frame we decide the predicted scroll point\r\n this.predictedScrollPoint =\r\n this.predictedScrollPoint ??\r\n predictNextScrollPosition(\r\n this.trajectoryPositions.currentPoint,\r\n this.scrollDirection,\r\n this._globalSettings.scrollMargin\r\n )\r\n\r\n if (\r\n lineSegmentIntersectsRect(\r\n this.trajectoryPositions.currentPoint,\r\n this.predictedScrollPoint,\r\n elementData?.elementBounds.expandedRect\r\n )\r\n ) {\r\n this.callCallback(elementData, {\r\n kind: \"scroll\",\r\n subType: this.scrollDirection,\r\n })\r\n }\r\n if (this.debugger) {\r\n this.debugger.updateScrollTrajectoryVisuals(\r\n this.trajectoryPositions.currentPoint,\r\n this.predictedScrollPoint\r\n )\r\n }\r\n } else {\r\n if (\r\n isPointInRectangle(\r\n this.trajectoryPositions.currentPoint,\r\n elementData.elementBounds.expandedRect\r\n )\r\n ) {\r\n this.callCallback(elementData, {\r\n kind: \"mouse\",\r\n subType: \"hover\",\r\n })\r\n }\r\n }\r\n }\r\n\r\n private handlePositionChange = (entries: PositionObserverEntry[]) => {\r\n for (const entry of entries) {\r\n const elementData = this.elements.get(entry.target)\r\n if (!elementData) continue\r\n const wasPreviouslyIntersecting = elementData.isIntersectingWithViewport\r\n const isNowIntersecting = entry.isIntersecting\r\n elementData.isIntersectingWithViewport = isNowIntersecting\r\n\r\n if (wasPreviouslyIntersecting !== isNowIntersecting) {\r\n this.debugger?.updateElementVisibilityStatus(elementData)\r\n }\r\n if (!isNowIntersecting) {\r\n if (this._globalSettings.debug && wasPreviouslyIntersecting) {\r\n this.debugger?.removeElementOverlay(elementData)\r\n }\r\n continue\r\n }\r\n this.updateElementBounds(entry.boundingClientRect, elementData)\r\n this.handleScrollPrefetch(elementData, entry.boundingClientRect)\r\n }\r\n\r\n this.scrollDirection = null\r\n this.predictedScrollPoint = null\r\n }\r\n\r\n private initializeGlobalListeners() {\r\n if (this.isSetup) {\r\n return\r\n }\r\n // To avoid setting up listeners while ssr\r\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\r\n return\r\n }\r\n\r\n this.globalListenersController = new AbortController()\r\n const { signal } = this.globalListenersController\r\n document.addEventListener(\"mousemove\", this.handleMouseMove, { signal })\r\n document.addEventListener(\"keydown\", this.handleKeyDown, { signal })\r\n document.addEventListener(\"focusin\", this.handleFocusIn, { signal })\r\n\r\n //Mutation observer is to automatically unregister elements when they leave the DOM. Its a fail-safe for if the user forgets to do it.\r\n this.domObserver = new MutationObserver(this.handleDomMutations)\r\n this.domObserver.observe(document.documentElement, {\r\n childList: true,\r\n subtree: true,\r\n attributes: false,\r\n })\r\n\r\n // Handles all position based changes and update the rects of the elements. completely async to avoid dirtying the main thread.\r\n // Handles resize of elements\r\n // Handles resize of viewport\r\n // Handles scrolling\r\n this.positionObserver = new PositionObserver(this.handlePositionChange)\r\n\r\n this.isSetup = true\r\n }\r\n\r\n private removeGlobalListeners() {\r\n this.isSetup = false\r\n if (!this.debugger) {\r\n this.globalListenersController?.abort() // Remove all event listeners only in non debug mode\r\n this.globalListenersController = null\r\n } else {\r\n console.log(\r\n \"ForesightJS: All elements have successfully been unregistered. ForesightJS would typically perform cleanup events now, but these are currently skipped while in debug mode. Observers are cleared up.\"\r\n )\r\n }\r\n this.domObserver?.disconnect()\r\n this.domObserver = null\r\n this.positionObserver?.disconnect()\r\n this.positionObserver = null\r\n }\r\n}\r\n","import type { FocusableElement } from \"tabbable\"\r\n\r\n/**\r\n * Finds the index of a focused element within a cache of tabbable elements.\r\n * It uses a predictive search for O(1) performance in the common case of\r\n * sequential tabbing, and falls back to a linear search O(n) if the\r\n * prediction fails.\r\n *\r\n * @param isReversed - True if the user is tabbing backward (Shift+Tab).\r\n * @param lastFocusedIndex - The index of the previously focused element, or null if none.\r\n * @param tabbableElementsCache - The array of all tabbable elements.\r\n * @param targetElement - The new HTML element that has received focus.\r\n * @returns The index of the targetElement in the cache, or -1 if not found.\r\n */\r\nexport function getFocusedElementIndex(\r\n isReversed: boolean,\r\n lastFocusedIndex: number | null,\r\n tabbableElementsCache: FocusableElement[],\r\n targetElement: HTMLElement\r\n): number {\r\n // First, try to predict the next index based on the last known position.\r\n if (lastFocusedIndex !== null) {\r\n const predictedIndex = isReversed ? lastFocusedIndex - 1 : lastFocusedIndex + 1\r\n\r\n // Check if the prediction is valid and correct.\r\n if (\r\n predictedIndex >= 0 &&\r\n predictedIndex < tabbableElementsCache.length &&\r\n tabbableElementsCache[predictedIndex] === targetElement\r\n ) {\r\n return predictedIndex\r\n }\r\n }\r\n\r\n // Slow way if we dont find it\r\n return tabbableElementsCache.findIndex((element) => element === targetElement)\r\n}\r\n","import type { MousePosition, Point } from \"../../types/types\"\r\n\r\n/**\r\n * Predicts the next mouse position based on a history of recent movements.\r\n * It calculates velocity from the historical data and extrapolates a future point.\r\n * The `history` array is mutated by this function: the new `currentPoint` is added,\r\n * and if the history exceeds `positionHistorySize`, the oldest entry is removed.\r\n *\r\n * @param currentPoint - The current actual mouse coordinates.\r\n * @param history - An array of previous mouse positions with timestamps.\r\n * This array will be modified by this function.\r\n * @param positionHistorySize - The maximum number of past positions to store and consider\r\n * for the prediction.\r\n * @param trajectoryPredictionTimeInMs - How far into the future (in milliseconds)\r\n * to predict the mouse position.\r\n * @returns The predicted {@link Point} (x, y coordinates). If history is insufficient\r\n * (less than 2 points) or time delta is zero, returns the `currentPoint`.\r\n */\r\nexport function predictNextMousePosition(\r\n currentPoint: Point,\r\n history: MousePosition[],\r\n positionHistorySize: number,\r\n trajectoryPredictionTimeInMs: number\r\n): Point {\r\n const now = performance.now()\r\n const currentPosition: MousePosition = { point: currentPoint, time: now }\r\n const { x, y } = currentPoint\r\n\r\n history.push(currentPosition)\r\n if (history.length > positionHistorySize) {\r\n history.shift()\r\n }\r\n\r\n if (history.length < 2) {\r\n return { x, y }\r\n }\r\n\r\n const first = history[0]\r\n const last = history[history.length - 1]\r\n const dt = (last.time - first.time) / 1000\r\n\r\n if (dt === 0) {\r\n return { x, y }\r\n }\r\n\r\n const dx = last.point.x - first.point.x\r\n const dy = last.point.y - first.point.y\r\n const vx = dx / dt\r\n const vy = dy / dt\r\n\r\n const trajectoryPredictionTimeInSeconds = trajectoryPredictionTimeInMs / 1000\r\n const predictedX = x + vx * trajectoryPredictionTimeInSeconds\r\n const predictedY = y + vy * trajectoryPredictionTimeInSeconds\r\n\r\n return { x: predictedX, y: predictedY }\r\n}\r\n","import type { Rect, ScrollDirection } from \"../../types/types\"\r\n\r\nexport function getScrollDirection(oldRect: Rect, newRect: Rect): ScrollDirection {\r\n const scrollThreshold = 1\r\n const deltaY = newRect.top - oldRect.top\r\n const deltaX = newRect.left - oldRect.left\r\n\r\n // Check vertical scroll first (most common)\r\n if (deltaY < -scrollThreshold) {\r\n return \"down\" // Element moved up in viewport = scrolled down\r\n } else if (deltaY > scrollThreshold) {\r\n return \"up\" // Element moved down in viewport = scrolled up\r\n }\r\n\r\n // Check horizontal scroll\r\n if (deltaX < -scrollThreshold) {\r\n return \"right\" // Element moved left in viewport = scrolled right\r\n } else if (deltaX > scrollThreshold) {\r\n return \"left\" // Element moved right in viewport = scrolled left\r\n }\r\n\r\n return \"none\" // No significant movement detected\r\n}\r\n","import type { Point, ScrollDirection } from \"../../types/types\"\r\n\r\nexport function predictNextScrollPosition(\r\n currentPoint: Point,\r\n direction: ScrollDirection,\r\n scrollMargin: number\r\n) {\r\n const { x, y } = currentPoint\r\n const predictedPoint = { x, y }\r\n\r\n switch (direction) {\r\n case \"down\":\r\n predictedPoint.y += scrollMargin\r\n break\r\n case \"up\":\r\n predictedPoint.y -= scrollMargin\r\n break\r\n case \"left\":\r\n predictedPoint.x -= scrollMargin\r\n break\r\n case \"right\":\r\n predictedPoint.x += scrollMargin\r\n break\r\n }\r\n return predictedPoint\r\n}\r\n"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","SuppressedError","candidateSelector","join","NoElement","Element","matches","msMatchesSelector","webkitMatchesSelector","getRootNode","element","_element$getRootNode","ownerDocument","isInert","node","lookUp","_node$getAttribute","inertAtt","getAttribute","parentNode","getCandidatesIteratively","elements","includeContainer","options","candidates","elementsToCheck","Array","from","shift","tagName","assigned","assignedElements","nestedCandidates","children","flatten","push","scopeParent","filter","includes","shadowRoot","getShadowRoot","validShadowRoot","shadowRootFilter","_nestedCandidates","unshift","hasTabIndex","isNaN","parseInt","getTabIndex","Error","tabIndex","test","_node$getAttribute2","attValue","isContentEditable","sortOrderedTabbables","a","b","documentOrder","isInput","isNonTabbableRadio","type","isRadio","name","radioSet","radioScope","form","queryRadios","querySelectorAll","window","CSS","escape","err","console","error","message","checked","nodes","getCheckedRadio","isTabbableRadio","isZeroArea","_node$getBoundingClie","getBoundingClientRect","width","height","isHidden","_ref","displayCheck","getComputedStyle","visibility","nodeUnderDetails","parentElement","originalNode","rootNode","assignedSlot","host","_nodeRoot","_nodeRootHost","_nodeRootHost$ownerDo","_node$ownerDocument","nodeRoot","nodeRootHost","attached","contains","_nodeRoot2","_nodeRootHost2","_nodeRootHost2$ownerD","isNodeAttached","getClientRects","isNodeMatchingSelectorFocusable","disabled","isHiddenInput","slice","some","child","isDetailsWithSummary","item","isDisabledFromFieldset","isNodeMatchingSelectorTabbable","isValidShadowRootTabbable","shadowHostNode","sortByOrder","regularTabbables","orderedTabbables","forEach","isScope","candidateTabindex","getSortOrderTabIndex","content","sort","reduce","acc","sortable","concat","tabbable","container","bind","el","getCandidates","TRAJECTORY_PREDICTION_TIME_UNIT","POSITION_HISTORY_SIZE_UNIT","TAB_OFFSET_UNIT","MAX_HITSLOP","DEFAULT_IS_DEBUGGER_MINIMIZED","DEFAULT_SHOW_NAME_TAGS","formatValue","value","indent","spaces","repeat","isArray","entries","formattedEntries","map","_a","key","val","String","undefined","JSON","stringify","createAndAppendElement","tag","parent","attributes","document","createElement","id","className","data","setAttribute","appendChild","createAndAppendStyle","styleSheet","textContent","getIntersectingIcon","isIntersectingWithViewport","COPY_SVG_ICON","NO_ELEMENTS_STRING","DebuggerControlPanel","foresightManager","elementListItemsContainer","elementCountSpan","callbackCountSpan","elementListItems","Map","trajectoryEnabledCheckbox","tabEnabledCheckbox","scrollEnabledCheckbox","historySizeSlider","historyValueSpan","predictionTimeSlider","predictionValueSpan","tabOffsetSlider","tabOffsetValueSpan","scrollMarginSlider","scrollMarginValueSpan","showNameTagsCheckbox","sortOptionsPopup","sortButton","containerMinimizeButton","allSettingsSectionsContainer","debuggerElementsSection","isContainerMinimized","isMouseSettingsMinimized","isKeyboardSettingsMinimized","isScrollSettingsMinimized","isGeneralSettingsMinimized","SESSION_STORAGE_KEY","copySettingsButton","copyTimeoutId","closeSortDropdownHandler","foresightManagerInstance","_setupDOMAndListeners","debuggerSettings","controlsContainer","isControlPanelDefaultMinimized","createControlContainer","controlPanelStyleElement","getStyles","queryDOMElements","originalSectionStates","setupEventListeners","updateContainerVisibilityState","initialize","isInitiated","debuggerControlPanelInstance","instance","defineProperty","get","loadSectionStatesFromSessionStorage","storedStatesRaw","sessionStorage","getItem","loadedStates","parse","mouse","_b","keyboard","_c","scroll","_d","general","saveSectionStatesToSessionStorage","states","setItem","e","querySelector","handleCopySettings","obj","methodName","_this","navigator","clipboard","writeText","getManagerData","globalSettings","then","innerHTML","clearTimeout","setTimeout","catch","createInputEventListener","spanElement","unit","setting","addEventListener","target","alterGlobalSettings","createChangeEventListener","showNameTags","createSectionVisibilityToggleEventListener","section","isMinimizedFlagName","sectionHeader","stopPropagation","toggleMinimizeSection","classList","toggle","closest","dataset","sortElementList","log","sortAndReorderElements","updateSortOptionUI","remove","shouldMinimize","sectionContent","minimizeButton","style","display","elementListContent","_e","add","currentSort","button","btn","updateControlsState","settings","enableMousePrediction","enableTabPrediction","enableScrollPrediction","positionHistorySize","toString","trajectoryPredictionTime","tabOffset","scrollMargin","refreshRegisteredElementCountDisplay","elementsMap","visibleElementCount","totalElements","size","globalCallbackHits","tab","total","title","hover","trajectory","forwards","reverse","down","left","right","up","removeElementFromList","elementData","listItem","delete","registeredElements","updateElementVisibilityStatus","intersectingElement","intersectingIcon","addElementToList","sortOrder","elementsData","values","sortByDocumentPosition_1","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","fragment","createDocumentFragment","has","updateListItemContent","set","hitBehaviorText","unregisterOnCallback","hitSlopText","elementBounds","hitSlop","top_1","top","bottom","comprehensiveTitle","cleanup","removeEventListener","clear","rowsContentHeight","elementItemHeight","numItemsPerRow","updateElementOverlays","currentOverlays","newData","expandedOverlay","nameLabel","expandedRect","expandedWidth","expandedHeight","transform","Rect","intersect","rect1","rect2","Math","max","min","DOMRect","clip","rect","updatedRect","toJSON","clipOffsets","clippedRect","equals","x","y","sizeEqual","round","rootMargin","rootBounds","threshold","_","PositionIntersectionObserver","constructor","callback","clientRect","observe","observer","previousIntersectionRatio","visibleRect","isIntersecting","root","disconnect","IntersectionObserver","onIntersection","entry","intersectionRatio","boundingClientRect","previousClientRect","clientRectChanged","rootIntersection","PositionIntersectionObserverEntry","intersectionRect","RootBoundsObserver","nodeType","DOCUMENT_NODE","isDocument","defaultView","getRoot","isNode","ELEMENT_NODE","isElement","resizeObserver","ResizeObserver","inlineSize","blockSize","borderBoxSize","event","capture","passive","signal","controller","viewport","visualViewport","getWindowRect","handleResize","AbortController","abort","window2","innerWidth","innerHeight","VisibilityObserver","changedEntries","previousIntersection","intersections","observers","WeakMap","document2","unobserve","PositionObserver","rootBoundsObserver","onRootBoundsChange","visibilityObserver","onVisibilityChange","onResize","positionObservers","positions","positionObserver","notify","records","isEntryEqual","observePosition","PositionObserverEntry","onPositionChange","intersection","previous","first","second","evaluateRegistrationConditions","isTouchDevice","matchMedia","maxTouchPoints","connection","isLimitedConnection","effectiveType","saveData","shouldRegister","ForesightDebugger","callbackAnimations","debugElementOverlays","predictedMouseIndicator","mouseTrajectoryLine","scrollTrajectoryLine","animationPositionObserver","handleAnimationPositionChange","_i","entries_1","animationData","overlay","newLeft","newTop","newWidth","newHeight","_setupDOM","shadowHost","body","attachShadow","mode","debugContainer","controlPanel","debuggerCSS","debuggerInstance","trajectoryPositions","updateMouseTrajectoryVisuals","createElementOverlays","overlays","createOrUpdateElementOverlay","toggleNameTagVisibility","removeElement","removeElementOverlay","addElement","predictedPoint","currentPoint","dx","dy","sqrt","angle","atan2","PI","updateScrollTrajectoryVisuals","predictedScrollPoint","hideScrollTrajectoryVisuals","showCallbackAnimation","existingAnimation","timeoutId","animationOverlay","clampNumber","number","lowerBound","upperBound","isDebug","settingName","warn","lineSegmentIntersectsRect","p1","p2","t0","t1","clipTest","q","r","normalizeHitSlop","clampedValue","getExpandedRect","baseRect","areRectsEqual","isPointInRectangle","point","shouldUpdateSetting","newValue","currentValue","ForesightManager","isSetup","debugger","_globalCallbackHits","_globalSettings","debug","defaultHitSlop","resizeScrollThrottleDelay","onAnyCallbackFired","_elementData","_managerData","tabbableElementsCache","lastFocusedIndex","scrollDirection","domObserver","lastKeyDown","globalListenersController","handleMouseMove","updatePointerState","currentData","handleSingleCallbackInteraction","handleMultiCallbackInteraction","handleDomMutations","mutationsList","mutationsList_1","mutation","removedNodes","keys","isConnected","unregister","handleKeyDown","handleFocusIn","targetElement","HTMLElement","documentElement","isReversed","shiftKey","currentIndex","predictedIndex","findIndex","getFocusedElementIndex","elementsToPredict","callCallback","kind","subType","handlePositionChange","wasPreviouslyIntersecting","isNowIntersecting","updateElementBounds","handleScrollPrefetch","props","manager","register","isRegistered","initializeGlobalListeners","normalizedHitSlop","callbackHits","originalRect","isHovering","trajectoryHitData","isTrajectoryHit","trajectoryHitTime","trajectoryHitExpirationTimeoutId","foresightElementData","removeGlobalListeners","updateNumericSettings","updateBooleanSetting","oldPositionHistorySize","positionHistoryChanged","trajectoryTimeChanged","scrollMarginChanged","tabOffsetChanged","mousePredictionChanged","scrollPredictionChanged","tabPredictionChanged","debuggerSettingsChanged","hitSlopChanged","normalizedNewHitSlop","forceUpdateAllElementBounds","debugModeChanged","turnOnDebugMode","elementsArray_1","index","isLastElement","forceUpdateElementBounds","clientX","clientY","history","trajectoryPredictionTimeInMs","currentPosition","time","performance","now","last","dt","trajectoryPredictionTimeInSeconds","predictNextMousePosition","isNewPhysicalHover","isNewTrajectoryHit","newElementData_1","updateHitCounters","hitType","newOriginalRect","updatedData","newRect","oldRect","deltaY","deltaX","getScrollDirection","direction","predictNextScrollPosition","MutationObserver","childList","subtree"],"mappings":"aA+BO,IAAIA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,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google_ignoreList":[0,1,8]}
1
+ {"version":3,"file":"index.js","sources":["../node_modules/.pnpm/@rollup+plugin-typescript@1_25d8bb3f895bd6a0766290a9503c913c/node_modules/tslib/tslib.es6.js","../node_modules/.pnpm/tabbable@6.2.0/node_modules/tabbable/dist/index.esm.js","../src/Manager/constants.ts","../src/Debugger/helpers/objectToMethodCall.ts","../src/Debugger/helpers/createAndAppend.ts","../src/Debugger/helpers/getIntersectingIcon.ts","../src/Debugger/DebuggerControlPanel.ts","../src/Debugger/helpers/updateElementOverlays.ts","../node_modules/.pnpm/position-observer@1.0.0/node_modules/position-observer/dist/index.js","../src/helpers/shouldRegister.ts","../src/Debugger/ForesightDebugger.ts","../src/Debugger/helpers/removeOldDebuggers.ts","../src/Manager/helpers/clampNumber.ts","../src/Manager/helpers/lineSigmentIntersectsRect.ts","../src/Manager/helpers/rectAndHitSlop.ts","../src/Manager/helpers/shouldUpdateSetting.ts","../src/Manager/ForesightManager.ts","../src/Manager/helpers/getFocusedElementIndex.ts","../src/Manager/helpers/predictNextMousePosition.ts","../src/Manager/helpers/getScrollDirection.ts","../src/Manager/helpers/predictNextScrollPosition.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nvar ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","/*!\n* tabbable 6.2.0\n* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE\n*/\n// NOTE: separate `:not()` selectors has broader browser support than the newer\n// `:not([inert], [inert] *)` (Feb 2023)\n// CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes\n// the entire query to fail, resulting in no nodes found, which will break a lot\n// of things... so we have to rely on JS to identify nodes inside an inert container\nvar candidateSelectors = ['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])'];\nvar candidateSelector = /* #__PURE__ */candidateSelectors.join(',');\nvar NoElement = typeof Element === 'undefined';\nvar matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;\nvar getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {\n var _element$getRootNode;\n return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);\n} : function (element) {\n return element === null || element === void 0 ? void 0 : element.ownerDocument;\n};\n\n/**\n * Determines if a node is inert or in an inert ancestor.\n * @param {Element} [node]\n * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to\n * see if any of them are inert. If false, only `node` itself is considered.\n * @returns {boolean} True if inert itself or by way of being in an inert ancestor.\n * False if `node` is falsy.\n */\nvar isInert = function isInert(node, lookUp) {\n var _node$getAttribute;\n if (lookUp === void 0) {\n lookUp = true;\n }\n // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`\n // JS API property; we have to check the attribute, which can either be empty or 'true';\n // if it's `null` (not specified) or 'false', it's an active element\n var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, 'inert');\n var inert = inertAtt === '' || inertAtt === 'true';\n\n // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`\n // if it weren't for `matches()` not being a function on shadow roots; the following\n // code works for any kind of node\n // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`\n // so it likely would not support `:is([inert] *)` either...\n var result = inert || lookUp && node && isInert(node.parentNode); // recursive\n\n return result;\n};\n\n/**\n * Determines if a node's content is editable.\n * @param {Element} [node]\n * @returns True if it's content-editable; false if it's not or `node` is falsy.\n */\nvar isContentEditable = function isContentEditable(node) {\n var _node$getAttribute2;\n // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have\n // to use the attribute directly to check for this, which can either be empty or 'true';\n // if it's `null` (not specified) or 'false', it's a non-editable element\n var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, 'contenteditable');\n return attValue === '' || attValue === 'true';\n};\n\n/**\n * @param {Element} el container to check in\n * @param {boolean} includeContainer add container to check\n * @param {(node: Element) => boolean} filter filter candidates\n * @returns {Element[]}\n */\nvar getCandidates = function getCandidates(el, includeContainer, filter) {\n // even if `includeContainer=false`, we still have to check it for inertness because\n // if it's inert, all its children are inert\n if (isInert(el)) {\n return [];\n }\n var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));\n if (includeContainer && matches.call(el, candidateSelector)) {\n candidates.unshift(el);\n }\n candidates = candidates.filter(filter);\n return candidates;\n};\n\n/**\n * @callback GetShadowRoot\n * @param {Element} element to check for shadow root\n * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.\n */\n\n/**\n * @callback ShadowRootFilter\n * @param {Element} shadowHostNode the element which contains shadow content\n * @returns {boolean} true if a shadow root could potentially contain valid candidates.\n */\n\n/**\n * @typedef {Object} CandidateScope\n * @property {Element} scopeParent contains inner candidates\n * @property {Element[]} candidates list of candidates found in the scope parent\n */\n\n/**\n * @typedef {Object} IterativeOptions\n * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;\n * if a function, implies shadow support is enabled and either returns the shadow root of an element\n * or a boolean stating if it has an undisclosed shadow root\n * @property {(node: Element) => boolean} filter filter candidates\n * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list\n * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;\n */\n\n/**\n * @param {Element[]} elements list of element containers to match candidates from\n * @param {boolean} includeContainer add container list to check\n * @param {IterativeOptions} options\n * @returns {Array.<Element|CandidateScope>}\n */\nvar getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {\n var candidates = [];\n var elementsToCheck = Array.from(elements);\n while (elementsToCheck.length) {\n var element = elementsToCheck.shift();\n if (isInert(element, false)) {\n // no need to look up since we're drilling down\n // anything inside this container will also be inert\n continue;\n }\n if (element.tagName === 'SLOT') {\n // add shadow dom slot scope (slot itself cannot be focusable)\n var assigned = element.assignedElements();\n var content = assigned.length ? assigned : element.children;\n var nestedCandidates = getCandidatesIteratively(content, true, options);\n if (options.flatten) {\n candidates.push.apply(candidates, nestedCandidates);\n } else {\n candidates.push({\n scopeParent: element,\n candidates: nestedCandidates\n });\n }\n } else {\n // check candidate element\n var validCandidate = matches.call(element, candidateSelector);\n if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {\n candidates.push(element);\n }\n\n // iterate over shadow content if possible\n var shadowRoot = element.shadowRoot ||\n // check for an undisclosed shadow\n typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);\n\n // no inert look up because we're already drilling down and checking for inertness\n // on the way down, so all containers to this root node should have already been\n // vetted as non-inert\n var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));\n if (shadowRoot && validShadowRoot) {\n // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed\n // shadow exists, so look at light dom children as fallback BUT create a scope for any\n // child candidates found because they're likely slotted elements (elements that are\n // children of the web component element (which has the shadow), in the light dom, but\n // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,\n // _after_ we return from this recursive call\n var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);\n if (options.flatten) {\n candidates.push.apply(candidates, _nestedCandidates);\n } else {\n candidates.push({\n scopeParent: element,\n candidates: _nestedCandidates\n });\n }\n } else {\n // there's not shadow so just dig into the element's (light dom) children\n // __without__ giving the element special scope treatment\n elementsToCheck.unshift.apply(elementsToCheck, element.children);\n }\n }\n }\n return candidates;\n};\n\n/**\n * @private\n * Determines if the node has an explicitly specified `tabindex` attribute.\n * @param {HTMLElement} node\n * @returns {boolean} True if so; false if not.\n */\nvar hasTabIndex = function hasTabIndex(node) {\n return !isNaN(parseInt(node.getAttribute('tabindex'), 10));\n};\n\n/**\n * Determine the tab index of a given node.\n * @param {HTMLElement} node\n * @returns {number} Tab order (negative, 0, or positive number).\n * @throws {Error} If `node` is falsy.\n */\nvar getTabIndex = function getTabIndex(node) {\n if (!node) {\n throw new Error('No node provided');\n }\n if (node.tabIndex < 0) {\n // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default\n // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,\n // yet they are still part of the regular tab order; in FF, they get a default\n // `tabIndex` of 0; since Chrome still puts those elements in the regular tab\n // order, consider their tab index to be 0.\n // Also browsers do not return `tabIndex` correctly for contentEditable nodes;\n // so if they don't have a tabindex attribute specifically set, assume it's 0.\n if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {\n return 0;\n }\n }\n return node.tabIndex;\n};\n\n/**\n * Determine the tab index of a given node __for sort order purposes__.\n * @param {HTMLElement} node\n * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,\n * has tabIndex -1, but needs to be sorted by document order in order for its content to be\n * inserted into the correct sort position.\n * @returns {number} Tab order (negative, 0, or positive number).\n */\nvar getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {\n var tabIndex = getTabIndex(node);\n if (tabIndex < 0 && isScope && !hasTabIndex(node)) {\n return 0;\n }\n return tabIndex;\n};\nvar sortOrderedTabbables = function sortOrderedTabbables(a, b) {\n return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;\n};\nvar isInput = function isInput(node) {\n return node.tagName === 'INPUT';\n};\nvar isHiddenInput = function isHiddenInput(node) {\n return isInput(node) && node.type === 'hidden';\n};\nvar isDetailsWithSummary = function isDetailsWithSummary(node) {\n var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {\n return child.tagName === 'SUMMARY';\n });\n return r;\n};\nvar getCheckedRadio = function getCheckedRadio(nodes, form) {\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i].checked && nodes[i].form === form) {\n return nodes[i];\n }\n }\n};\nvar isTabbableRadio = function isTabbableRadio(node) {\n if (!node.name) {\n return true;\n }\n var radioScope = node.form || getRootNode(node);\n var queryRadios = function queryRadios(name) {\n return radioScope.querySelectorAll('input[type=\"radio\"][name=\"' + name + '\"]');\n };\n var radioSet;\n if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {\n radioSet = queryRadios(window.CSS.escape(node.name));\n } else {\n try {\n radioSet = queryRadios(node.name);\n } catch (err) {\n // eslint-disable-next-line no-console\n 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', err.message);\n return false;\n }\n }\n var checked = getCheckedRadio(radioSet, node.form);\n return !checked || checked === node;\n};\nvar isRadio = function isRadio(node) {\n return isInput(node) && node.type === 'radio';\n};\nvar isNonTabbableRadio = function isNonTabbableRadio(node) {\n return isRadio(node) && !isTabbableRadio(node);\n};\n\n// determines if a node is ultimately attached to the window's document\nvar isNodeAttached = function isNodeAttached(node) {\n var _nodeRoot;\n // The root node is the shadow root if the node is in a shadow DOM; some document otherwise\n // (but NOT _the_ document; see second 'If' comment below for more).\n // If rootNode is shadow root, it'll have a host, which is the element to which the shadow\n // is attached, and the one we need to check if it's in the document or not (because the\n // shadow, and all nodes it contains, is never considered in the document since shadows\n // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,\n // is hidden, or is not in the document itself but is detached, it will affect the shadow's\n // visibility, including all the nodes it contains). The host could be any normal node,\n // or a custom element (i.e. web component). Either way, that's the one that is considered\n // part of the document, not the shadow root, nor any of its children (i.e. the node being\n // tested).\n // To further complicate things, we have to look all the way up until we find a shadow HOST\n // that is attached (or find none) because the node might be in nested shadows...\n // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the\n // document (per the docs) and while it's a Document-type object, that document does not\n // appear to be the same as the node's `ownerDocument` for some reason, so it's safer\n // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,\n // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when\n // node is actually detached.\n // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible\n // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed\n // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then\n // `ownerDocument` will be `null`, hence the optional chaining on it.\n var nodeRoot = node && getRootNode(node);\n var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;\n\n // in some cases, a detached node will return itself as the root instead of a document or\n // shadow root object, in which case, we shouldn't try to look further up the host chain\n var attached = false;\n if (nodeRoot && nodeRoot !== node) {\n var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;\n attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));\n while (!attached && nodeRootHost) {\n var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;\n // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,\n // which means we need to get the host's host and check if that parent host is contained\n // in (i.e. attached to) the document\n nodeRoot = getRootNode(nodeRootHost);\n nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;\n attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));\n }\n }\n return attached;\n};\nvar isZeroArea = function isZeroArea(node) {\n var _node$getBoundingClie = node.getBoundingClientRect(),\n width = _node$getBoundingClie.width,\n height = _node$getBoundingClie.height;\n return width === 0 && height === 0;\n};\nvar isHidden = function isHidden(node, _ref) {\n var displayCheck = _ref.displayCheck,\n getShadowRoot = _ref.getShadowRoot;\n // NOTE: visibility will be `undefined` if node is detached from the document\n // (see notes about this further down), which means we will consider it visible\n // (this is legacy behavior from a very long way back)\n // NOTE: we check this regardless of `displayCheck=\"none\"` because this is a\n // _visibility_ check, not a _display_ check\n if (getComputedStyle(node).visibility === 'hidden') {\n return true;\n }\n var isDirectSummary = matches.call(node, 'details>summary:first-of-type');\n var nodeUnderDetails = isDirectSummary ? node.parentElement : node;\n if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {\n return true;\n }\n if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {\n if (typeof getShadowRoot === 'function') {\n // figure out if we should consider the node to be in an undisclosed shadow and use the\n // 'non-zero-area' fallback\n var originalNode = node;\n while (node) {\n var parentElement = node.parentElement;\n var rootNode = getRootNode(node);\n if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow\n ) {\n // node has an undisclosed shadow which means we can only treat it as a black box, so we\n // fall back to a non-zero-area test\n return isZeroArea(node);\n } else if (node.assignedSlot) {\n // iterate up slot\n node = node.assignedSlot;\n } else if (!parentElement && rootNode !== node.ownerDocument) {\n // cross shadow boundary\n node = rootNode.host;\n } else {\n // iterate up normal dom\n node = parentElement;\n }\n }\n node = originalNode;\n }\n // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support\n // (i.e. it does not also presume that all nodes might have undisclosed shadows); or\n // it might be a falsy value, which means shadow DOM support is disabled\n\n // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)\n // now we can just test to see if it would normally be visible or not, provided it's\n // attached to the main document.\n // NOTE: We must consider case where node is inside a shadow DOM and given directly to\n // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.\n\n if (isNodeAttached(node)) {\n // this works wherever the node is: if there's at least one client rect, it's\n // somehow displayed; it also covers the CSS 'display: contents' case where the\n // node itself is hidden in place of its contents; and there's no need to search\n // up the hierarchy either\n return !node.getClientRects().length;\n }\n\n // Else, the node isn't attached to the document, which means the `getClientRects()`\n // API will __always__ return zero rects (this can happen, for example, if React\n // is used to render nodes onto a detached tree, as confirmed in this thread:\n // https://github.com/facebook/react/issues/9117#issuecomment-284228870)\n //\n // It also means that even window.getComputedStyle(node).display will return `undefined`\n // because styles are only computed for nodes that are in the document.\n //\n // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable\n // somehow. Though it was never stated officially, anyone who has ever used tabbable\n // APIs on nodes in detached containers has actually implicitly used tabbable in what\n // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck=\"none\"` mode -- essentially\n // considering __everything__ to be visible because of the innability to determine styles.\n //\n // v6.0.0: As of this major release, the default 'full' option __no longer treats detached\n // nodes as visible with the 'none' fallback.__\n if (displayCheck !== 'legacy-full') {\n return true; // hidden\n }\n // else, fallback to 'none' mode and consider the node visible\n } else if (displayCheck === 'non-zero-area') {\n // NOTE: Even though this tests that the node's client rect is non-zero to determine\n // whether it's displayed, and that a detached node will __always__ have a zero-area\n // client rect, we don't special-case for whether the node is attached or not. In\n // this mode, we do want to consider nodes that have a zero area to be hidden at all\n // times, and that includes attached or not.\n return isZeroArea(node);\n }\n\n // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume\n // it's visible\n return false;\n};\n\n// form fields (nested) inside a disabled fieldset are not focusable/tabbable\n// unless they are in the _first_ <legend> element of the top-most disabled\n// fieldset\nvar isDisabledFromFieldset = function isDisabledFromFieldset(node) {\n if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {\n var parentNode = node.parentElement;\n // check if `node` is contained in a disabled <fieldset>\n while (parentNode) {\n if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {\n // look for the first <legend> among the children of the disabled <fieldset>\n for (var i = 0; i < parentNode.children.length; i++) {\n var child = parentNode.children.item(i);\n // when the first <legend> (in document order) is found\n if (child.tagName === 'LEGEND') {\n // if its parent <fieldset> is not nested in another disabled <fieldset>,\n // return whether `node` is a descendant of its first <legend>\n return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);\n }\n }\n // the disabled <fieldset> containing `node` has no <legend>\n return true;\n }\n parentNode = parentNode.parentElement;\n }\n }\n\n // else, node's tabbable/focusable state should not be affected by a fieldset's\n // enabled/disabled state\n return false;\n};\nvar isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {\n if (node.disabled ||\n // we must do an inert look up to filter out any elements inside an inert ancestor\n // because we're limited in the type of selectors we can use in JSDom (see related\n // note related to `candidateSelectors`)\n isInert(node) || isHiddenInput(node) || isHidden(node, options) ||\n // For a details element with a summary, the summary element gets the focus\n isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {\n return false;\n }\n return true;\n};\nvar isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {\n if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {\n return false;\n }\n return true;\n};\nvar isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {\n var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);\n if (isNaN(tabIndex) || tabIndex >= 0) {\n return true;\n }\n // If a custom element has an explicit negative tabindex,\n // browsers will not allow tab targeting said element's children.\n return false;\n};\n\n/**\n * @param {Array.<Element|CandidateScope>} candidates\n * @returns Element[]\n */\nvar sortByOrder = function sortByOrder(candidates) {\n var regularTabbables = [];\n var orderedTabbables = [];\n candidates.forEach(function (item, i) {\n var isScope = !!item.scopeParent;\n var element = isScope ? item.scopeParent : item;\n var candidateTabindex = getSortOrderTabIndex(element, isScope);\n var elements = isScope ? sortByOrder(item.candidates) : element;\n if (candidateTabindex === 0) {\n isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);\n } else {\n orderedTabbables.push({\n documentOrder: i,\n tabIndex: candidateTabindex,\n item: item,\n isScope: isScope,\n content: elements\n });\n }\n });\n return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {\n sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);\n return acc;\n }, []).concat(regularTabbables);\n};\nvar tabbable = function tabbable(container, options) {\n options = options || {};\n var candidates;\n if (options.getShadowRoot) {\n candidates = getCandidatesIteratively([container], options.includeContainer, {\n filter: isNodeMatchingSelectorTabbable.bind(null, options),\n flatten: false,\n getShadowRoot: options.getShadowRoot,\n shadowRootFilter: isValidShadowRootTabbable\n });\n } else {\n candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));\n }\n return sortByOrder(candidates);\n};\nvar focusable = function focusable(container, options) {\n options = options || {};\n var candidates;\n if (options.getShadowRoot) {\n candidates = getCandidatesIteratively([container], options.includeContainer, {\n filter: isNodeMatchingSelectorFocusable.bind(null, options),\n flatten: true,\n getShadowRoot: options.getShadowRoot\n });\n } else {\n candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));\n }\n return candidates;\n};\nvar isTabbable = function isTabbable(node, options) {\n options = options || {};\n if (!node) {\n throw new Error('No node provided');\n }\n if (matches.call(node, candidateSelector) === false) {\n return false;\n }\n return isNodeMatchingSelectorTabbable(options, node);\n};\nvar focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');\nvar isFocusable = function isFocusable(node, options) {\n options = options || {};\n if (!node) {\n throw new Error('No node provided');\n }\n if (matches.call(node, focusableCandidateSelector) === false) {\n return false;\n }\n return isNodeMatchingSelectorFocusable(options, node);\n};\n\nexport { focusable, getTabIndex, isFocusable, isTabbable, tabbable };\n//# sourceMappingURL=index.esm.js.map\n","import type { SortElementList } from \"../types/types\"\r\n\r\n//IMPORTANT: when altering these values change the type jsDocs/actual docs for BaseForesightManagerProps\r\nexport const MIN_TRAJECTORY_PREDICTION_TIME: number = 10\r\nexport const MAX_TRAJECTORY_PREDICTION_TIME: number = 200\r\nexport const DEFAULT_TRAJECTORY_PREDICTION_TIME: number = 120\r\nexport const TRAJECTORY_PREDICTION_TIME_UNIT: string = \"ms\"\r\n\r\nexport const MIN_POSITION_HISTORY_SIZE: number = 2\r\nexport const MAX_POSITION_HISTORY_SIZE: number = 30\r\nexport const DEFAULT_POSITION_HISTORY_SIZE: number = 8\r\nexport const POSITION_HISTORY_SIZE_UNIT: string = \"points\"\r\n\r\nexport const MIN_TAB_OFFSET: number = 0\r\nexport const MAX_TAB_OFFSET: number = 20\r\nexport const DEFAULT_TAB_OFFSET: number = 2\r\nexport const TAB_OFFSET_UNIT: string = \"tabs\"\r\n\r\nexport const MIN_HITSLOP: number = 0\r\nexport const MAX_HITSLOP: number = 2000\r\nexport const DEFAULT_HITSLOP: number = 0\r\n\r\nexport const DEFAULT_SCROLL_MARGIN: number = 150\r\nexport const MIN_SCROLL_MARGIN: number = 30\r\nexport const MAX_SCROLL_MARGIN: number = 300\r\nexport const SCROLL_MARGIN_UNIT: string = \"px\"\r\n\r\nexport const DEFAULT_ENABLE_TAB_PREDICTION: boolean = true\r\nexport const DEFAULT_ENABLE_MOUSE_PREDICTION: boolean = true\r\nexport const DEFAULT_ENABLE_SCROLL_PREDICTION: boolean = true\r\nexport const DEFAULT_IS_DEBUGGER_MINIMIZED: boolean = false\r\nexport const DEFAULT_SHOW_NAME_TAGS: boolean = true\r\nexport const DEFAULT_IS_DEBUG: boolean = false\r\nexport const DEFAULT_SORT_ELEMENT_LIST: SortElementList = \"visibility\"\r\n","/**\r\n * Converts a JavaScript object into a readable method call string format.\r\n *\r\n * This utility is designed for copying object configurations and transforming them\r\n * into method call syntax for easy copy-pasting of global settings or configurations.\r\n *\r\n * @template T - The type of the input object, constrained to Record<string, any>\r\n * @param obj - The object to convert to method call format\r\n * @param methodName - The name of the method to wrap the object in (e.g., 'ForesightManager.initialize')\r\n * @returns A formatted string representing the object as a method call with proper indentation\r\n *\r\n * @example\r\n * ```typescript\r\n * const config = {\r\n * debug: true,\r\n * settings: { enabled: false }\r\n * };\r\n *\r\n * const result = objectToMethodCall(config, 'MyClass.configure');\r\n * // Returns:\r\n * // MyClass.configure({\r\n * // debug: true,\r\n * // settings: {\r\n * // enabled: false\r\n * // }\r\n * // })\r\n * ```\r\n */\r\nexport function objectToMethodCall<T extends Record<string, any>>(\r\n obj: T,\r\n methodName: string\r\n): string {\r\n const entries = Object.entries(obj) as Array<[keyof T, T[keyof T]]>\r\n\r\n // Filter out deprecated keys\r\n const filteredEntries = entries.filter(([key]) => {\r\n const keyStr = String(key)\r\n if (keyStr === \"resizeScrollThrottleDelay\") {\r\n return false\r\n }\r\n return true\r\n })\r\n\r\n const formattedEntries = filteredEntries\r\n .map(([key, value]) => ` ${String(key)}: ${formatValue(value)}`)\r\n .join(\",\\n\")\r\n\r\n return `${methodName}({\\n${formattedEntries}\\n})`\r\n}\r\n\r\n/**\r\n * Formats a value with proper indentation and type-appropriate string representation.\r\n *\r\n * @param value - The value to format (can be any type)\r\n * @param indent - The current indentation level (defaults to 2 spaces)\r\n * @returns A formatted string representation of the value\r\n */\r\nconst formatValue = (value: unknown, indent: number = 2): string => {\r\n const spaces = \" \".repeat(indent)\r\n\r\n if (typeof value === \"object\" && value !== null && !Array.isArray(value)) {\r\n const entries = Object.entries(value as Record<string, unknown>)\r\n if (entries.length === 0) return \"{}\"\r\n\r\n const formattedEntries = entries\r\n .map(([key, val]) => `${spaces} ${key}: ${formatValue(val, indent + 2)}`)\r\n .join(\",\\n\")\r\n\r\n return `{\\n${formattedEntries}\\n${spaces}}`\r\n }\r\n\r\n if (typeof value === \"string\") return `'${value}'`\r\n if (typeof value === \"boolean\" || typeof value === \"number\") return String(value)\r\n if (value === null) return \"null\"\r\n if (value === undefined) return \"undefined\"\r\n if (Array.isArray(value)) return JSON.stringify(value)\r\n\r\n return String(value)\r\n}\r\n","type attributes = {\r\n className?: string\r\n data?: string\r\n id?: string\r\n}\r\n\r\nexport function createAndAppendElement(\r\n tag: string,\r\n parent: Node,\r\n attributes: attributes\r\n): HTMLElement {\r\n const element = document.createElement(tag)\r\n if (attributes.id) element.id = attributes.id\r\n if (attributes.className) element.className = attributes.className\r\n if (attributes.data) element.setAttribute(\"data-value\", attributes.data)\r\n return parent.appendChild(element)\r\n}\r\n\r\nexport function createAndAppendStyle(\r\n styleSheet: string,\r\n parent: Node,\r\n id: string\r\n): HTMLStyleElement {\r\n const element = document.createElement(\"style\")\r\n element.textContent = styleSheet\r\n element.id = id\r\n return parent.appendChild(element)\r\n}\r\n","export const getIntersectingIcon = (isIntersectingWithViewport: boolean): string =>\r\n isIntersectingWithViewport ? \"👁️\" : \"🚫\"\r\n","// DebuggerControlPanel.ts\r\nimport type { ForesightManager } from \"../Manager/ForesightManager\"\r\nimport type {\r\n ForesightElementData,\r\n ForesightElement,\r\n DebuggerSettings,\r\n NumericSettingKeys,\r\n BooleanSettingKeys,\r\n ForesightManagerSettings,\r\n SortElementList,\r\n} from \"../types/types\"\r\nimport {\r\n DEFAULT_IS_DEBUGGER_MINIMIZED,\r\n DEFAULT_SHOW_NAME_TAGS,\r\n MAX_POSITION_HISTORY_SIZE,\r\n MAX_SCROLL_MARGIN,\r\n MAX_TAB_OFFSET,\r\n MAX_TRAJECTORY_PREDICTION_TIME,\r\n MIN_POSITION_HISTORY_SIZE,\r\n MIN_SCROLL_MARGIN,\r\n MIN_TAB_OFFSET,\r\n MIN_TRAJECTORY_PREDICTION_TIME,\r\n POSITION_HISTORY_SIZE_UNIT,\r\n SCROLL_MARGIN_UNIT,\r\n TAB_OFFSET_UNIT,\r\n TRAJECTORY_PREDICTION_TIME_UNIT,\r\n} from \"../Manager/constants\"\r\nimport { objectToMethodCall } from \"./helpers/objectToMethodCall\"\r\nimport { createAndAppendStyle } from \"./helpers/createAndAppend\"\r\nimport { getIntersectingIcon } from \"./helpers/getIntersectingIcon\"\r\n\r\ntype SectionStates = {\r\n mouse: boolean\r\n keyboard: boolean\r\n scroll: boolean\r\n general: boolean\r\n}\r\n\r\nconst COPY_SVG_ICON = `<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>`\r\nconst TICK_SVG_ICON = `<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>`\r\nconst SORT_SVG_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polygon points=\"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3\"></polygon></svg>`\r\nconst NO_ELEMENTS_STRING = \"<em>No elements registered.</em>\"\r\n\r\nexport class DebuggerControlPanel {\r\n private foresightManagerInstance: ForesightManager\r\n private static debuggerControlPanelInstance: DebuggerControlPanel\r\n\r\n // These properties will be assigned in _setupDOMAndListeners\r\n private shadowRoot!: ShadowRoot\r\n private controlsContainer!: HTMLElement\r\n private controlPanelStyleElement!: HTMLStyleElement\r\n private elementListItemsContainer: HTMLElement | null = null\r\n private elementCountSpan: HTMLSpanElement | null = null\r\n private callbackCountSpan: HTMLSpanElement | null = null\r\n private elementListItems: Map<ForesightElement, HTMLElement> = new Map()\r\n\r\n private trajectoryEnabledCheckbox: HTMLInputElement | null = null\r\n private tabEnabledCheckbox: HTMLInputElement | null = null\r\n private scrollEnabledCheckbox: HTMLInputElement | null = null\r\n private historySizeSlider: HTMLInputElement | null = null\r\n private historyValueSpan: HTMLSpanElement | null = null\r\n private predictionTimeSlider: HTMLInputElement | null = null\r\n private predictionValueSpan: HTMLSpanElement | null = null\r\n private tabOffsetSlider: HTMLInputElement | null = null\r\n private tabOffsetValueSpan: HTMLSpanElement | null = null\r\n private scrollMarginSlider: HTMLInputElement | null = null\r\n private scrollMarginValueSpan: HTMLSpanElement | null = null\r\n private showNameTagsCheckbox: HTMLInputElement | null = null\r\n private sortOptionsPopup: HTMLDivElement | null = null\r\n private sortButton: HTMLButtonElement | null = null\r\n\r\n private containerMinimizeButton: HTMLButtonElement | null = null\r\n private allSettingsSectionsContainer: HTMLElement | null = null\r\n private debuggerElementsSection: HTMLElement | null = null\r\n private isContainerMinimized: boolean = false\r\n\r\n private isMouseSettingsMinimized: boolean = true\r\n private isKeyboardSettingsMinimized: boolean = true\r\n private isScrollSettingsMinimized: boolean = true\r\n private isGeneralSettingsMinimized: boolean = true\r\n private readonly SESSION_STORAGE_KEY = \"jsforesightDebuggerSectionStates\"\r\n\r\n private copySettingsButton: HTMLButtonElement | null = null\r\n private copyTimeoutId: ReturnType<typeof setTimeout> | null = null\r\n private closeSortDropdownHandler: ((e: MouseEvent) => void) | null = null\r\n\r\n /**\r\n * The constructor is now minimal, only storing the manager instance.\r\n * The actual setup is deferred to _setupDOMAndListeners.\r\n */\r\n private constructor(foresightManager: ForesightManager) {\r\n this.foresightManagerInstance = foresightManager\r\n }\r\n\r\n /**\r\n * All DOM creation and event listener setup logic is moved here.\r\n * This method can be called to \"revive\" a cleaned-up instance.\r\n */\r\n private _setupDOMAndListeners(shadowRoot: ShadowRoot, debuggerSettings: DebuggerSettings) {\r\n // Guard clause to prevent re-running if the UI is already active.\r\n if (this.controlsContainer) {\r\n return\r\n }\r\n\r\n this.shadowRoot = shadowRoot\r\n this.isContainerMinimized =\r\n debuggerSettings.isControlPanelDefaultMinimized ?? DEFAULT_IS_DEBUGGER_MINIMIZED\r\n this.controlsContainer = this.createControlContainer()\r\n this.shadowRoot.appendChild(this.controlsContainer)\r\n\r\n this.controlPanelStyleElement = createAndAppendStyle(\r\n this.getStyles(),\r\n this.shadowRoot,\r\n \"debug-control-panel\"\r\n )\r\n this.queryDOMElements()\r\n this.originalSectionStates()\r\n this.setupEventListeners()\r\n this.updateContainerVisibilityState()\r\n }\r\n\r\n /**\r\n * The initialize method now creates the instance if needed,\r\n * then calls the setup method to ensure the UI is ready.\r\n */\r\n public static initialize(\r\n foresightManager: ForesightManager,\r\n shadowRoot: ShadowRoot,\r\n debuggerSettings: DebuggerSettings\r\n ): DebuggerControlPanel {\r\n if (!DebuggerControlPanel.isInitiated) {\r\n DebuggerControlPanel.debuggerControlPanelInstance = new DebuggerControlPanel(foresightManager)\r\n }\r\n\r\n const instance = DebuggerControlPanel.debuggerControlPanelInstance\r\n\r\n // This will build the DOM on first run or rebuild it on subsequent runs after cleanup.\r\n instance._setupDOMAndListeners(shadowRoot, debuggerSettings)\r\n\r\n return instance\r\n }\r\n\r\n private static get isInitiated(): boolean {\r\n return !!DebuggerControlPanel.debuggerControlPanelInstance\r\n }\r\n\r\n private loadSectionStatesFromSessionStorage(): Partial<SectionStates> {\r\n const storedStatesRaw = sessionStorage.getItem(this.SESSION_STORAGE_KEY)\r\n let loadedStates: Partial<SectionStates> = {}\r\n\r\n if (storedStatesRaw) {\r\n loadedStates = JSON.parse(storedStatesRaw)\r\n }\r\n\r\n this.isMouseSettingsMinimized = loadedStates.mouse ?? true\r\n this.isKeyboardSettingsMinimized = loadedStates.keyboard ?? true\r\n this.isScrollSettingsMinimized = loadedStates.scroll ?? true\r\n this.isGeneralSettingsMinimized = loadedStates.general ?? true\r\n return loadedStates\r\n }\r\n\r\n private saveSectionStatesToSessionStorage() {\r\n const states: SectionStates = {\r\n mouse: this.isMouseSettingsMinimized,\r\n keyboard: this.isKeyboardSettingsMinimized,\r\n scroll: this.isScrollSettingsMinimized,\r\n general: this.isGeneralSettingsMinimized,\r\n }\r\n try {\r\n sessionStorage.setItem(this.SESSION_STORAGE_KEY, JSON.stringify(states))\r\n } catch (e) {\r\n console.error(\"Foresight Debugger: Could not save section states to session storage.\", e)\r\n }\r\n }\r\n\r\n private queryDOMElements() {\r\n this.trajectoryEnabledCheckbox = this.controlsContainer.querySelector(\"#trajectory-enabled\")\r\n this.tabEnabledCheckbox = this.controlsContainer.querySelector(\"#tab-enabled\")\r\n this.scrollEnabledCheckbox = this.controlsContainer.querySelector(\"#scroll-enabled\")\r\n this.historySizeSlider = this.controlsContainer.querySelector(\"#history-size\")\r\n this.historyValueSpan = this.controlsContainer.querySelector(\"#history-value\")\r\n this.predictionTimeSlider = this.controlsContainer.querySelector(\"#prediction-time\")\r\n this.predictionValueSpan = this.controlsContainer.querySelector(\"#prediction-value\")\r\n this.tabOffsetSlider = this.controlsContainer.querySelector(\"#tab-offset\")\r\n this.tabOffsetValueSpan = this.controlsContainer.querySelector(\"#tab-offset-value\")\r\n this.scrollMarginSlider = this.controlsContainer.querySelector(\"#scroll-margin\")\r\n this.scrollMarginValueSpan = this.controlsContainer.querySelector(\"#scroll-margin-value\")\r\n this.elementListItemsContainer = this.controlsContainer.querySelector(\r\n \"#element-list-items-container\"\r\n )\r\n this.showNameTagsCheckbox = this.controlsContainer.querySelector(\"#toggle-name-tags\")\r\n this.sortOptionsPopup = this.controlsContainer.querySelector(\"#sort-options-popup\")\r\n this.sortButton = this.controlsContainer.querySelector(\".sort-button\")\r\n this.elementCountSpan = this.controlsContainer.querySelector(\"#element-count\")\r\n this.callbackCountSpan = this.controlsContainer.querySelector(\"#callback-count\")\r\n this.containerMinimizeButton = this.controlsContainer.querySelector(\".minimize-button\")\r\n this.allSettingsSectionsContainer = this.controlsContainer.querySelector(\r\n \".all-settings-sections-container\"\r\n )\r\n this.debuggerElementsSection = this.controlsContainer.querySelector(\".debugger-elements\")\r\n this.copySettingsButton = this.controlsContainer.querySelector(\".copy-settings-button\")\r\n }\r\n\r\n private handleCopySettings() {\r\n if (!this.copySettingsButton) return\r\n navigator.clipboard\r\n .writeText(\r\n objectToMethodCall(\r\n this.foresightManagerInstance.getManagerData.globalSettings,\r\n \"ForesightManager.initialize\"\r\n )\r\n )\r\n .then(() => {\r\n this.copySettingsButton!.innerHTML = TICK_SVG_ICON\r\n if (this.copyTimeoutId) {\r\n clearTimeout(this.copyTimeoutId)\r\n }\r\n this.copyTimeoutId = setTimeout(() => {\r\n if (this.copySettingsButton) {\r\n this.copySettingsButton.innerHTML = COPY_SVG_ICON\r\n }\r\n this.copyTimeoutId = null\r\n }, 3000)\r\n })\r\n .catch((err) => {\r\n console.error(\"Foresight Debugger: Could not copy settings to clipboard\", err)\r\n })\r\n }\r\n\r\n private createInputEventListener(\r\n element: HTMLInputElement | null,\r\n spanElement: HTMLSpanElement | null,\r\n unit: string,\r\n setting: NumericSettingKeys\r\n ) {\r\n if (!element || !spanElement) {\r\n return\r\n }\r\n element.addEventListener(\"input\", (e) => {\r\n const value = parseInt((e.target as HTMLInputElement).value, 10)\r\n spanElement.textContent = `${value} ${unit}`\r\n this.foresightManagerInstance.alterGlobalSettings({\r\n [setting]: value,\r\n })\r\n })\r\n }\r\n\r\n private createChangeEventListener(\r\n element: HTMLElement | null,\r\n setting: BooleanSettingKeys | \"name-tag\"\r\n ) {\r\n if (!element) {\r\n return\r\n }\r\n element.addEventListener(\"change\", (e) => {\r\n if (setting === \"name-tag\") {\r\n this.foresightManagerInstance.alterGlobalSettings({\r\n debuggerSettings: {\r\n showNameTags: (e.target as HTMLInputElement).checked,\r\n },\r\n })\r\n } else {\r\n this.foresightManagerInstance.alterGlobalSettings({\r\n [setting]: (e.target as HTMLInputElement).checked,\r\n })\r\n }\r\n })\r\n }\r\n\r\n private createSectionVisibilityToggleEventListener(\r\n section: HTMLDivElement | null,\r\n isMinimizedFlagName:\r\n | \"isMouseSettingsMinimized\"\r\n | \"isKeyboardSettingsMinimized\"\r\n | \"isScrollSettingsMinimized\"\r\n | \"isGeneralSettingsMinimized\"\r\n ) {\r\n const sectionHeader = section?.querySelector(\".debugger-section-header\")\r\n sectionHeader?.addEventListener(\"click\", (e) => {\r\n e.stopPropagation()\r\n this.toggleMinimizeSection(section, (this[isMinimizedFlagName] = !this[isMinimizedFlagName]))\r\n })\r\n }\r\n\r\n private setupEventListeners() {\r\n this.createChangeEventListener(this.trajectoryEnabledCheckbox, \"enableMousePrediction\")\r\n this.createChangeEventListener(this.tabEnabledCheckbox, \"enableTabPrediction\")\r\n this.createChangeEventListener(this.scrollEnabledCheckbox, \"enableScrollPrediction\")\r\n this.createChangeEventListener(this.showNameTagsCheckbox, \"name-tag\")\r\n this.createInputEventListener(\r\n this.historySizeSlider,\r\n this.historyValueSpan,\r\n POSITION_HISTORY_SIZE_UNIT,\r\n \"positionHistorySize\"\r\n )\r\n\r\n this.createInputEventListener(\r\n this.predictionTimeSlider,\r\n this.predictionValueSpan,\r\n TRAJECTORY_PREDICTION_TIME_UNIT,\r\n \"trajectoryPredictionTime\"\r\n )\r\n\r\n this.createInputEventListener(\r\n this.tabOffsetSlider,\r\n this.tabOffsetValueSpan,\r\n TAB_OFFSET_UNIT,\r\n \"tabOffset\"\r\n )\r\n\r\n this.createInputEventListener(\r\n this.scrollMarginSlider,\r\n this.scrollMarginValueSpan,\r\n SCROLL_MARGIN_UNIT,\r\n \"scrollMargin\"\r\n )\r\n\r\n this.sortButton?.addEventListener(\"click\", (e) => {\r\n e.stopPropagation()\r\n this.sortOptionsPopup?.classList.toggle(\"active\")\r\n })\r\n\r\n this.sortOptionsPopup?.addEventListener(\"click\", (e) => {\r\n const target = e.target as HTMLElement\r\n const sortButton = target.closest(\"[data-sort]\") as HTMLElement | null\r\n if (!sortButton) return\r\n\r\n const value = sortButton.dataset.sort as SortElementList\r\n this.foresightManagerInstance.alterGlobalSettings({\r\n debuggerSettings: {\r\n sortElementList: value,\r\n },\r\n })\r\n console.log(\"here\")\r\n this.sortAndReorderElements()\r\n this.updateSortOptionUI(value)\r\n this.sortOptionsPopup?.classList.remove(\"active\")\r\n })\r\n\r\n this.closeSortDropdownHandler = (e: MouseEvent) => {\r\n if (\r\n this.sortOptionsPopup?.classList.contains(\"active\") &&\r\n !this.sortButton?.contains(e.target as Node)\r\n ) {\r\n this.sortOptionsPopup.classList.remove(\"active\")\r\n }\r\n }\r\n document.addEventListener(\"click\", this.closeSortDropdownHandler)\r\n\r\n this.containerMinimizeButton?.addEventListener(\"click\", () => {\r\n this.isContainerMinimized = !this.isContainerMinimized\r\n this.updateContainerVisibilityState()\r\n })\r\n this.copySettingsButton?.addEventListener(\"click\", this.handleCopySettings.bind(this))\r\n\r\n this.createSectionVisibilityToggleEventListener(\r\n this.controlsContainer.querySelector(\".mouse-settings-section\"),\r\n \"isMouseSettingsMinimized\"\r\n )\r\n this.createSectionVisibilityToggleEventListener(\r\n this.controlsContainer.querySelector(\".keyboard-settings-section\"),\r\n \"isKeyboardSettingsMinimized\"\r\n )\r\n this.createSectionVisibilityToggleEventListener(\r\n this.controlsContainer.querySelector(\".scroll-settings-section\"),\r\n \"isScrollSettingsMinimized\"\r\n )\r\n this.createSectionVisibilityToggleEventListener(\r\n this.controlsContainer.querySelector(\".general-settings-section\"),\r\n \"isGeneralSettingsMinimized\"\r\n )\r\n }\r\n\r\n private toggleMinimizeSection(section: HTMLDivElement | null, shouldMinimize: boolean) {\r\n if (!section) {\r\n return\r\n }\r\n const sectionContent: HTMLDivElement | null = section.querySelector(\".debugger-section-content\")\r\n const minimizeButton: HTMLButtonElement | null = section.querySelector(\r\n \".section-minimize-button\"\r\n )\r\n if (sectionContent && minimizeButton) {\r\n if (shouldMinimize) {\r\n sectionContent.style.display = \"none\"\r\n minimizeButton.textContent = \"+\"\r\n } else {\r\n sectionContent.style.display = \"flex\"\r\n minimizeButton.textContent = \"-\"\r\n }\r\n }\r\n this.saveSectionStatesToSessionStorage()\r\n }\r\n\r\n private originalSectionStates() {\r\n const states = this.loadSectionStatesFromSessionStorage()\r\n this.toggleMinimizeSection(\r\n this.controlsContainer.querySelector(\".mouse-settings-section\"),\r\n states.mouse ?? true\r\n )\r\n this.toggleMinimizeSection(\r\n this.controlsContainer.querySelector(\".keyboard-settings-section\"),\r\n states.keyboard ?? true\r\n )\r\n this.toggleMinimizeSection(\r\n this.controlsContainer.querySelector(\".scroll-settings-section\"),\r\n states.scroll ?? true\r\n )\r\n this.toggleMinimizeSection(\r\n this.controlsContainer.querySelector(\".general-settings-section\"),\r\n states.general ?? true\r\n )\r\n // Ensure the element list is always open by default\r\n const elementListContent = this.debuggerElementsSection?.querySelector(\r\n \".debugger-section-content\"\r\n )\r\n if (elementListContent) {\r\n ;(elementListContent as HTMLElement).style.display = \"flex\"\r\n }\r\n }\r\n\r\n private updateContainerVisibilityState() {\r\n if (!this.containerMinimizeButton) return\r\n if (this.isContainerMinimized) {\r\n this.controlsContainer.classList.add(\"minimized\")\r\n this.containerMinimizeButton.textContent = \"+\"\r\n if (this.allSettingsSectionsContainer)\r\n this.allSettingsSectionsContainer.style.display = \"none\"\r\n if (this.debuggerElementsSection) this.debuggerElementsSection.style.display = \"none\"\r\n if (this.copySettingsButton) this.copySettingsButton.style.display = \"none\"\r\n } else {\r\n this.controlsContainer.classList.remove(\"minimized\")\r\n this.containerMinimizeButton.textContent = \"-\"\r\n if (this.allSettingsSectionsContainer) this.allSettingsSectionsContainer.style.display = \"\"\r\n if (this.debuggerElementsSection) this.debuggerElementsSection.style.display = \"\"\r\n if (this.copySettingsButton) this.copySettingsButton.style.display = \"\"\r\n }\r\n }\r\n\r\n // Adds a tick before the choosen sort option\r\n private updateSortOptionUI(currentSort: SortElementList) {\r\n this.sortOptionsPopup?.querySelectorAll(\"[data-sort]\").forEach((button) => {\r\n const btn = button as HTMLElement\r\n if (btn.dataset.sort === currentSort) {\r\n btn.classList.add(\"active-sort-option\")\r\n } else {\r\n btn.classList.remove(\"active-sort-option\")\r\n }\r\n })\r\n }\r\n\r\n public updateControlsState(settings: ForesightManagerSettings) {\r\n if (this.trajectoryEnabledCheckbox) {\r\n this.trajectoryEnabledCheckbox.checked = settings.enableMousePrediction\r\n }\r\n if (this.tabEnabledCheckbox) {\r\n this.tabEnabledCheckbox.checked = settings.enableTabPrediction\r\n }\r\n if (this.scrollEnabledCheckbox) {\r\n this.scrollEnabledCheckbox.checked = settings.enableScrollPrediction\r\n }\r\n if (this.showNameTagsCheckbox) {\r\n this.showNameTagsCheckbox.checked =\r\n settings.debuggerSettings.showNameTags ?? DEFAULT_SHOW_NAME_TAGS\r\n }\r\n this.updateSortOptionUI(settings.debuggerSettings.sortElementList ?? \"visibility\")\r\n if (this.historySizeSlider && this.historyValueSpan) {\r\n this.historySizeSlider.value = settings.positionHistorySize.toString()\r\n this.historyValueSpan.textContent = `${settings.positionHistorySize} ${POSITION_HISTORY_SIZE_UNIT}`\r\n }\r\n if (this.predictionTimeSlider && this.predictionValueSpan) {\r\n this.predictionTimeSlider.value = settings.trajectoryPredictionTime.toString()\r\n this.predictionValueSpan.textContent = `${settings.trajectoryPredictionTime} ${TRAJECTORY_PREDICTION_TIME_UNIT}`\r\n }\r\n if (this.tabOffsetSlider && this.tabOffsetValueSpan) {\r\n this.tabOffsetSlider.value = settings.tabOffset.toString()\r\n this.tabOffsetValueSpan.textContent = `${settings.tabOffset} ${TAB_OFFSET_UNIT}`\r\n }\r\n if (this.scrollMarginSlider && this.scrollMarginValueSpan) {\r\n this.scrollMarginSlider.value = settings.scrollMargin.toString()\r\n this.scrollMarginValueSpan.textContent = `${settings.scrollMargin} ${SCROLL_MARGIN_UNIT}`\r\n }\r\n }\r\n\r\n private refreshRegisteredElementCountDisplay(\r\n elementsMap: ReadonlyMap<Element, ForesightElementData>\r\n ) {\r\n if (!this.elementCountSpan || !this.callbackCountSpan) {\r\n return\r\n }\r\n\r\n let visibleElementCount = 0\r\n elementsMap.forEach((data) => {\r\n if (data.isIntersectingWithViewport) {\r\n visibleElementCount++\r\n }\r\n })\r\n const totalElements = elementsMap.size\r\n const { tab, mouse, scroll, total } =\r\n this.foresightManagerInstance.getManagerData.globalCallbackHits\r\n this.elementCountSpan.textContent = `Visible: ${visibleElementCount}/${totalElements} ~ `\r\n this.elementCountSpan.title = [\r\n \"Element Visibility Status\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n `Visible in Viewport: ${visibleElementCount}`,\r\n `Not in Viewport: ${totalElements - visibleElementCount}`,\r\n `Total Registered Elements: ${totalElements}`,\r\n \"\",\r\n \"Note: Only elements visible in the viewport\",\r\n \"are actively tracked by intersection observers.\",\r\n ].join(\"\\n\")\r\n this.callbackCountSpan.textContent = `Mouse: ${mouse.hover + mouse.trajectory} Tab: ${\r\n tab.forwards + tab.reverse\r\n } Scroll: ${scroll.down + scroll.left + scroll.right + scroll.up}`\r\n this.callbackCountSpan.title = [\r\n \"Callback Execution Stats\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Mouse Callbacks\",\r\n ` • Trajectory: ${mouse.trajectory}`,\r\n ` • Hover: ${mouse.hover}`,\r\n ` • Subtotal: ${mouse.hover + mouse.trajectory}`,\r\n \"\",\r\n \"Keyboard Callbacks:\",\r\n ` • Tab Forward: ${tab.forwards}`,\r\n ` • Tab Reverse: ${tab.reverse}`,\r\n ` • Subtotal: ${tab.forwards + tab.reverse}`,\r\n \"\",\r\n \"Scroll Callbacks:\",\r\n ` • Up: ${scroll.up} | Down: ${scroll.down}`,\r\n ` • Left: ${scroll.left} | Right: ${scroll.right}`,\r\n ` • Subtotal: ${scroll.up + scroll.down + scroll.left + scroll.right}`,\r\n \"\",\r\n \"Total Callbacks: \" + total,\r\n ].join(\"\\n\")\r\n }\r\n\r\n public removeElementFromList(elementData: ForesightElementData) {\r\n if (!this.elementListItemsContainer) return\r\n\r\n const listItem = this.elementListItems.get(elementData.element)\r\n\r\n if (listItem) {\r\n listItem.remove()\r\n this.elementListItems.delete(elementData.element)\r\n const elementsMap = this.foresightManagerInstance.registeredElements\r\n this.refreshRegisteredElementCountDisplay(elementsMap)\r\n\r\n if (this.elementListItems.size === 0) {\r\n this.elementListItemsContainer.innerHTML = NO_ELEMENTS_STRING\r\n }\r\n }\r\n }\r\n\r\n public updateElementVisibilityStatus(elementData: ForesightElementData) {\r\n if (!this.elementListItemsContainer) return\r\n const listItem = this.elementListItems.get(elementData.element)\r\n if (!listItem) {\r\n this.addElementToList(elementData)\r\n return\r\n }\r\n\r\n listItem.classList.toggle(\"not-in-viewport\", !elementData.isIntersectingWithViewport)\r\n const intersectingElement = listItem.querySelector(\".intersecting-indicator\")\r\n if (intersectingElement) {\r\n const intersectingIcon = getIntersectingIcon(elementData.isIntersectingWithViewport)\r\n intersectingElement.textContent = intersectingIcon\r\n }\r\n this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements)\r\n this.sortAndReorderElements()\r\n }\r\n\r\n private sortAndReorderElements() {\r\n if (!this.elementListItemsContainer) return\r\n\r\n const sortOrder =\r\n this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings\r\n .sortElementList ?? \"visibility\"\r\n\r\n const elementsData = Array.from(this.foresightManagerInstance.registeredElements.values())\r\n\r\n if (sortOrder !== \"insertionOrder\") {\r\n const sortByDocumentPosition = (a: ForesightElementData, b: ForesightElementData) => {\r\n const position = a.element.compareDocumentPosition(b.element)\r\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1\r\n if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1\r\n return 0\r\n }\r\n\r\n if (sortOrder === \"visibility\") {\r\n elementsData.sort((a, b) => {\r\n if (a.isIntersectingWithViewport !== b.isIntersectingWithViewport) {\r\n return a.isIntersectingWithViewport ? -1 : 1\r\n }\r\n return sortByDocumentPosition(a, b)\r\n })\r\n } else if (sortOrder === \"documentOrder\") {\r\n elementsData.sort(sortByDocumentPosition)\r\n }\r\n }\r\n\r\n const fragment = document.createDocumentFragment()\r\n\r\n if (elementsData.length) {\r\n elementsData.forEach((elementData) => {\r\n const listItem = this.elementListItems.get(elementData.element)\r\n if (listItem) {\r\n // Appending to the fragment is cheap (it's off-screen)\r\n fragment.appendChild(listItem)\r\n }\r\n })\r\n\r\n this.elementListItemsContainer.innerHTML = \"\"\r\n this.elementListItemsContainer.appendChild(fragment)\r\n }\r\n }\r\n\r\n public addElementToList(elementData: ForesightElementData, sort: boolean = true) {\r\n if (!this.elementListItemsContainer) return\r\n if (this.elementListItemsContainer.innerHTML === NO_ELEMENTS_STRING) {\r\n this.elementListItemsContainer.innerHTML = \"\"\r\n }\r\n if (this.elementListItems.has(elementData.element)) return\r\n const listItem = document.createElement(\"div\")\r\n listItem.className = \"element-list-item\"\r\n this.updateListItemContent(listItem, elementData)\r\n this.elementListItemsContainer!.appendChild(listItem)\r\n this.elementListItems.set(elementData.element, listItem)\r\n this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements)\r\n if (sort) {\r\n this.sortAndReorderElements()\r\n }\r\n }\r\n\r\n private updateListItemContent(listItem: HTMLElement, elementData: ForesightElementData) {\r\n // Determine the viewport icon based on current visibility status\r\n const intersectingIcon = getIntersectingIcon(elementData.isIntersectingWithViewport)\r\n listItem.classList.toggle(\"not-in-viewport\", !elementData.isIntersectingWithViewport)\r\n const hitBehaviorText = elementData.unregisterOnCallback ? \"Single\" : \"Multi\"\r\n let hitSlopText = \"N/A\"\r\n\r\n if (elementData.elementBounds.hitSlop) {\r\n const { top, right, bottom, left } = elementData.elementBounds.hitSlop\r\n hitSlopText = `T:${top} R:${right} B:${bottom} L:${left}`\r\n }\r\n\r\n // Create comprehensive title with all information\r\n const comprehensiveTitle = [\r\n `${elementData.name || \"Unnamed Element\"}`,\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Viewport Status:\",\r\n elementData.isIntersectingWithViewport\r\n ? \" ✓ In viewport - actively tracked by observers\"\r\n : \" ✗ Not in viewport - not being tracked\",\r\n \"\",\r\n \"Hit Behavior:\",\r\n elementData.unregisterOnCallback\r\n ? \" • Single: Callback triggers once\"\r\n : \" • Multi: Callback can trigger multiple times\",\r\n \"\",\r\n \"Hit Slop:\",\r\n elementData.elementBounds.hitSlop\r\n ? [\r\n ` Top: ${elementData.elementBounds.hitSlop.top}px, Bottom: ${elementData.elementBounds.hitSlop.bottom}px `,\r\n ` Right: ${elementData.elementBounds.hitSlop.right}px, Left: ${elementData.elementBounds.hitSlop.left}px`,\r\n ].join(\"\\n\")\r\n : \" • Not defined - using element's natural boundaries\",\r\n \"\",\r\n ].join(\"\\n\")\r\n\r\n listItem.title = comprehensiveTitle\r\n\r\n listItem.innerHTML = `\r\n <span class=\"intersecting-indicator\">${intersectingIcon}</span>\r\n <span class=\"element-name\">${elementData.name || \"Unnamed Element\"}</span>\r\n <span class=\"hit-slop\">${hitSlopText}</span>\r\n <span class=\"hit-behavior\">${hitBehaviorText}</span>\r\n `\r\n }\r\n /**\r\n * The cleanup method is updated to be more thorough, nullifying all\r\n * DOM-related properties to put the instance in a dormant state.\r\n */\r\n public cleanup() {\r\n this.controlsContainer?.remove()\r\n this.controlPanelStyleElement?.remove()\r\n\r\n if (this.copyTimeoutId) {\r\n clearTimeout(this.copyTimeoutId)\r\n this.copyTimeoutId = null\r\n }\r\n\r\n if (this.closeSortDropdownHandler) {\r\n document.removeEventListener(\"click\", this.closeSortDropdownHandler)\r\n this.closeSortDropdownHandler = null\r\n }\r\n\r\n // Nullify all DOM-related properties to signal it's \"cleaned up\"\r\n this.controlsContainer = null!\r\n this.controlPanelStyleElement = null!\r\n this.elementListItemsContainer = null\r\n this.elementCountSpan = null\r\n this.callbackCountSpan = null\r\n this.elementListItems.clear()\r\n this.containerMinimizeButton = null\r\n this.allSettingsSectionsContainer = null\r\n this.debuggerElementsSection = null\r\n this.trajectoryEnabledCheckbox = null\r\n this.tabEnabledCheckbox = null\r\n this.scrollEnabledCheckbox = null\r\n this.historySizeSlider = null\r\n this.historyValueSpan = null\r\n this.predictionTimeSlider = null\r\n this.predictionValueSpan = null\r\n this.tabOffsetSlider = null\r\n this.tabOffsetValueSpan = null\r\n this.scrollMarginSlider = null\r\n this.scrollMarginValueSpan = null\r\n this.showNameTagsCheckbox = null\r\n this.sortOptionsPopup = null\r\n this.sortButton = null\r\n this.copySettingsButton = null\r\n }\r\n\r\n private createControlContainer(): HTMLElement {\r\n const container = document.createElement(\"div\")\r\n container.id = \"debug-controls\"\r\n container.innerHTML = `\r\n <div class=\"debugger-title-container\">\r\n <button class=\"minimize-button\">-</button>\r\n <div class=\"title-group\">\r\n <h2>Foresight Debugger</h2>\r\n <span class=\"info-icon\" title=\"${[\r\n \"Foresight Debugger Information\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Session-Only Changes:\",\r\n \"All adjustments made here apply only to the\",\r\n \"current browser session and won't persist.\",\r\n \"\",\r\n \"Permanent Configuration:\",\r\n \"To make lasting changes, update the initial\",\r\n \"values in your ForesightManager.initialize().\",\r\n \"\",\r\n \"You can copy the current debugger settings\",\r\n \"with the button on the right\",\r\n ].join(\"\\n\")}\">i</span>\r\n </div>\r\n <button class=\"copy-settings-button\" title=\"${[\r\n \"Copy Settings to Clipboard\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Copies the current configuration as a\",\r\n \"formatted method call that you can paste\",\r\n \"directly into your code.\",\r\n ].join(\"\\n\")}\">\r\n ${COPY_SVG_ICON}\r\n </button>\r\n </div>\r\n\r\n <div class=\"all-settings-sections-container\">\r\n <div class=\"debugger-section mouse-settings-section\">\r\n <div class=\"debugger-section-header collapsible\">\r\n <h3>Mouse Settings</h3>\r\n <button class=\"section-minimize-button\">-</button>\r\n </div>\r\n <div class=\"debugger-section-content mouse-settings-content\">\r\n <div class=\"control-row\">\r\n <label for=\"trajectory-enabled\">\r\n Enable Mouse Prediction\r\n <span class=\"info-icon\" title=\"${[\r\n \"Mouse Prediction Control\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"When enabled: Predicts mouse movement\",\r\n \"trajectory and triggers callbacks before\",\r\n \"the cursor reaches the target element.\",\r\n \"\",\r\n \"When disabled: Only direct hover events\",\r\n \"trigger actions (next to tab/scroll).\",\r\n \"\",\r\n \"Property: enableMousePrediction\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"checkbox\" id=\"trajectory-enabled\">\r\n </div>\r\n <div class=\"control-row\">\r\n <label for=\"history-size\">\r\n History Size\r\n <span class=\"info-icon\" title=\"${[\r\n \"Position History\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Controls how many past mouse positions\",\r\n \"are stored for velocity calculations.\",\r\n \"\",\r\n \"Higher values:\",\r\n \" • More accurate trajectory predictions\",\r\n \" • Smoother movement detection\",\r\n \" • Slightly increased processing overhead\",\r\n \"\",\r\n \"Lower values:\",\r\n \" • Faster response to direction changes\",\r\n \" • Less memory usage\",\r\n \" • May be less accurate for fast movements\",\r\n \"\",\r\n \"Property: positionHistorySize\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"range\" id=\"history-size\" min=\"${MIN_POSITION_HISTORY_SIZE}\" max=\"${MAX_POSITION_HISTORY_SIZE}\">\r\n <span id=\"history-value\"></span>\r\n </div>\r\n <div class=\"control-row\">\r\n <label for=\"prediction-time\">\r\n Prediction Time\r\n <span class=\"info-icon\" title=\"${[\r\n \"Trajectory Prediction Time\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n `How far into the future (in ${TRAJECTORY_PREDICTION_TIME_UNIT})`,\r\n \"to calculate the mouse trajectory path.\",\r\n \"\",\r\n \"Larger values:\",\r\n \" • Elements are detected sooner\",\r\n \" • More time for preloading/preparation\",\r\n \" • May trigger false positives for curved paths\",\r\n \"\",\r\n \"Smaller values:\",\r\n \" • More precise targeting\",\r\n \" • Reduced false positive rate\",\r\n \" • Less time for preparation\",\r\n \"\",\r\n \"Property: trajectoryPredictionTime\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"range\" id=\"prediction-time\" min=\"${MIN_TRAJECTORY_PREDICTION_TIME}\" max=\"${MAX_TRAJECTORY_PREDICTION_TIME}\" step=\"10\">\r\n <span id=\"prediction-value\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"debugger-section keyboard-settings-section\">\r\n <div class=\"debugger-section-header collapsible\">\r\n <h3>Keyboard Settings</h3>\r\n <button class=\"section-minimize-button\">-</button>\r\n </div>\r\n <div class=\"debugger-section-content keyboard-settings-content\">\r\n <div class=\"control-row\">\r\n <label for=\"tab-enabled\">\r\n Enable Tab Prediction\r\n <span class=\"info-icon\" title=\"${[\r\n \"Tab Navigation Prediction\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"When enabled: Callbacks are executed when\",\r\n `the user is ${this.foresightManagerInstance.getManagerData.globalSettings.tabOffset} (tabOffset) ${TAB_OFFSET_UNIT} away from`,\r\n \"a registered element during tab navigation.\",\r\n \"\",\r\n \"(works with Shift+Tab too).\",\r\n \"\",\r\n \"Property: enableTabPrediction\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"checkbox\" id=\"tab-enabled\">\r\n </div>\r\n <div class=\"control-row\">\r\n <label for=\"tab-offset\">\r\n Tab Offset\r\n <span class=\"info-icon\" title=\"${[\r\n \"Tab Offset\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Number of tabbable elements to look ahead\",\r\n \"when predicting tab navigation targets.\",\r\n \"\",\r\n \"How it works:\",\r\n \" • Tracks the current focused element\",\r\n \" • Looks ahead by the specified offset\",\r\n \" • Triggers callbacks for registered elements\",\r\n \" within that range\",\r\n \"\",\r\n \"Property: tabOffset\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"range\" id=\"tab-offset\" min=\"${MIN_TAB_OFFSET}\" max=\"${MAX_TAB_OFFSET}\" step=\"1\">\r\n <span id=\"tab-offset-value\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"debugger-section scroll-settings-section\">\r\n <div class=\"debugger-section-header collapsible\">\r\n <h3>Scroll Settings</h3>\r\n <button class=\"section-minimize-button\">-</button>\r\n </div>\r\n <div class=\"debugger-section-content scroll-settings-content\">\r\n <div class=\"control-row\">\r\n <label for=\"scroll-enabled\">\r\n Enable Scroll Prediction\r\n <span class=\"info-icon\" title=\"${[\r\n \"Scroll Prediction\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Enables predictive scrolling based on mouse\",\r\n \"position and scroll direction.\",\r\n \"\",\r\n \"When enabled, calculates scroll direction from\",\r\n \"mouse movement and triggers callbacks for\",\r\n \"elements that intersect the predicted path.\",\r\n \"\",\r\n \"Property: enableScrollPrediction\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"checkbox\" id=\"scroll-enabled\">\r\n </div>\r\n <div class=\"control-row\">\r\n <label for=\"scroll-margin\">\r\n Scroll Margin\r\n <span class=\"info-icon\" title=\"${[\r\n \"Scroll Margin\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Sets the pixel distance to check from the\",\r\n \"mouse position in the scroll direction.\",\r\n \"\",\r\n \"Higher values check further ahead, allowing\",\r\n \"earlier detection of elements that will come\",\r\n \"into view during scrolling.\",\r\n \"\",\r\n \"Property: scrollMargin\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"range\" id=\"scroll-margin\" min=\"${MIN_SCROLL_MARGIN}\" max=\"${MAX_SCROLL_MARGIN}\" step=\"10\">\r\n <span id=\"scroll-margin-value\"></span>\r\n </div>\r\n </div>\r\n\r\n <div class=\"debugger-section general-settings-section\">\r\n <div class=\"debugger-section-header collapsible\">\r\n <h3>General Settings</h3>\r\n <button class=\"section-minimize-button\">-</button>\r\n </div>\r\n <div class=\"debugger-section-content general-settings-content\">\r\n <div class=\"control-row\">\r\n <label for=\"toggle-name-tags\">\r\n Show Name Tags\r\n <span class=\"info-icon\" title=\"${[\r\n \"Visual Debug Name Tags\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"When enabled: Displays name tags over\",\r\n \"each registered element in debug mode.\",\r\n \"\",\r\n \"Property: debuggerSettings.showNameTags\",\r\n ].join(\"\\n\")}\">i</span>\r\n </label>\r\n <input type=\"checkbox\" id=\"toggle-name-tags\">\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"debugger-section debugger-elements\">\r\n <div class=\"debugger-section-header elements-list-header\">\r\n <h3>Elements <span id=\"element-count\"></span> <span id=\"callback-count\"></span></h3>\r\n <div class=\"header-controls\">\r\n <div class=\"sort-control-container\">\r\n <button class=\"sort-button\" title=\"Change element list sort order\">\r\n ${SORT_SVG_ICON}\r\n </button>\r\n <div id=\"sort-options-popup\">\r\n <button\r\n data-sort=\"visibility\"\r\n title=\"${[\r\n \"Sort by Visibility\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Sorts elements by their viewport visibility\",\r\n \"(visible elements first), with a secondary\",\r\n \"sort by their order in the document.\",\r\n \"\",\r\n \"Property: debuggerSettings.sortElementList\",\r\n \"Value: 'visibility'\",\r\n ].join(\"\\n\")}\"\r\n>\r\n Visibility\r\n</button>\r\n<button\r\n data-sort=\"documentOrder\"\r\n title=\"${[\r\n \"Sort by Document Order\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Sorts elements based on their order of\",\r\n \"appearance in the document's structure\",\r\n \"(matching the HTML source).\",\r\n \"\",\r\n \"Property: debuggerSettings.sortElementList\",\r\n \"Value: 'documentOrder'\",\r\n ].join(\"\\n\")}\"\r\n>\r\n Document Order\r\n</button>\r\n<button\r\n data-sort=\"insertionOrder\"\r\n title=\"${[\r\n \"Sort by Insertion Order\",\r\n \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\",\r\n \"Sorts elements based on the order they\",\r\n \"were registered with the ForesightManager.\",\r\n \"\",\r\n \"Property: debuggerSettings.sortElementList\",\r\n \"Value: 'insertionOrder'\",\r\n ].join(\"\\n\")}\"\r\n>\r\n Insertion Order\r\n</button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"debugger-section-content element-list\">\r\n <div id=\"element-list-items-container\">\r\n </div>\r\n </div>\r\n </div>\r\n `\r\n return container\r\n }\r\n\r\n private getStyles(): string {\r\n const elementItemHeight = 35 // px\r\n const elementListGap = 3 // px\r\n const elementListItemsContainerPadding = 6 // px\r\n const numRowsToShow = 6\r\n const numItemsPerRow = 1\r\n\r\n const rowsContentHeight =\r\n elementItemHeight * numRowsToShow + elementListGap * (numRowsToShow - 1)\r\n const elementListContainerHeight = rowsContentHeight + elementListItemsContainerPadding * 2\r\n\r\n return `\r\n #debug-controls {\r\n position: fixed; bottom: 10px; right: 10px;\r\n background-color: rgba(0, 0, 0, 0.90); color: white; padding: 12px;\r\n border-radius: 5px; font-family: Arial, sans-serif; font-size: 13px;\r\n z-index: 10001; pointer-events: auto; display: flex; flex-direction: column; gap: 8px;\r\n width: 400px;\r\n transition: width 0.3s ease, height 0.3s ease;\r\n }\r\n #debug-controls.minimized {\r\n width: 220px;\r\n overflow: hidden;\r\n padding: 12px 0; \r\n }\r\n #debug-controls.minimized .debugger-title-container {\r\n justify-content: flex-start; \r\n padding-left: 10px; \r\n padding-right: 10px;\r\n gap: 10px; \r\n }\r\n #debug-controls.minimized .debugger-title-container h2 {\r\n display: inline;\r\n font-size: 14px;\r\n margin: 0;\r\n white-space: nowrap;\r\n }\r\n #debug-controls.minimized .info-icon {\r\n display: none;\r\n }\r\n\r\n #element-count,#callback-count {\r\n font-size: 12px;\r\n color: #9e9e9e;\r\n }\r\n\r\n .debugger-title-container {\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between; \r\n padding: 0 0px; \r\n }\r\n .title-group { \r\n display: flex;\r\n align-items: center;\r\n gap: 8px; \r\n\r\n }\r\n .minimize-button {\r\n background: none; border: none; color: white;\r\n font-size: 22px; cursor: pointer;\r\n line-height: 1;\r\n }\r\n .debugger-title-container h2 { margin: 0; font-size: 15px; }\r\n\r\n .copy-settings-button {\r\n background: none; border: none; color: white;\r\n cursor: pointer; padding: 0;\r\n display: flex; align-items: center; justify-content: center;\r\n }\r\n .copy-settings-button svg {\r\n width: 16px; height: 16px;\r\n stroke: white;\r\n }\r\n\r\n .all-settings-sections-container {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 8px;\r\n }\r\n\r\n .debugger-section-header {\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n margin-top: 5px;\r\n margin-bottom: 2px;\r\n padding-bottom: 2px;\r\n border-bottom: 1px solid #444;\r\n }\r\n .debugger-section-header.collapsible {\r\n cursor: pointer;\r\n }\r\n .debugger-section-header h3 {\r\n margin: 0;\r\n font-size: 14px;\r\n font-weight: bold;\r\n color: #b0c4de;\r\n flex-grow: 1;\r\n }\r\n\r\n .section-minimize-button {\r\n background: none;\r\n border: none;\r\n color: white;\r\n font-size: 18px;\r\n cursor: pointer;\r\n padding: 0;\r\n line-height: 1;\r\n }\r\n\r\n #debug-controls .control-row {\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n gap: 8px;\r\n }\r\n #debug-controls label {\r\n display: flex;\r\n align-items: center;\r\n gap: 5px;\r\n cursor: pointer;\r\n }\r\n #debug-controls .control-row:has(input[type=\"checkbox\"]) label {\r\n flex-grow: 1;\r\n }\r\n #debug-controls .control-row input[type=\"checkbox\"] {\r\n appearance: none; -webkit-appearance: none; -moz-appearance: none;\r\n position: relative; width: 40px; height: 18px;\r\n background-color: #555; border-radius: 10px; cursor: pointer;\r\n outline: none; transition: background-color 0.2s ease;\r\n vertical-align: middle; flex-shrink: 0; margin: 0;\r\n }\r\n #debug-controls .control-row input[type=\"checkbox\"]::before {\r\n content: \"\"; position: absolute; width: 14px; height: 14px;\r\n border-radius: 50%; background-color: white; top: 2px; left: 2px;\r\n transition: transform 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.4);\r\n }\r\n #debug-controls .control-row input[type=\"checkbox\"]:checked {\r\n background-color: #b0c4de;\r\n }\r\n #debug-controls .control-row input[type=\"checkbox\"]:checked::before {\r\n transform: translateX(22px);\r\n }\r\n #debug-controls .control-row:has(input[type=\"range\"]) label {\r\n flex-basis: 170px; flex-shrink: 0;\r\n }\r\n #debug-controls input[type=\"range\"] {\r\n flex-grow: 1; margin: 0; cursor: pointer; -webkit-appearance: none;\r\n appearance: none; background: transparent; height: 18px; vertical-align: middle;\r\n }\r\n #debug-controls input[type=\"range\"]::-webkit-slider-runnable-track {\r\n height: 6px; background: #555; border-radius: 3px;\r\n }\r\n #debug-controls input[type=\"range\"]::-moz-range-track {\r\n height: 6px; background: #555; border-radius: 3px;\r\n }\r\n #debug-controls input[type=\"range\"]::-webkit-slider-thumb {\r\n -webkit-appearance: none; appearance: none; margin-top: -5px;\r\n background: #b0c4de; height: 16px; width: 16px;\r\n border-radius: 50%; border: 1px solid #333;\r\n }\r\n #debug-controls input[type=\"range\"]::-moz-range-thumb {\r\n background: #b0c4de; height: 16px; width: 16px;\r\n border-radius: 50%; border: 1px solid #333; border: none;\r\n }\r\n #debug-controls .control-row:has(input[type=\"range\"]) span:not(.info-icon) {\r\n width: 55px; min-width: 55px; text-align: right; flex-shrink: 0;\r\n }\r\n .info-icon {\r\n display: inline-flex; align-items: center; justify-content: center;\r\n width: 16px; height: 16px; border-radius: 50%;\r\n background-color: #555; color: white; font-size: 10px;\r\n font-style: italic; font-weight: bold; font-family: 'Georgia', serif;\r\n cursor: help; user-select: none; flex-shrink: 0;\r\n }\r\n .debugger-section {\r\n display: flex; flex-direction: column; gap: 6px;\r\n }\r\n .debugger-section-content {\r\n display: none; flex-direction: column; gap: 8px;\r\n }\r\n\r\n /* Element List Styles */\r\n .elements-list-header { cursor: default; }\r\n .header-controls {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n }\r\n .sort-control-container {\r\n position: relative;\r\n }\r\n .sort-button {\r\n background: none; border: none; color: white; cursor: pointer;\r\n padding: 0; display: flex; align-items: center; justify-content: center;\r\n }\r\n .sort-button svg {\r\n width: 16px; height: 16px; stroke: #b0c4de; transition: stroke 0.2s;\r\n }\r\n .sort-button:hover svg { stroke: white; }\r\n \r\n #sort-options-popup {\r\n position: absolute;\r\n bottom: calc(100% + 5px);\r\n right: -5px;\r\n z-index: 10;\r\n display: none;\r\n flex-direction: column;\r\n gap: 4px;\r\n background-color: #3a3a3a;\r\n border: 1px solid #555;\r\n border-radius: 4px;\r\n padding: 3px;\r\n width: 200px;\r\n box-shadow: 0 4px 8px rgba(0,0,0,0.3);\r\n }\r\n #sort-options-popup.active {\r\n display: flex;\r\n }\r\n #sort-options-popup button {\r\n background: none; border: none; color: #ccc;\r\n font-size: 12px; text-align: left; padding: 5px 8px;\r\n cursor: pointer; border-radius: 3px;\r\n transition: background-color 0.2s, color 0.2s;\r\n display: flex;\r\n align-items: center;\r\n height: 26px;\r\n }\r\n #sort-options-popup button:hover {\r\n background-color: #555;\r\n color: white;\r\n }\r\n #sort-options-popup button.active-sort-option {\r\n color: #b0c4de;\r\n font-weight: bold;\r\n }\r\n #sort-options-popup button.active-sort-option::before {\r\n content: '✓';\r\n margin-right: 6px;\r\n width: 10px;\r\n }\r\n #sort-options-popup button::before {\r\n content: '';\r\n margin-right: 6px;\r\n width: 10px;\r\n }\r\n\r\n .element-list { /* Scroll container */\r\n min-height: ${elementListContainerHeight}px;\r\n max-height: ${elementListContainerHeight}px; \r\n overflow-y: auto;\r\n background-color: rgba(20, 20, 20, 0.5);\r\n border-radius: 3px;\r\n padding: 0;\r\n display: flex;\r\n }\r\n\r\n /* Modern Scrollbar Styling */\r\n .element-list::-webkit-scrollbar { width: 8px; }\r\n .element-list::-webkit-scrollbar-track { background: rgba(30, 30, 30, 0.5); border-radius: 4px; }\r\n .element-list::-webkit-scrollbar-thumb { background-color: rgba(176, 196, 222, 0.5); border-radius: 4px; border: 2px solid rgba(0, 0, 0, 0.2); }\r\n .element-list::-webkit-scrollbar-thumb:hover { background-color: rgba(176, 196, 222, 0.7); }\r\n .element-list { scrollbar-width: thin; scrollbar-color: rgba(176, 196, 222, 0.5) rgba(30, 30, 30, 0.5); }\r\n\r\n #element-list-items-container { \r\n display: flex;\r\n flex-wrap: wrap;\r\n gap: ${elementListGap}px;\r\n padding: ${elementListItemsContainerPadding}px;\r\n min-height: ${rowsContentHeight}px;\r\n box-sizing: border-box;\r\n align-content: flex-start;\r\n }\r\n #element-list-items-container > em {\r\n flex-basis: 100%;\r\n text-align: center;\r\n padding: 10px 0;\r\n font-style: italic;\r\n color: #ccc;\r\n font-size: 12px;\r\n }\r\n .element-list-item {\r\n flex-basis: calc((100% - (${\r\n numItemsPerRow - 1\r\n } * ${elementListGap}px)) / ${numItemsPerRow});\r\n flex-grow: 0;\r\n flex-shrink: 0;\r\n height: ${elementItemHeight}px;\r\n box-sizing: border-box;\r\n padding: 3px 5px;\r\n border-radius: 2px;\r\n display: flex;\r\n align-items: center;\r\n gap: 5px;\r\n background-color: rgba(50,50,50,0.7);\r\n transition: background-color 0.2s ease, opacity 0.2s ease;\r\n font-size: 11px; \r\n overflow: hidden;\r\n }\r\n \r\n /* Viewport intersection styling */\r\n .element-list-item.not-in-viewport { opacity: 0.4; }\r\n \r\n .element-list-item .element-name {\r\n flex-grow: 1;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n font-size: 12px; \r\n font-weight: bold;\r\n }\r\n .element-list-item .intersecting-indicator {\r\n font-size: 12px;\r\n flex-shrink: 0;\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n width: 16px;\r\n height: 16px;\r\n }\r\n .element-list-item .hit-behavior,\r\n .element-list-item .hit-slop {\r\n font-size: 10px; \r\n color: #b0b0b0;\r\n padding: 2px 5px; \r\n border-radius: 3px; \r\n background-color: rgba(0,0,0,0.2);\r\n flex-shrink: 0;\r\n }\r\n `\r\n }\r\n}\r\n","import type { ForesightElementData } from \"../../types/types\"\r\nimport type { ElementOverlays } from \"../ForesightDebugger\"\r\n\r\nexport function updateElementOverlays(\r\n currentOverlays: ElementOverlays,\r\n newData: ForesightElementData,\r\n showNameTags: boolean\r\n) {\r\n const { expandedOverlay, nameLabel } = currentOverlays\r\n const { expandedRect } = newData.elementBounds\r\n\r\n const expandedWidth = expandedRect.right - expandedRect.left\r\n const expandedHeight = expandedRect.bottom - expandedRect.top\r\n expandedOverlay.style.width = `${expandedWidth}px`\r\n expandedOverlay.style.height = `${expandedHeight}px`\r\n expandedOverlay.style.transform = `translate3d(${expandedRect.left}px, ${expandedRect.top}px, 0)`\r\n expandedOverlay.style.display = \"block\"\r\n\r\n nameLabel.textContent = newData.name\r\n if (newData.name === \"\" || !showNameTags) {\r\n nameLabel.style.display = \"none\"\r\n } else {\r\n nameLabel.style.display = \"block\"\r\n nameLabel.style.transform = `translate3d(${expandedRect.left}px, ${expandedRect.top - 25}px, 0)`\r\n }\r\n}\r\n","// src/utilities/Rect.ts\nvar Rect = class {\n /**\n * Intersects two DOMRects.\n *\n * @param rect1 - The first DOMRect.\n * @param rect2 - The second DOMRect.\n * @returns The intersection of the two DOMRects.\n */\n static intersect(rect1, rect2) {\n const left = Math.max(rect1.left, rect2.left);\n const right = Math.min(rect1.right, rect2.right);\n const top = Math.max(rect1.top, rect2.top);\n const bottom = Math.min(rect1.bottom, rect2.bottom);\n const width = Math.max(0, right - left);\n const height = Math.max(0, bottom - top);\n return new DOMRect(left, top, width, height);\n }\n /**\n * Clips a DOMRect to a given rectangle.\n *\n * @param rect - The DOMRect to clip.\n * @param clip - The rectangle to clip the DOMRect to.\n * @returns The clipped DOMRect.\n */\n static clip(rect, clip) {\n const updatedRect = {\n ...rect.toJSON(),\n top: rect.top + clip.top,\n left: rect.left + clip.left,\n bottom: rect.bottom - clip.bottom,\n right: rect.right - clip.right\n };\n updatedRect.width = updatedRect.right - updatedRect.left;\n updatedRect.height = updatedRect.bottom - updatedRect.top;\n return updatedRect;\n }\n /**\n * Calculates the offsets of a clipped DOMRect.\n *\n * @param rect - The DOMRect to calculate the offsets for.\n * @param clippedRect - The clipped DOMRect.\n * @returns The offsets of the clipped DOMRect.\n */\n static clipOffsets(rect, clippedRect) {\n return {\n top: clippedRect.top - rect.top,\n left: clippedRect.left - rect.left,\n bottom: rect.bottom - clippedRect.bottom,\n right: rect.right - clippedRect.right\n };\n }\n /**\n * Checks if two DOMRects are equal.\n *\n * @param rect1 - The first DOMRect.\n * @param rect2 - The second DOMRect.\n * @returns True if the DOMRects are equal, false otherwise.\n */\n static equals(rect1, rect2) {\n if (rect1 == null || rect2 == null) return rect1 === rect2;\n return rect1.x === rect2.x && rect1.y === rect2.y && rect1.width === rect2.width && rect1.height === rect2.height;\n }\n static sizeEqual(rect1, rect2) {\n return Math.round(rect1.width) === Math.round(rect2.width) && Math.round(rect1.height) === Math.round(rect2.height);\n }\n};\n\n// src/utilities/rootMargin.ts\nvar INSET = -1;\nvar MIN_SIZE = 1 - INSET * 2;\nfunction rootMargin(rect, rootBounds) {\n const width = Math.max(rect.width, MIN_SIZE);\n const height = Math.max(rect.height, MIN_SIZE);\n const top = rect.top - rootBounds.top - INSET;\n const left = rect.left - rootBounds.left - INSET;\n const right = rootBounds.right - rect.left - width - INSET;\n const bottom = rootBounds.bottom - rect.top - height - INSET;\n return `${-Math.round(top)}px ${-Math.round(right)}px ${-Math.round(bottom)}px ${-Math.round(left)}px`;\n}\n\n// src/utilities/threshold.ts\nvar threshold = [\n ...Array.from({ length: 1e3 }, (_, i) => i / 1e3),\n 1\n];\n\n// src/observers/PositionIntersectionObserver.ts\nvar PositionIntersectionObserver = class {\n constructor(element, callback, options) {\n this.#callback = callback;\n this.#options = options;\n this.#clientRect = options.clientRect;\n this.#observe(element);\n }\n #callback;\n #observer = void 0;\n #options;\n #clientRect;\n #previousIntersectionRatio = void 0;\n /**\n * The visible rectangle of the element within the root.\n *\n * @returns The visible rectangle of the element within the root.\n */\n get visibleRect() {\n const clip = this.#options.clip;\n return clip ? Rect.clip(this.#clientRect, clip) : this.#clientRect;\n }\n /**\n * Whether the element is intersecting with the root.\n *\n * @returns Whether the element is intersecting with the root.\n */\n get isIntersecting() {\n const { width, height } = this.visibleRect;\n return width > 0 && height > 0;\n }\n /**\n * Observes the element.\n */\n #observe(element) {\n const { root, rootBounds } = this.#options;\n const { visibleRect } = this;\n this.#observer?.disconnect();\n this.#observer = new IntersectionObserver(this.#onIntersection, {\n root,\n rootMargin: rootMargin(visibleRect, rootBounds),\n threshold\n });\n this.#observer.observe(element);\n }\n /**\n * The callback function for the intersection observer.\n */\n #onIntersection = (entries) => {\n if (!this.#observer) return;\n const entry = entries[entries.length - 1];\n if (entry) {\n const { intersectionRatio, boundingClientRect } = entry;\n const previousClientRect = this.#clientRect;\n this.#clientRect = boundingClientRect;\n const previousIntersectionRatio = this.#previousIntersectionRatio;\n const clientRectChanged = !Rect.equals(\n boundingClientRect,\n previousClientRect\n );\n if (intersectionRatio !== this.#previousIntersectionRatio || clientRectChanged) {\n const rootBounds = this.#options.rootBounds;\n const rootIntersection = Rect.intersect(boundingClientRect, rootBounds);\n const isIntersecting = rootIntersection.width > 0 && rootIntersection.height > 0;\n if (!isIntersecting) {\n return;\n }\n this.#previousIntersectionRatio = intersectionRatio;\n if (previousIntersectionRatio != null || clientRectChanged) {\n this.#callback(\n new PositionIntersectionObserverEntry(\n entry.target,\n boundingClientRect,\n entry.intersectionRect,\n isIntersecting,\n rootBounds\n ),\n this\n );\n this.#observe(entry.target);\n }\n }\n }\n };\n /**\n * Disconnects the position intersection observer.\n */\n disconnect() {\n this.#observer?.disconnect();\n }\n};\nvar PositionIntersectionObserverEntry = class {\n constructor(target, boundingClientRect, intersectionRect, isIntersecting, rootBounds) {\n this.target = target;\n this.boundingClientRect = boundingClientRect;\n this.intersectionRect = intersectionRect;\n this.isIntersecting = isIntersecting;\n this.rootBounds = rootBounds;\n }\n};\n\n// src/observers/RootBoundsObserver.ts\nvar RootBoundsObserver = class {\n /**\n * Creates a new root bounds observer.\n *\n * @param root - The root element to observe.\n * @param callback - The callback function to call when the root bounds change.\n */\n constructor(target, callback) {\n const root = getRoot(target);\n if (isElement(root)) {\n const ownerDocument = root.ownerDocument ?? document;\n this.rootBounds = root.getBoundingClientRect();\n this.#resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const [{ inlineSize: width, blockSize: height }] = entry.borderBoxSize;\n if (Rect.sizeEqual(this.rootBounds, { width, height })) {\n continue;\n }\n const rect = entry.target.getBoundingClientRect();\n this.rootBounds = rect;\n callback(rect, this);\n }\n });\n this.#resizeObserver.observe(root);\n ownerDocument.addEventListener(\n \"scroll\",\n (event) => {\n if (event.target && event.target !== root && isNode(event.target) && event.target.contains(root)) {\n this.rootBounds = root.getBoundingClientRect();\n callback(this.rootBounds, this);\n }\n },\n { capture: true, passive: true, signal: this.#controller.signal }\n );\n } else {\n const viewport = root.visualViewport ?? root;\n this.rootBounds = getWindowRect(root);\n const handleResize = () => {\n const rect = getWindowRect(root);\n if (Rect.equals(this.rootBounds, rect)) return;\n this.rootBounds = rect;\n callback(rect, this);\n };\n viewport.addEventListener(\"resize\", handleResize, {\n signal: this.#controller.signal\n });\n }\n }\n /**\n * The resize observer if the root is an element.\n */\n #resizeObserver;\n /**\n * The controller to disconnect the root bounds resize and scroll listeners.\n */\n #controller = new AbortController();\n /**\n * The bounds of the root element.\n */\n rootBounds;\n /**\n * Disconnects the root bounds observer.\n */\n disconnect() {\n this.#resizeObserver?.disconnect();\n this.#controller.abort();\n }\n};\nfunction getWindowRect(window2) {\n const width = window2.visualViewport?.width ?? window2.innerWidth;\n const height = window2.visualViewport?.height ?? window2.innerHeight;\n return new DOMRect(0, 0, width, height);\n}\nfunction isNode(target) {\n return \"nodeType\" in target;\n}\nfunction isElement(target) {\n return isNode(target) && target.nodeType === Node.ELEMENT_NODE;\n}\nfunction isDocument(root) {\n return root.nodeType === Node.DOCUMENT_NODE;\n}\nfunction getRoot(target) {\n return !target || isDocument(target) ? target?.defaultView ?? window : target;\n}\n\n// src/observers/VisibilityObserver.ts\nvar VisibilityObserver = class {\n constructor(callback, options) {\n this.#options = options;\n this.#callback = (entries) => {\n const changedEntries = [];\n for (const entry of entries) {\n const previousIntersection = this.intersections.get(entry.target);\n this.intersections.set(entry.target, entry);\n if (previousIntersection?.isIntersecting !== entry.isIntersecting || !Rect.equals(\n previousIntersection?.intersectionRect,\n entry.intersectionRect\n )) {\n changedEntries.push(entry);\n }\n }\n if (changedEntries.length > 0) {\n callback(changedEntries, this);\n }\n };\n }\n /**\n * The callback function to be invoked when the intersection entries change.\n */\n #callback;\n /**\n * The visibility observer for each document.\n */\n #observers = /* @__PURE__ */ new Map();\n /**\n * The options for the visibility observer.\n */\n #options;\n /**\n * The latest intersection entries for the observed elements.\n */\n intersections = /* @__PURE__ */ new WeakMap();\n /**\n * Observes an element.\n *\n * @param element - The element to observe.\n */\n observe(element) {\n const document2 = element.ownerDocument;\n if (!document2) return;\n let observer = this.#observers.get(document2);\n if (!observer) {\n observer = new IntersectionObserver(this.#callback, {\n ...this.#options,\n threshold\n });\n this.#observers.set(document2, observer);\n }\n observer.observe(element);\n }\n /**\n * Unobserves an element.\n *\n * @param element - The element to unobserve.\n */\n unobserve(element) {\n const document2 = element.ownerDocument;\n if (!document2) return;\n const observer = this.#observers.get(document2);\n if (!observer) return;\n observer.unobserve(element);\n this.intersections.delete(element);\n }\n /**\n * Disconnects the visibility observer.\n */\n disconnect() {\n for (const observer of this.#observers.values()) {\n observer.disconnect();\n }\n this.#observers.clear();\n }\n};\n\n// src/PositionObserver.ts\nvar PositionObserver = class {\n constructor(callback, options) {\n this.#callback = callback;\n this.#options = options;\n this.#rootBoundsObserver = new RootBoundsObserver(\n options?.root,\n this.#onRootBoundsChange\n );\n this.#visibilityObserver = new VisibilityObserver(\n this.#onVisibilityChange,\n options\n );\n this.#resizeObserver = new ResizeObserver(this.#onResize);\n }\n /**\n * The callback function to be invoked when the position changes.\n */\n #callback;\n /**\n * The options for the position observer.\n */\n #options;\n /**\n * The position observers for the observed elements.\n */\n #positionObservers = /* @__PURE__ */ new Map();\n /**\n * The resize observer for the observed elements.\n */\n #resizeObserver;\n /**\n * The positions of the observed elements.\n */\n #positions = /* @__PURE__ */ new WeakMap();\n /**\n * The root bounds observer for the observed elements.\n */\n #rootBoundsObserver;\n /**\n * The visibility observer for the observed elements.\n */\n #visibilityObserver;\n /**\n * Observes an element.\n *\n * @param element - The element to observe.\n */\n observe(element) {\n this.#visibilityObserver.observe(element);\n }\n /**\n * Unobserves an element.\n *\n * @param element - The element to unobserve. If not provided, the position observer is disconnected.\n */\n unobserve(element) {\n if (element) {\n this.#positionObservers.get(element)?.disconnect();\n this.#visibilityObserver.unobserve(element);\n } else {\n this.disconnect();\n }\n }\n /**\n * Disconnects the observer.\n */\n disconnect() {\n for (const positionObserver of this.#positionObservers.values()) {\n positionObserver.disconnect();\n }\n this.#resizeObserver.disconnect();\n this.#rootBoundsObserver.disconnect();\n this.#visibilityObserver.disconnect();\n }\n /**\n * Notifies the position observer of the changes.\n *\n * @param entries - The entries to notify.\n */\n #notify(entries) {\n const records = [];\n for (const entry of entries) {\n const { target } = entry;\n const previousEntry = this.#positions.get(target);\n if (isEntryEqual(entry, previousEntry)) continue;\n this.#positions.set(target, entry);\n records.push(entry);\n }\n if (records.length > 0) {\n this.#callback(records);\n }\n }\n /**\n * The callback function to be invoked when the root bounds change.\n */\n #onRootBoundsChange = (rootBounds) => {\n const entries = [];\n for (const [element] of this.#positionObservers) {\n const boundingClientRect = element.getBoundingClientRect();\n const observer = this.#observePosition(element, boundingClientRect);\n entries.push(\n new PositionObserverEntry(\n element,\n boundingClientRect,\n observer.visibleRect,\n observer.isIntersecting,\n rootBounds\n )\n );\n }\n this.#notify(entries);\n };\n /**\n * Observes the position of an element.\n *\n * @param element - The element to observe.\n * @param clientRect - The client rect of the element.\n */\n #observePosition(element, clientRect) {\n const visibilityObserver = this.#visibilityObserver;\n this.#positionObservers.get(element)?.disconnect();\n const positionObserver = new PositionIntersectionObserver(\n element,\n this.#onPositionChange,\n {\n clientRect,\n root: this.#options?.root,\n rootBounds: this.#rootBoundsObserver.rootBounds,\n get clip() {\n const intersection = visibilityObserver.intersections.get(element);\n if (!intersection) return;\n const { intersectionRect, boundingClientRect } = intersection;\n return Rect.clipOffsets(boundingClientRect, intersectionRect);\n }\n }\n );\n this.#positionObservers.set(element, positionObserver);\n return positionObserver;\n }\n /**\n * The callback function to be invoked when the visibility changes.\n */\n #onVisibilityChange = (entries) => {\n const records = [];\n for (const entry of entries) {\n const { target, isIntersecting, boundingClientRect } = entry;\n if (isIntersecting) {\n this.#observePosition(target, boundingClientRect);\n this.#resizeObserver.observe(target);\n } else {\n this.#positionObservers.get(target)?.disconnect();\n this.#positionObservers.delete(target);\n this.#resizeObserver.unobserve(target);\n }\n const observer = this.#positionObservers.get(target);\n records.push(\n new PositionObserverEntry(\n target,\n boundingClientRect,\n observer?.visibleRect ?? entry.intersectionRect,\n isIntersecting,\n this.#rootBoundsObserver.rootBounds\n )\n );\n }\n this.#notify(records);\n };\n /**\n * The callback function to be invoked when the position changes.\n */\n #onPositionChange = (entry, observer) => {\n this.#notify([\n new PositionObserverEntry(\n entry.target,\n entry.boundingClientRect,\n observer.visibleRect,\n entry.isIntersecting,\n this.#rootBoundsObserver.rootBounds\n )\n ]);\n };\n /**\n * The callback function to be invoked when the resize observer entries change.\n */\n #onResize = (entries) => {\n const records = [];\n for (const entry of entries) {\n const { target, borderBoxSize } = entry;\n const previous = this.#positions.get(target);\n if (previous) {\n const [{ inlineSize: width, blockSize: height }] = borderBoxSize;\n if (Rect.sizeEqual(previous.boundingClientRect, { width, height })) {\n continue;\n }\n }\n const boundingClientRect = target.getBoundingClientRect();\n const observer = this.#observePosition(target, boundingClientRect);\n records.push(\n new PositionObserverEntry(\n target,\n boundingClientRect,\n observer.visibleRect,\n this.#visibilityObserver.intersections.get(target)?.isIntersecting ?? false,\n this.#rootBoundsObserver.rootBounds\n )\n );\n }\n this.#notify(records);\n };\n};\nvar PositionObserverEntry = class {\n constructor(target, boundingClientRect, intersectionRect, isIntersecting, rootBounds) {\n this.target = target;\n this.boundingClientRect = boundingClientRect;\n this.intersectionRect = intersectionRect;\n this.isIntersecting = isIntersecting;\n this.rootBounds = rootBounds;\n }\n};\nfunction isEntryEqual(first, second) {\n if (second == null) return false;\n return first.target === second.target && first.isIntersecting === second.isIntersecting && Rect.equals(first.boundingClientRect, second.boundingClientRect) && Rect.equals(first.intersectionRect, second.intersectionRect);\n}\nexport {\n PositionObserver,\n PositionObserverEntry\n};\n//# sourceMappingURL=index.js.map","type ShouldRegister = {\r\n shouldRegister: boolean\r\n isTouchDevice: boolean\r\n isLimitedConnection: boolean\r\n}\r\n\r\nexport function evaluateRegistrationConditions(): ShouldRegister {\r\n const isTouchDevice = userUsesTouchDevice()\r\n const isLimitedConnection = hasConnectionLimitations()\r\n const shouldRegister = !isTouchDevice && !isLimitedConnection\r\n return { isTouchDevice, isLimitedConnection, shouldRegister }\r\n}\r\n\r\n/**\r\n * Detects if the current device is likely a touch-enabled device.\r\n * It checks for coarse pointer media query and the presence of touch points.\r\n *\r\n * @returns `true` if the device is likely touch-enabled, `false` otherwise.\r\n */\r\nfunction userUsesTouchDevice(): boolean {\r\n return window.matchMedia(\"(pointer: coarse)\").matches && navigator.maxTouchPoints > 0\r\n}\r\n\r\n/**\r\n * Checks if the user has connection limitations (slow network or data saver enabled).\r\n *\r\n * @returns {boolean} True if connection is limited, false if safe to prefetch\r\n * @example\r\n * if (!hasConnectionLimitations()) {\r\n * prefetchResource('/api/data');\r\n * }\r\n */\r\nfunction hasConnectionLimitations(): boolean {\r\n const connection = (navigator as any).connection\r\n if (!connection) return false\r\n\r\n return /2g/.test(connection.effectiveType) || connection.saveData\r\n}\r\n","import { ForesightManager } from \"../Manager/ForesightManager\"\r\nimport { DebuggerControlPanel } from \"./DebuggerControlPanel\"\r\nimport type {\r\n ForesightElementData,\r\n ForesightElement,\r\n TrajectoryPositions,\r\n ForesightManagerSettings,\r\n Point,\r\n HitSlop,\r\n} from \"../types/types\"\r\nimport { createAndAppendElement, createAndAppendStyle } from \"./helpers/createAndAppend\"\r\nimport { updateElementOverlays } from \"./helpers/updateElementOverlays\"\r\nimport { removeOldDebuggers } from \"./helpers/removeOldDebuggers\"\r\nimport { DEFAULT_SHOW_NAME_TAGS } from \"../Manager/constants\"\r\nimport { PositionObserver, type PositionObserverEntry } from \"position-observer\"\r\nimport { evaluateRegistrationConditions } from \"../helpers/shouldRegister\"\r\n\r\nexport type ElementOverlays = {\r\n expandedOverlay: HTMLElement\r\n nameLabel: HTMLElement\r\n}\r\n\r\ntype callbackAnimation = {\r\n hitSlop: Exclude<HitSlop, number>\r\n overlay: HTMLElement\r\n timeoutId: ReturnType<typeof setTimeout>\r\n}\r\nexport class ForesightDebugger {\r\n private static debuggerInstance: ForesightDebugger\r\n private callbackAnimations: Map<Element, callbackAnimation> = new Map()\r\n private foresightManagerInstance: ForesightManager\r\n private shadowHost!: HTMLElement\r\n private shadowRoot!: ShadowRoot\r\n private debugContainer!: HTMLElement\r\n private controlPanel!: DebuggerControlPanel\r\n\r\n private debugElementOverlays: Map<ForesightElement, ElementOverlays> = new Map()\r\n private predictedMouseIndicator: HTMLElement | null = null\r\n private mouseTrajectoryLine: HTMLElement | null = null\r\n private scrollTrajectoryLine: HTMLElement | null = null\r\n\r\n private constructor(foresightManager: ForesightManager) {\r\n this.foresightManagerInstance = foresightManager\r\n }\r\n private animationPositionObserver: PositionObserver | null = null\r\n\r\n private _setupDOM() {\r\n // If for some reason we call this on an already-setup instance, do nothing.\r\n if (this.shadowHost) {\r\n return\r\n }\r\n\r\n this.shadowHost = createAndAppendElement(\"div\", document.body, {\r\n id: \"jsforesight-debugger-shadow-host\",\r\n })\r\n this.shadowRoot = this.shadowHost.attachShadow({ mode: \"open\" })\r\n this.debugContainer = createAndAppendElement(\"div\", this.shadowRoot, {\r\n id: \"jsforesight-debug-container\",\r\n })\r\n this.predictedMouseIndicator = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-mouse-predicted\",\r\n })\r\n this.mouseTrajectoryLine = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-trajectory-line\",\r\n })\r\n this.scrollTrajectoryLine = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-scroll-trajectory-line\",\r\n })\r\n this.controlPanel = DebuggerControlPanel.initialize(\r\n this.foresightManagerInstance,\r\n this.shadowRoot,\r\n this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings\r\n )\r\n createAndAppendStyle(debuggerCSS, this.shadowRoot, \"screen-visuals\")\r\n\r\n this.animationPositionObserver = new PositionObserver(this.handleAnimationPositionChange)\r\n }\r\n\r\n private handleAnimationPositionChange = (entries: PositionObserverEntry[]) => {\r\n for (const entry of entries) {\r\n const animationData = this.callbackAnimations.get(entry.target)\r\n if (animationData) {\r\n const rect = entry.boundingClientRect\r\n const { hitSlop, overlay } = animationData\r\n\r\n const newLeft = rect.left - hitSlop.left\r\n const newTop = rect.top - hitSlop.top\r\n const newWidth = rect.width + hitSlop.left + hitSlop.right\r\n const newHeight = rect.height + hitSlop.top + hitSlop.bottom\r\n\r\n overlay.style.transform = `translate3d(${newLeft}px, ${newTop}px, 0)`\r\n overlay.style.width = `${newWidth}px`\r\n overlay.style.height = `${newHeight}px`\r\n }\r\n }\r\n }\r\n\r\n private static get isInitiated(): boolean {\r\n return !!ForesightDebugger.debuggerInstance\r\n }\r\n\r\n public static initialize(\r\n foresightManager: ForesightManager,\r\n trajectoryPositions: TrajectoryPositions\r\n ): ForesightDebugger | null {\r\n removeOldDebuggers()\r\n if (typeof window === \"undefined\" || !evaluateRegistrationConditions().shouldRegister) {\r\n return null\r\n }\r\n\r\n if (!ForesightDebugger.isInitiated) {\r\n ForesightDebugger.debuggerInstance = new ForesightDebugger(foresightManager)\r\n }\r\n\r\n const instance = ForesightDebugger.debuggerInstance\r\n\r\n if (!instance.shadowHost) {\r\n instance._setupDOM()\r\n }\r\n\r\n instance.updateMouseTrajectoryVisuals(\r\n trajectoryPositions,\r\n foresightManager.getManagerData.globalSettings.enableMousePrediction\r\n )\r\n\r\n return instance\r\n }\r\n\r\n private createElementOverlays(elementData: ForesightElementData) {\r\n const expandedOverlay = createAndAppendElement(\"div\", this.debugContainer!, {\r\n className: \"jsforesight-expanded-overlay\",\r\n data: elementData.name,\r\n })\r\n const nameLabel = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-name-label\",\r\n })\r\n const overlays = { expandedOverlay, nameLabel }\r\n this.debugElementOverlays.set(elementData.element, overlays)\r\n return overlays\r\n }\r\n\r\n public createOrUpdateElementOverlay(newData: ForesightElementData) {\r\n if (!this.debugContainer || !this.shadowRoot) return\r\n\r\n let overlays = this.debugElementOverlays.get(newData.element)\r\n if (!overlays) {\r\n overlays = this.createElementOverlays(newData)\r\n }\r\n\r\n updateElementOverlays(\r\n overlays,\r\n newData,\r\n this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags ??\r\n DEFAULT_SHOW_NAME_TAGS\r\n )\r\n }\r\n\r\n public toggleNameTagVisibility() {\r\n this.foresightManagerInstance.registeredElements.forEach((elementData) => {\r\n const overlays = this.debugElementOverlays.get(elementData.element)\r\n if (!overlays) return\r\n updateElementOverlays(\r\n overlays,\r\n elementData,\r\n this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags ??\r\n DEFAULT_SHOW_NAME_TAGS\r\n )\r\n })\r\n }\r\n\r\n /**\r\n * Removes all debug overlays and data associated with an element.\r\n *\r\n * This method cleans up the link overlay, expanded overlay, and name label\r\n * for the specified element, removes it from internal tracking maps, and\r\n * refreshes the control panel's element list to reflect the removal.\r\n *\r\n * @param element - The ForesightElement to remove from debugging visualization\r\n */\r\n public removeElement(elementData: ForesightElementData) {\r\n this.removeElementOverlay(elementData)\r\n this.controlPanel?.removeElementFromList(elementData)\r\n }\r\n\r\n public removeElementOverlay(elementData: ForesightElementData) {\r\n const overlays = this.debugElementOverlays.get(elementData.element)\r\n if (overlays) {\r\n overlays.expandedOverlay.remove()\r\n overlays.nameLabel.remove()\r\n this.debugElementOverlays.delete(elementData.element)\r\n }\r\n }\r\n\r\n public addElement(elementData: ForesightElementData, sort: boolean = true) {\r\n this.createOrUpdateElementOverlay(elementData)\r\n this.controlPanel.addElementToList(elementData, sort)\r\n }\r\n\r\n public updateMouseTrajectoryVisuals(\r\n trajectoryPositions: TrajectoryPositions,\r\n enableMousePrediction: boolean\r\n ) {\r\n if (!this.shadowRoot || !this.debugContainer) {\r\n return\r\n }\r\n if (!this.predictedMouseIndicator || !this.mouseTrajectoryLine) {\r\n return\r\n }\r\n const { predictedPoint, currentPoint } = trajectoryPositions\r\n\r\n // Use transform for positioning to avoid layout reflow.\r\n // The CSS handles centering the element with `translate(-50%, -50%)`.\r\n this.predictedMouseIndicator.style.transform = `translate3d(${predictedPoint.x}px, ${predictedPoint.y}px, 0) translate3d(-50%, -50%, 0)`\r\n this.predictedMouseIndicator.style.display = enableMousePrediction ? \"block\" : \"none\"\r\n\r\n // This hides the circle from the UI at the top-left corner when refreshing the page with the cursor outside of the window\r\n if (predictedPoint.x === 0 && predictedPoint.y === 0) {\r\n this.predictedMouseIndicator.style.display = \"none\"\r\n return\r\n }\r\n\r\n if (!enableMousePrediction) {\r\n this.mouseTrajectoryLine.style.display = \"none\"\r\n return\r\n }\r\n\r\n const dx = predictedPoint.x - currentPoint.x\r\n const dy = predictedPoint.y - currentPoint.y\r\n\r\n const length = Math.sqrt(dx * dx + dy * dy)\r\n const angle = (Math.atan2(dy, dx) * 180) / Math.PI\r\n\r\n // Use a single transform to position, rotate, and scale the line,\r\n // avoiding reflow from top/left changes.\r\n this.mouseTrajectoryLine.style.transform = `translate3d(${currentPoint.x}px, ${currentPoint.y}px, 0) rotate(${angle}deg)`\r\n this.mouseTrajectoryLine.style.width = `${length}px`\r\n this.mouseTrajectoryLine.style.display = \"block\"\r\n }\r\n\r\n public updateScrollTrajectoryVisuals(currentPoint: Point, predictedScrollPoint: Point) {\r\n if (!this.scrollTrajectoryLine) return\r\n const dx = predictedScrollPoint.x - currentPoint.x\r\n const dy = predictedScrollPoint.y - currentPoint.y\r\n\r\n const length = Math.sqrt(dx * dx + dy * dy)\r\n const angle = (Math.atan2(dy, dx) * 180) / Math.PI\r\n\r\n this.scrollTrajectoryLine.style.transform = `translate3d(${currentPoint.x}px, ${currentPoint.y}px, 0) rotate(${angle}deg)`\r\n this.scrollTrajectoryLine.style.width = `${length}px`\r\n this.scrollTrajectoryLine.style.display = \"block\"\r\n }\r\n\r\n public hideScrollTrajectoryVisuals() {\r\n if (this.scrollTrajectoryLine) {\r\n this.scrollTrajectoryLine.style.display = \"none\"\r\n }\r\n }\r\n\r\n public updateControlsState(settings: ForesightManagerSettings) {\r\n this.controlPanel?.updateControlsState(settings)\r\n }\r\n\r\n public updateElementVisibilityStatus(elementData: ForesightElementData) {\r\n this.controlPanel?.updateElementVisibilityStatus(elementData)\r\n }\r\n\r\n public removeElementFromList(elementData: ForesightElementData) {\r\n this.controlPanel?.removeElementFromList(elementData)\r\n }\r\n\r\n public showCallbackAnimation(elementData: ForesightElementData) {\r\n const { element, elementBounds } = elementData\r\n const existingAnimation = this.callbackAnimations.get(element)\r\n\r\n // If an animation is already running for this element, reset it\r\n if (existingAnimation) {\r\n clearTimeout(existingAnimation.timeoutId)\r\n existingAnimation.overlay.remove()\r\n this.animationPositionObserver?.unobserve(element)\r\n this.callbackAnimations.delete(element)\r\n }\r\n\r\n const animationOverlay = createAndAppendElement(\"div\", this.debugContainer, {\r\n className: \"jsforesight-callback-indicator\",\r\n })\r\n\r\n const { left, top, right, bottom } = elementBounds.expandedRect\r\n const width = right - left\r\n const height = bottom - top\r\n\r\n animationOverlay.style.display = \"block\"\r\n animationOverlay.style.transform = `translate3d(${left}px, ${top}px, 0)`\r\n animationOverlay.style.width = `${width}px`\r\n animationOverlay.style.height = `${height}px`\r\n\r\n animationOverlay.classList.add(\"animate\")\r\n\r\n const animationDuration = 500\r\n\r\n const timeoutId = setTimeout(() => {\r\n animationOverlay.remove()\r\n this.callbackAnimations.delete(element)\r\n this.animationPositionObserver?.unobserve(element)\r\n }, animationDuration)\r\n\r\n this.callbackAnimations.set(element, {\r\n hitSlop: elementData.elementBounds.hitSlop,\r\n overlay: animationOverlay,\r\n timeoutId: timeoutId,\r\n })\r\n\r\n this.animationPositionObserver?.observe(element)\r\n }\r\n\r\n public cleanup() {\r\n this.controlPanel?.cleanup()\r\n this.shadowHost?.remove()\r\n this.debugElementOverlays.clear()\r\n this.shadowHost = null!\r\n this.shadowRoot = null!\r\n this.debugContainer = null!\r\n this.predictedMouseIndicator = null\r\n this.mouseTrajectoryLine = null\r\n this.scrollTrajectoryLine = null\r\n this.controlPanel = null!\r\n }\r\n}\r\n\r\nconst debuggerCSS = `\r\n #jsforesight-debug-container { \r\n position: fixed; top: 0; left: 0; width: 100%; height: 100%;\r\n pointer-events: none; z-index: 9999;\r\n }\r\n\r\n .jsforesight-expanded-overlay, \r\n .jsforesight-name-label, \r\n .jsforesight-callback-indicator,\r\n .jsforesight-mouse-predicted,\r\n .jsforesight-scroll-trajectory-line,\r\n .jsforesight-trajectory-line {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n will-change: transform; \r\n }\r\n .jsforesight-expanded-overlay {\r\n border: 1px dashed rgba(100, 116, 139, 0.4);\r\n background-color: rgba(100, 116, 139, 0.05);\r\n box-sizing: border-box;\r\n border-radius: 8px;\r\n }\r\n .jsforesight-mouse-predicted {\r\n width: 20px;\r\n height: 20px;\r\n border-radius: 50%;\r\n border: 2px solid #6b98e1;\r\n background-color: rgba(176, 196, 222, 0.3);\r\n z-index: 10000;\r\n /* transform is now set dynamically via JS for performance */\r\n }\r\n .jsforesight-trajectory-line {\r\n height: 2px;\r\n background-color: #6b98e1;\r\n transform-origin: left center;\r\n z-index: 9999;\r\n border-radius: 1px;\r\n /* width and transform are set dynamically via JS for performance */\r\n }\r\n .jsforesight-name-label {\r\n background-color: rgba(27, 31, 35, 0.85);\r\n backdrop-filter: blur(4px);\r\n color: white;\r\n padding: 4px 8px;\r\n font-size: 11px;\r\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\";\r\n border-radius: 4px;\r\n z-index: 10001;\r\n white-space: nowrap;\r\n pointer-events: none;\r\n }\r\n .jsforesight-callback-indicator {\r\n border: 4px solid oklch(65% 0.22 280); \r\n border-radius: 8px;\r\n box-sizing: border-box;\r\n pointer-events: none;\r\n opacity: 0;\r\n z-index: 10002;\r\n display: none; \r\n }\r\n .jsforesight-callback-indicator.animate {\r\n animation: jsforesight-callback-pulse 0.5s ease-out forwards;\r\n }\r\n \r\n .jsforesight-scroll-trajectory-line {\r\n height: 2px;\r\n background: repeating-linear-gradient(\r\n 90deg,\r\n oklch(68% 0.18 145) 0px,\r\n oklch(68% 0.18 145) 6px,\r\n transparent 6px,\r\n transparent 10px\r\n );\r\n transform-origin: left center;\r\n z-index: 9999;\r\n border-radius: 1px;\r\n display: none;\r\n animation: scroll-dash-flow 1.8s linear infinite;\r\n position: relative;\r\n }\r\n\r\n .jsforesight-scroll-trajectory-line::after {\r\n content: '';\r\n position: absolute;\r\n right: -2px;\r\n top: 50%;\r\n transform: translateY(-50%);\r\n width: 6px;\r\n height: 6px;\r\n background: oklch(68% 0.18 145);\r\n border-radius: 50%;\r\n animation: scroll-escape-squeeze 2.2s ease-in-out infinite;\r\n }\r\n\r\n @keyframes scroll-dash-flow {\r\n 0% { background-position: 0px 0px; }\r\n 100% { background-position: 10px 0px; }\r\n }\r\n\r\n @keyframes scroll-escape-squeeze {\r\n 0%, 100% { \r\n transform: translateY(-50%) scale(1);\r\n right: -2px;\r\n }\r\n 25% {\r\n transform: translateY(-50%) scaleX(1.3) scaleY(0.7);\r\n right: -3px;\r\n }\r\n 50% {\r\n transform: translateY(-50%) scaleX(0.8) scaleY(1.2);\r\n right: -1px;\r\n }\r\n 75% {\r\n transform: translateY(-50%) scaleX(1.2) scaleY(0.8);\r\n right: -3px;\r\n }\r\n }\r\n\r\n \r\n @keyframes jsforesight-callback-pulse {\r\n 0% {\r\n opacity: 1;\r\n box-shadow: 0 0 15px oklch(65% 0.22 280 / 0.7);\r\n }\r\n 100% {\r\n opacity: 0;\r\n box-shadow: 0 0 25px oklch(65% 0.22 280 / 0);\r\n }\r\n }\r\n `\r\n","/**\r\n * removes stale debuggers that might have been left behind in the dom\r\n */\r\nexport function removeOldDebuggers() {\r\n const oldDebuggers = document.querySelectorAll(\"#jsforesight-debugger-shadow-host\")\r\n oldDebuggers.forEach((element) => element.remove())\r\n}\r\n","export function clampNumber(\r\n number: number,\r\n lowerBound: number,\r\n upperBound: number,\r\n isDebug: boolean,\r\n settingName: string\r\n) {\r\n if (isDebug) {\r\n if (number < lowerBound) {\r\n console.warn(\r\n `ForesightJS: \"${settingName}\" value ${number} is below minimum bound ${lowerBound}, clamping to ${lowerBound}`\r\n )\r\n } else if (number > upperBound) {\r\n console.warn(\r\n `ForesightJS: \"${settingName}\" value ${number} is above maximum bound ${upperBound}, clamping to ${upperBound}`\r\n )\r\n }\r\n }\r\n\r\n return Math.min(Math.max(number, lowerBound), upperBound)\r\n}\r\n","import type { Point, Rect } from \"../../types/types\"\r\n\r\n/**\r\n * Determines if a line segment intersects with a given rectangle.\r\n * This function implements the Liang-Barsky line clipping algorithm.\r\n *\r\n * @param p1 - The starting {@link Point} of the line segment.\r\n * @param p2 - The ending {@link Point} of the line segment.\r\n * @param rect - The {@link Rect} to check for intersection.\r\n * @returns `true` if the line segment intersects the rectangle, `false` otherwise.\r\n */\r\nexport function lineSegmentIntersectsRect(p1: Point, p2: Point, rect: Rect): boolean {\r\n let t0 = 0.0\r\n let t1 = 1.0\r\n const dx = p2.x - p1.x\r\n const dy = p2.y - p1.y\r\n\r\n const clipTest = (p: number, q: number): boolean => {\r\n if (p === 0) {\r\n // Line is parallel to this clipping edge\r\n if (q < 0) return false // Line is outside the clipping edge\r\n } else {\r\n const r = q / p\r\n if (p < 0) {\r\n // Line proceeds from outside to inside\r\n if (r > t1) return false // Line segment ends before crossing edge\r\n if (r > t0) t0 = r // Update entry point\r\n } else {\r\n // Line proceeds from inside to outside\r\n if (r < t0) return false // Line segment starts after crossing edge\r\n if (r < t1) t1 = r // Update exit point\r\n }\r\n }\r\n return true\r\n }\r\n\r\n // Clip against all four edges of the rectangle\r\n if (!clipTest(-dx, p1.x - rect.left)) return false // Left edge\r\n if (!clipTest(dx, rect.right - p1.x)) return false // Right edge\r\n if (!clipTest(-dy, p1.y - rect.top)) return false // Top edge\r\n if (!clipTest(dy, rect.bottom - p1.y)) return false // Bottom edge\r\n\r\n // If t0 <= t1, the line segment intersects the rectangle (or lies within it)\r\n return t0 <= t1\r\n}\r\n","import type { HitSlop, Point, Rect } from \"../../types/types\"\r\nimport { MAX_HITSLOP, MIN_HITSLOP } from \"../constants\"\r\nimport { clampNumber } from \"./clampNumber\"\r\n\r\n/**\r\n * Normalizes a `hitSlop` value into a {@link Rect} object.\r\n * If `hitSlop` is a number, it's applied uniformly to all sides (top, left, right, bottom).\r\n * If `hitSlop` is already a `Rect` object, it's returned as is.\r\n *\r\n * @param hitSlop - A number for uniform slop, or a {@link Rect} object for specific slop per side.\r\n * @returns A {@link Rect} object with `top`, `left`, `right`, and `bottom` properties.\r\n */\r\nexport function normalizeHitSlop(hitSlop: HitSlop, isDebug: boolean): Rect {\r\n if (typeof hitSlop === \"number\") {\r\n const clampedValue = clampNumber(hitSlop, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop\")\r\n return {\r\n top: clampedValue,\r\n left: clampedValue,\r\n right: clampedValue,\r\n bottom: clampedValue,\r\n }\r\n }\r\n\r\n return {\r\n top: clampNumber(hitSlop.top, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop - top\"),\r\n left: clampNumber(hitSlop.left, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop - left\"),\r\n right: clampNumber(hitSlop.right, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop - right\"),\r\n bottom: clampNumber(hitSlop.bottom, MIN_HITSLOP, MAX_HITSLOP, isDebug, \"hitslop - bottom\"),\r\n }\r\n}\r\n\r\n/**\r\n * Calculates an expanded rectangle by applying a `hitSlop` to a base rectangle.\r\n * The `hitSlop` values define how much to extend each side of the `baseRect` outwards.\r\n *\r\n * @param baseRect - The original {@link Rect} or `DOMRect` to expand.\r\n * @param hitSlop - A {@link Rect} object defining how much to expand each side\r\n * (e.g., `hitSlop.left` expands the left boundary further to the left).\r\n * @returns A new {@link Rect} object representing the expanded area.\r\n */\r\nexport function getExpandedRect(baseRect: Rect | DOMRect, hitSlop: Rect): Rect {\r\n return {\r\n left: baseRect.left - hitSlop.left,\r\n right: baseRect.right + hitSlop.right,\r\n top: baseRect.top - hitSlop.top,\r\n bottom: baseRect.bottom + hitSlop.bottom,\r\n }\r\n}\r\n\r\n/**\r\n * Checks if two rectangle objects are equal by comparing their respective\r\n * `top`, `left`, `right`, and `bottom` properties.\r\n * Handles cases where one or both rects might be null or undefined.\r\n *\r\n * @param rect1 - The first {@link Rect} object to compare.\r\n * @param rect2 - The second {@link Rect} object to compare.\r\n * @returns `true` if the rectangles have identical dimensions or if both are null/undefined,\r\n * `false` otherwise.\r\n */\r\nexport function areRectsEqual(rect1: Rect, rect2: Rect): boolean {\r\n if (!rect1 || !rect2) return rect1 === rect2\r\n return (\r\n rect1.left === rect2.left &&\r\n rect1.right === rect2.right &&\r\n rect1.top === rect2.top &&\r\n rect1.bottom === rect2.bottom\r\n )\r\n}\r\n\r\nexport function isPointInRectangle(point: Point, rect: Rect): boolean {\r\n return (\r\n point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom\r\n )\r\n}\r\n","/**\r\n * Checks if a setting should be updated.\r\n * Returns true if the newValue is defined and different from the currentValue.\r\n * Uses a type predicate to narrow the type of newValue in the calling scope.\r\n *\r\n * @param newValue The potentially new value for the setting (can be undefined).\r\n * @param currentValue The current value of the setting.\r\n * @returns True if the setting should be updated, false otherwise.\r\n */\r\nexport function shouldUpdateSetting<T>(\r\n newValue: T | undefined,\r\n currentValue: T\r\n): newValue is NonNullable<T> {\r\n // NonNullable<T> ensures that if T itself could be undefined (e.g. T = number | undefined),\r\n // the predicate narrows to the non-undefined part (e.g. number).\r\n // If T is already non-nullable (e.g. T = number), it remains T (e.g. number).\r\n return newValue !== undefined && currentValue !== newValue\r\n}\r\n","import { tabbable, type FocusableElement } from \"tabbable\"\r\nimport { ForesightDebugger } from \"../Debugger/ForesightDebugger\"\r\nimport { evaluateRegistrationConditions } from \"../helpers/shouldRegister\"\r\nimport type {\r\n BooleanSettingKeys,\r\n CallbackHits,\r\n ForesightElement,\r\n ForesightElementData,\r\n ForesightManagerData,\r\n ForesightManagerSettings,\r\n ForesightRegisterOptions,\r\n ForesightRegisterResult,\r\n HitType,\r\n NumericSettingKeys,\r\n Point,\r\n ScrollDirection,\r\n TrajectoryPositions,\r\n UpdateForsightManagerSettings,\r\n} from \"../types/types\"\r\nimport {\r\n DEFAULT_ENABLE_MOUSE_PREDICTION,\r\n DEFAULT_ENABLE_SCROLL_PREDICTION,\r\n DEFAULT_ENABLE_TAB_PREDICTION,\r\n DEFAULT_HITSLOP,\r\n DEFAULT_IS_DEBUG,\r\n DEFAULT_IS_DEBUGGER_MINIMIZED,\r\n DEFAULT_POSITION_HISTORY_SIZE,\r\n DEFAULT_SCROLL_MARGIN,\r\n DEFAULT_SHOW_NAME_TAGS,\r\n DEFAULT_SORT_ELEMENT_LIST,\r\n DEFAULT_TAB_OFFSET,\r\n DEFAULT_TRAJECTORY_PREDICTION_TIME,\r\n MAX_POSITION_HISTORY_SIZE,\r\n MAX_SCROLL_MARGIN,\r\n MAX_TAB_OFFSET,\r\n MAX_TRAJECTORY_PREDICTION_TIME,\r\n MIN_POSITION_HISTORY_SIZE,\r\n MIN_SCROLL_MARGIN,\r\n MIN_TAB_OFFSET,\r\n MIN_TRAJECTORY_PREDICTION_TIME,\r\n} from \"./constants\"\r\nimport { clampNumber } from \"./helpers/clampNumber\"\r\nimport { lineSegmentIntersectsRect } from \"./helpers/lineSigmentIntersectsRect\"\r\nimport { predictNextMousePosition } from \"./helpers/predictNextMousePosition\"\r\nimport {\r\n areRectsEqual,\r\n getExpandedRect,\r\n isPointInRectangle,\r\n normalizeHitSlop,\r\n} from \"./helpers/rectAndHitSlop\"\r\nimport { shouldUpdateSetting } from \"./helpers/shouldUpdateSetting\"\r\n\r\nimport { getScrollDirection } from \"./helpers/getScrollDirection\"\r\nimport { predictNextScrollPosition } from \"./helpers/predictNextScrollPosition\"\r\nimport { getFocusedElementIndex } from \"./helpers/getFocusedElementIndex\"\r\nimport { PositionObserver, PositionObserverEntry } from \"position-observer\"\r\n\r\n/**\r\n * Manages the prediction of user intent based on mouse trajectory and element interactions.\r\n *\r\n * ForesightManager is a singleton class responsible for:\r\n * - Registering HTML elements to monitor.\r\n * - Tracking mouse movements and predicting future cursor positions.\r\n * - Detecting when a predicted trajectory intersects with a registered element's bounds.\r\n * - Invoking callbacks associated with elements upon predicted or actual interaction.\r\n * - Optionally unregistering elements after their callback is triggered.\r\n * - Handling global settings for prediction behavior (e.g., history size, prediction time).\r\n * - Optionally enabling a {@link ForesightDebugger} for visual feedback.\r\n * - Automatically updating element bounds on resize using {@link ResizeObserver}.\r\n * - Automatically unregistering elements removed from the DOM using {@link MutationObserver}.\r\n * - Detecting broader layout shifts via {@link MutationObserver} to update element positions.\r\n *\r\n * It should be initialized once using {@link ForesightManager.initialize} and then\r\n * accessed via the static getter {@link ForesightManager.instance}.\r\n */\r\n\r\nexport class ForesightManager {\r\n private static manager: ForesightManager\r\n private elements: Map<ForesightElement, ForesightElementData> = new Map()\r\n private isSetup: boolean = false\r\n private debugger: ForesightDebugger | null = null\r\n private _globalCallbackHits: CallbackHits = {\r\n mouse: {\r\n hover: 0,\r\n trajectory: 0,\r\n },\r\n tab: {\r\n forwards: 0,\r\n reverse: 0,\r\n },\r\n scroll: {\r\n down: 0,\r\n left: 0,\r\n right: 0,\r\n up: 0,\r\n },\r\n total: 0,\r\n }\r\n private _globalSettings: ForesightManagerSettings = {\r\n debug: DEFAULT_IS_DEBUG,\r\n enableMousePrediction: DEFAULT_ENABLE_MOUSE_PREDICTION,\r\n enableScrollPrediction: DEFAULT_ENABLE_SCROLL_PREDICTION,\r\n positionHistorySize: DEFAULT_POSITION_HISTORY_SIZE,\r\n trajectoryPredictionTime: DEFAULT_TRAJECTORY_PREDICTION_TIME,\r\n scrollMargin: DEFAULT_SCROLL_MARGIN,\r\n defaultHitSlop: {\r\n top: DEFAULT_HITSLOP,\r\n left: DEFAULT_HITSLOP,\r\n right: DEFAULT_HITSLOP,\r\n bottom: DEFAULT_HITSLOP,\r\n },\r\n resizeScrollThrottleDelay: 0,\r\n debuggerSettings: {\r\n isControlPanelDefaultMinimized: DEFAULT_IS_DEBUGGER_MINIMIZED,\r\n showNameTags: DEFAULT_SHOW_NAME_TAGS,\r\n sortElementList: DEFAULT_SORT_ELEMENT_LIST,\r\n },\r\n enableTabPrediction: DEFAULT_ENABLE_TAB_PREDICTION,\r\n tabOffset: DEFAULT_TAB_OFFSET,\r\n onAnyCallbackFired: (\r\n _elementData: ForesightElementData,\r\n _managerData: ForesightManagerData\r\n ) => {},\r\n }\r\n private trajectoryPositions: TrajectoryPositions = {\r\n positions: [],\r\n currentPoint: { x: 0, y: 0 },\r\n predictedPoint: { x: 0, y: 0 },\r\n }\r\n\r\n private tabbableElementsCache: FocusableElement[] = []\r\n private lastFocusedIndex: number | null = null\r\n\r\n private predictedScrollPoint: Point | null = null\r\n private scrollDirection: ScrollDirection | null = null\r\n private domObserver: MutationObserver | null = null\r\n private positionObserver: PositionObserver | null = null\r\n // Track the last keydown event to determine if focus change was due to Tab\r\n private lastKeyDown: KeyboardEvent | null = null\r\n\r\n // AbortController for managing global event listeners\r\n private globalListenersController: AbortController | null = null\r\n\r\n // Never put something in the constructor, use initialize instead\r\n private constructor() {}\r\n\r\n public static initialize(props?: Partial<UpdateForsightManagerSettings>): ForesightManager {\r\n if (!this.isInitiated) {\r\n ForesightManager.manager = new ForesightManager()\r\n }\r\n if (props !== undefined) {\r\n ForesightManager.manager.alterGlobalSettings(props)\r\n }\r\n return ForesightManager.manager\r\n }\r\n\r\n public get getManagerData(): Readonly<ForesightManagerData> {\r\n return {\r\n registeredElements: this.elements,\r\n globalSettings: this._globalSettings,\r\n globalCallbackHits: this._globalCallbackHits,\r\n }\r\n }\r\n\r\n public static get isInitiated(): Readonly<boolean> {\r\n return !!ForesightManager.manager\r\n }\r\n\r\n public static get instance(): ForesightManager {\r\n return this.initialize()\r\n }\r\n\r\n public get registeredElements(): ReadonlyMap<ForesightElement, ForesightElementData> {\r\n return this.elements\r\n }\r\n\r\n public register({\r\n element,\r\n callback,\r\n hitSlop,\r\n unregisterOnCallback,\r\n name,\r\n }: ForesightRegisterOptions): ForesightRegisterResult {\r\n const { shouldRegister, isTouchDevice, isLimitedConnection } = evaluateRegistrationConditions()\r\n if (!shouldRegister) {\r\n return {\r\n isLimitedConnection,\r\n isTouchDevice,\r\n isRegistered: false,\r\n unregister: () => {},\r\n }\r\n }\r\n\r\n // Setup global listeners on every first element added to the manager. It gets removed again when the map is emptied\r\n if (!this.isSetup) {\r\n this.initializeGlobalListeners()\r\n }\r\n\r\n const normalizedHitSlop = hitSlop\r\n ? normalizeHitSlop(hitSlop, this._globalSettings.debug)\r\n : this._globalSettings.defaultHitSlop\r\n // const elementRect = element.getBoundingClientRect()\r\n const elementData: ForesightElementData = {\r\n element: element,\r\n callback,\r\n callbackHits: {\r\n mouse: {\r\n hover: 0,\r\n trajectory: 0,\r\n },\r\n tab: {\r\n forwards: 0,\r\n reverse: 0,\r\n },\r\n scroll: {\r\n down: 0,\r\n left: 0,\r\n right: 0,\r\n up: 0,\r\n },\r\n total: 0,\r\n },\r\n elementBounds: {\r\n originalRect: undefined,\r\n expandedRect: { top: 0, left: 0, right: 0, bottom: 0 },\r\n hitSlop: normalizedHitSlop,\r\n },\r\n isHovering: false,\r\n trajectoryHitData: {\r\n isTrajectoryHit: false,\r\n trajectoryHitTime: 0,\r\n trajectoryHitExpirationTimeoutId: undefined,\r\n },\r\n name: name ?? element.id ?? \"\",\r\n unregisterOnCallback: unregisterOnCallback ?? true,\r\n isIntersectingWithViewport: true,\r\n }\r\n\r\n this.elements.set(element, elementData)\r\n\r\n this.positionObserver?.observe(element)\r\n\r\n if (this.debugger) {\r\n this.debugger.addElement(elementData)\r\n }\r\n\r\n return {\r\n isTouchDevice,\r\n isLimitedConnection,\r\n isRegistered: true,\r\n unregister: () => this.unregister(element),\r\n }\r\n }\r\n\r\n private unregister(element: ForesightElement) {\r\n const isRegistered = this.elements.has(element)\r\n if (!isRegistered) {\r\n // The element is already unregistered by something else (e.g. after hitting callback)\r\n return\r\n }\r\n const foresightElementData = this.elements.get(element)\r\n\r\n // Clear any pending trajectory expiration timeout\r\n if (foresightElementData?.trajectoryHitData.trajectoryHitExpirationTimeoutId) {\r\n clearTimeout(foresightElementData.trajectoryHitData.trajectoryHitExpirationTimeoutId)\r\n }\r\n\r\n this.positionObserver?.unobserve(element)\r\n this.elements.delete(element)\r\n\r\n if (this.debugger && foresightElementData) {\r\n this.debugger.removeElement(foresightElementData)\r\n }\r\n\r\n if (this.elements.size === 0 && this.isSetup) {\r\n this.removeGlobalListeners()\r\n }\r\n }\r\n\r\n private updateNumericSettings(\r\n newValue: number | undefined,\r\n setting: NumericSettingKeys,\r\n min: number,\r\n max: number\r\n ) {\r\n if (!shouldUpdateSetting(newValue, this._globalSettings[setting])) {\r\n return false\r\n }\r\n\r\n this._globalSettings[setting] = clampNumber(\r\n newValue,\r\n min,\r\n max,\r\n this._globalSettings.debug,\r\n setting\r\n )\r\n\r\n return true\r\n }\r\n\r\n private updateBooleanSetting(\r\n newValue: boolean | undefined,\r\n setting: BooleanSettingKeys\r\n ): boolean {\r\n if (!shouldUpdateSetting(newValue, this._globalSettings[setting])) {\r\n return false\r\n }\r\n this._globalSettings[setting] = newValue\r\n return true\r\n }\r\n\r\n public alterGlobalSettings(props?: Partial<UpdateForsightManagerSettings>): void {\r\n // Call each update function and store whether it made a change.\r\n // This ensures every update function is executed.\r\n const oldPositionHistorySize = this._globalSettings.positionHistorySize\r\n const positionHistoryChanged = this.updateNumericSettings(\r\n props?.positionHistorySize,\r\n \"positionHistorySize\",\r\n MIN_POSITION_HISTORY_SIZE,\r\n MAX_POSITION_HISTORY_SIZE\r\n )\r\n\r\n if (\r\n positionHistoryChanged &&\r\n this._globalSettings.positionHistorySize < oldPositionHistorySize\r\n ) {\r\n if (this.trajectoryPositions.positions.length > this._globalSettings.positionHistorySize) {\r\n this.trajectoryPositions.positions = this.trajectoryPositions.positions.slice(\r\n this.trajectoryPositions.positions.length - this._globalSettings.positionHistorySize\r\n )\r\n }\r\n }\r\n\r\n const trajectoryTimeChanged = this.updateNumericSettings(\r\n props?.trajectoryPredictionTime,\r\n \"trajectoryPredictionTime\",\r\n MIN_TRAJECTORY_PREDICTION_TIME,\r\n MAX_TRAJECTORY_PREDICTION_TIME\r\n )\r\n\r\n const scrollMarginChanged = this.updateNumericSettings(\r\n props?.scrollMargin,\r\n \"scrollMargin\",\r\n MIN_SCROLL_MARGIN,\r\n MAX_SCROLL_MARGIN\r\n )\r\n\r\n const tabOffsetChanged = this.updateNumericSettings(\r\n props?.tabOffset,\r\n \"tabOffset\",\r\n MIN_TAB_OFFSET,\r\n MAX_TAB_OFFSET\r\n )\r\n\r\n if (props?.resizeScrollThrottleDelay !== undefined) {\r\n console.warn(\r\n \"resizeScrollThrottleDelay is deprecated and will be removed in V3.0.0 of ForesightJS\"\r\n )\r\n }\r\n\r\n const mousePredictionChanged = this.updateBooleanSetting(\r\n props?.enableMousePrediction,\r\n \"enableMousePrediction\"\r\n )\r\n\r\n const scrollPredictionChanged = this.updateBooleanSetting(\r\n props?.enableScrollPrediction,\r\n \"enableScrollPrediction\"\r\n )\r\n\r\n const tabPredictionChanged = this.updateBooleanSetting(\r\n props?.enableTabPrediction,\r\n \"enableTabPrediction\"\r\n )\r\n\r\n if (props?.onAnyCallbackFired !== undefined) {\r\n this._globalSettings.onAnyCallbackFired = props.onAnyCallbackFired\r\n }\r\n\r\n let debuggerSettingsChanged = false\r\n if (props?.debuggerSettings?.isControlPanelDefaultMinimized !== undefined) {\r\n this._globalSettings.debuggerSettings.isControlPanelDefaultMinimized =\r\n props.debuggerSettings.isControlPanelDefaultMinimized\r\n debuggerSettingsChanged = true\r\n }\r\n\r\n if (props?.debuggerSettings?.showNameTags !== undefined) {\r\n this._globalSettings.debuggerSettings.showNameTags = props.debuggerSettings.showNameTags\r\n debuggerSettingsChanged = true\r\n if (this.debugger) {\r\n this.debugger.toggleNameTagVisibility()\r\n }\r\n }\r\n\r\n if (props?.debuggerSettings?.sortElementList !== undefined) {\r\n this._globalSettings.debuggerSettings.sortElementList = props.debuggerSettings.sortElementList\r\n debuggerSettingsChanged = true\r\n if (this.debugger) {\r\n // this.debugger.()\r\n }\r\n }\r\n\r\n let hitSlopChanged = false\r\n if (props?.defaultHitSlop !== undefined) {\r\n const normalizedNewHitSlop = normalizeHitSlop(\r\n props.defaultHitSlop,\r\n this._globalSettings.debug\r\n )\r\n if (!areRectsEqual(this._globalSettings.defaultHitSlop, normalizedNewHitSlop)) {\r\n this._globalSettings.defaultHitSlop = normalizedNewHitSlop\r\n hitSlopChanged = true\r\n this.forceUpdateAllElementBounds()\r\n }\r\n }\r\n\r\n let debugModeChanged = false\r\n if (props?.debug !== undefined && this._globalSettings.debug !== props.debug) {\r\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\r\n this._globalSettings.debug = props.debug\r\n debugModeChanged = true\r\n if (this._globalSettings.debug) {\r\n this.turnOnDebugMode()\r\n } else {\r\n if (this.debugger) {\r\n this.debugger.cleanup()\r\n this.debugger = null\r\n }\r\n }\r\n }\r\n }\r\n\r\n const settingsActuallyChanged =\r\n positionHistoryChanged ||\r\n trajectoryTimeChanged ||\r\n tabOffsetChanged ||\r\n mousePredictionChanged ||\r\n tabPredictionChanged ||\r\n scrollPredictionChanged ||\r\n debuggerSettingsChanged ||\r\n hitSlopChanged ||\r\n scrollMarginChanged ||\r\n debugModeChanged\r\n\r\n if (settingsActuallyChanged && this.debugger) {\r\n this.debugger.updateControlsState(this._globalSettings)\r\n }\r\n }\r\n private turnOnDebugMode() {\r\n if (!this.debugger) {\r\n this.debugger = ForesightDebugger.initialize(\r\n ForesightManager.instance,\r\n this.trajectoryPositions\r\n )\r\n const elementsArray = Array.from(this.elements.values())\r\n elementsArray.forEach((elementData, index) => {\r\n const isLastElement = index === elementsArray.length - 1\r\n this.debugger?.addElement(elementData, isLastElement)\r\n })\r\n } else {\r\n this.debugger.updateControlsState(this._globalSettings)\r\n }\r\n }\r\n\r\n private forceUpdateAllElementBounds() {\r\n this.elements.forEach((_, element) => {\r\n const elementData = this.elements.get(element)\r\n // For performance only update rects that are currently intersecting with the viewport\r\n if (elementData && elementData.isIntersectingWithViewport) {\r\n this.forceUpdateElementBounds(elementData)\r\n }\r\n })\r\n }\r\n\r\n private updatePointerState(e: MouseEvent): void {\r\n this.trajectoryPositions.currentPoint = { x: e.clientX, y: e.clientY }\r\n this.trajectoryPositions.predictedPoint = this._globalSettings.enableMousePrediction\r\n ? predictNextMousePosition(\r\n this.trajectoryPositions.currentPoint,\r\n this.trajectoryPositions.positions, // History before the currentPoint was added\r\n this._globalSettings.positionHistorySize,\r\n this._globalSettings.trajectoryPredictionTime\r\n )\r\n : { ...this.trajectoryPositions.currentPoint }\r\n }\r\n\r\n /**\r\n * Processes elements that unregister after a single callback.\r\n *\r\n * This is a \"fire-and-forget\" handler. Its only goal is to trigger the\r\n * callback once. It does so if the mouse trajectory is predicted to hit the\r\n * element (if prediction is on) OR if the mouse physically hovers over it.\r\n * It does not track state, as the element is immediately unregistered.\r\n *\r\n * @param elementData - The data object for the foresight element.\r\n * @param element - The HTML element being interacted with.\r\n */\r\n private handleSingleCallbackInteraction(elementData: ForesightElementData) {\r\n const { expandedRect } = elementData.elementBounds\r\n\r\n // when enable mouse prediction is off, we only check if the mouse is physically hovering over the element\r\n if (!this._globalSettings.enableMousePrediction) {\r\n if (isPointInRectangle(this.trajectoryPositions.currentPoint, expandedRect)) {\r\n this.callCallback(elementData, { kind: \"mouse\", subType: \"hover\" })\r\n return\r\n }\r\n } else if (\r\n lineSegmentIntersectsRect(\r\n this.trajectoryPositions.currentPoint,\r\n this.trajectoryPositions.predictedPoint,\r\n expandedRect\r\n )\r\n ) {\r\n this.callCallback(elementData, { kind: \"mouse\", subType: \"trajectory\" })\r\n }\r\n }\r\n\r\n /**\r\n * Processes persistent elements that can have multiple callbacks and require state tracking.\r\n *\r\n * This handler is responsible for elements where `unregisterOnCallback` is false.\r\n * It triggers callbacks only on the \"leading edge\" of an interaction—that is,\r\n * the first moment the mouse enters an element or the first moment a trajectory\r\n * is predicted to hit it. This prevents the callback from firing on every\r\n * mouse move. It also manages the element's state (`isHovering`, `isTrajectoryHit`)\r\n * for visual feedback in the {@link ForesightDebugger}.\r\n *\r\n * @param elementData - The current data object for the foresight element.\r\n * @param element - The HTML element being interacted with.\r\n */\r\n private handleMultiCallbackInteraction(elementData: ForesightElementData) {\r\n const { expandedRect } = elementData.elementBounds\r\n const isHovering = isPointInRectangle(this.trajectoryPositions.currentPoint, expandedRect)\r\n\r\n const isNewPhysicalHover = isHovering && !elementData.isHovering\r\n const isNewTrajectoryHit =\r\n this._globalSettings.enableMousePrediction &&\r\n !isHovering &&\r\n !elementData.trajectoryHitData.isTrajectoryHit &&\r\n lineSegmentIntersectsRect(\r\n this.trajectoryPositions.currentPoint,\r\n this.trajectoryPositions.predictedPoint,\r\n expandedRect\r\n )\r\n\r\n if (isNewPhysicalHover || isNewTrajectoryHit) {\r\n this.callCallback(elementData, {\r\n kind: \"mouse\",\r\n subType: isNewPhysicalHover ? \"hover\" : \"trajectory\",\r\n })\r\n }\r\n\r\n const hasStateChanged = isHovering !== elementData.isHovering || isNewTrajectoryHit\r\n\r\n if (hasStateChanged) {\r\n const newElementData: ForesightElementData = {\r\n ...elementData,\r\n isHovering: isHovering,\r\n trajectoryHitData: {\r\n ...elementData.trajectoryHitData,\r\n isTrajectoryHit: isNewTrajectoryHit,\r\n trajectoryHitTime: isNewTrajectoryHit\r\n ? performance.now()\r\n : elementData.trajectoryHitData.trajectoryHitTime,\r\n },\r\n }\r\n if (isNewTrajectoryHit) {\r\n if (newElementData.trajectoryHitData.trajectoryHitExpirationTimeoutId) {\r\n clearTimeout(newElementData.trajectoryHitData.trajectoryHitExpirationTimeoutId)\r\n }\r\n newElementData.trajectoryHitData.trajectoryHitExpirationTimeoutId = setTimeout(() => {\r\n const currentData = this.elements.get(elementData.element)\r\n if (\r\n currentData &&\r\n currentData.trajectoryHitData.trajectoryHitTime ===\r\n newElementData.trajectoryHitData.trajectoryHitTime\r\n ) {\r\n currentData.trajectoryHitData.isTrajectoryHit = false\r\n this.debugger?.createOrUpdateElementOverlay(currentData)\r\n }\r\n }, 200)\r\n }\r\n this.elements.set(elementData.element, newElementData)\r\n }\r\n }\r\n\r\n private handleMouseMove = (e: MouseEvent) => {\r\n this.updatePointerState(e)\r\n\r\n this.elements.forEach((currentData) => {\r\n if (!currentData.isIntersectingWithViewport) {\r\n return\r\n }\r\n\r\n if (!currentData.unregisterOnCallback) {\r\n this.handleMultiCallbackInteraction(currentData)\r\n } else {\r\n this.handleSingleCallbackInteraction(currentData)\r\n }\r\n })\r\n\r\n if (this.debugger) {\r\n this.debugger.hideScrollTrajectoryVisuals()\r\n this.debugger.updateMouseTrajectoryVisuals(\r\n this.trajectoryPositions,\r\n this._globalSettings.enableMousePrediction\r\n )\r\n }\r\n }\r\n\r\n /**\r\n * Detects when registered elements are removed from the DOM and automatically unregisters them to prevent stale references.\r\n *\r\n * @param mutationsList - Array of MutationRecord objects describing the DOM changes\r\n *\r\n */\r\n private handleDomMutations = (mutationsList: MutationRecord[]) => {\r\n // Invalidate tabbale elements cache\r\n if (mutationsList.length) {\r\n this.tabbableElementsCache = []\r\n this.lastFocusedIndex = null\r\n }\r\n for (const mutation of mutationsList) {\r\n if (mutation.type === \"childList\" && mutation.removedNodes.length > 0) {\r\n for (const element of Array.from(this.elements.keys())) {\r\n if (!element.isConnected) {\r\n this.unregister(element)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // We store the last key for the FocusIn event, meaning we know if the user is tabbing around the page.\r\n // We dont use handleKeyDown for the full event because of 2 main reasons:\r\n // 1: handleKeyDown e.target returns the target on which the keydown is pressed (meaning we dont know which target got the focus)\r\n // 2: handleKeyUp does return the correct e.target however when holding tab the event doesnt repeat (handleKeyDown does)\r\n private handleKeyDown = (e: KeyboardEvent) => {\r\n if (e.key === \"Tab\") {\r\n this.lastKeyDown = e\r\n }\r\n }\r\n\r\n private handleFocusIn = (e: FocusEvent) => {\r\n if (!this.lastKeyDown || !this._globalSettings.enableTabPrediction) {\r\n return\r\n }\r\n const targetElement = e.target\r\n if (!(targetElement instanceof HTMLElement)) {\r\n return\r\n }\r\n\r\n // tabbable uses element.GetBoundingClientRect under the hood, to avoid alot of computations we cache its values\r\n if (!this.tabbableElementsCache.length) {\r\n this.tabbableElementsCache = tabbable(document.documentElement)\r\n if (this._globalSettings.debug) {\r\n console.log(\"ForesightJS: Recomputed tabbable elements cache because of DOM change\")\r\n }\r\n }\r\n\r\n // Determine the range of elements to check based on the tab direction and offset\r\n const isReversed = this.lastKeyDown.shiftKey\r\n\r\n const currentIndex: number = getFocusedElementIndex(\r\n isReversed,\r\n this.lastFocusedIndex,\r\n this.tabbableElementsCache,\r\n targetElement\r\n )\r\n\r\n this.lastFocusedIndex = currentIndex\r\n\r\n this.lastKeyDown = null\r\n const elementsToPredict: ForesightElement[] = []\r\n for (let i = 0; i <= this._globalSettings.tabOffset; i++) {\r\n if (isReversed) {\r\n const element = this.tabbableElementsCache[currentIndex - i]\r\n if (this.elements.has(element as ForesightElement)) {\r\n elementsToPredict.push(element as ForesightElement)\r\n }\r\n } else {\r\n const element = this.tabbableElementsCache[currentIndex + i]\r\n if (this.elements.has(element as ForesightElement)) {\r\n elementsToPredict.push(element as ForesightElement)\r\n }\r\n }\r\n }\r\n\r\n elementsToPredict.forEach((element) => {\r\n this.callCallback(this.elements.get(element), {\r\n kind: \"tab\",\r\n subType: isReversed ? \"reverse\" : \"forwards\",\r\n })\r\n })\r\n }\r\n\r\n private updateHitCounters(elementData: ForesightElementData, hitType: HitType) {\r\n switch (hitType.kind) {\r\n case \"mouse\":\r\n elementData.callbackHits.mouse[hitType.subType]++\r\n this._globalCallbackHits.mouse[hitType.subType]++\r\n break\r\n case \"tab\":\r\n elementData.callbackHits.tab[hitType.subType]++\r\n this._globalCallbackHits.tab[hitType.subType]++\r\n break\r\n case \"scroll\":\r\n elementData.callbackHits.scroll[hitType.subType]++\r\n this._globalCallbackHits.scroll[hitType.subType]++\r\n break\r\n }\r\n elementData.callbackHits.total++\r\n this._globalCallbackHits.total++\r\n }\r\n\r\n private callCallback(elementData: ForesightElementData | undefined, hitType: HitType) {\r\n if (elementData) {\r\n this.updateHitCounters(elementData, hitType)\r\n elementData.callback()\r\n this._globalSettings.onAnyCallbackFired(elementData, this.getManagerData)\r\n if (this.debugger) {\r\n this.debugger.showCallbackAnimation(elementData)\r\n }\r\n // Do everything and then unregister. Always keep this at the end of the function\r\n if (elementData.unregisterOnCallback) {\r\n this.unregister(elementData.element)\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 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.\r\n * We need an observer for that\r\n */\r\n private forceUpdateElementBounds(elementData: ForesightElementData) {\r\n const newOriginalRect = elementData.element.getBoundingClientRect()\r\n const expandedRect = getExpandedRect(newOriginalRect, elementData.elementBounds.hitSlop)\r\n\r\n // Since its a force update, rects can be equal.\r\n if (!areRectsEqual(expandedRect, elementData.elementBounds.expandedRect)) {\r\n this.elements.set(elementData.element, {\r\n ...elementData,\r\n elementBounds: {\r\n ...elementData.elementBounds,\r\n originalRect: newOriginalRect,\r\n expandedRect,\r\n },\r\n })\r\n\r\n if (this.debugger) {\r\n const updatedData = this.elements.get(elementData.element)\r\n if (updatedData) this.debugger.createOrUpdateElementOverlay(updatedData)\r\n }\r\n }\r\n }\r\n\r\n private updateElementBounds(newRect: DOMRect, elementData: ForesightElementData) {\r\n // We dont check if rects are equal like we do in forceUpdateElementBounds, since rects can never be equal here\r\n this.elements.set(elementData.element, {\r\n ...elementData,\r\n elementBounds: {\r\n ...elementData.elementBounds,\r\n originalRect: newRect,\r\n expandedRect: getExpandedRect(newRect, elementData.elementBounds.hitSlop),\r\n },\r\n })\r\n\r\n if (this.debugger) {\r\n const updatedData = this.elements.get(elementData.element)\r\n if (updatedData) this.debugger.createOrUpdateElementOverlay(updatedData)\r\n }\r\n }\r\n\r\n private handleScrollPrefetch(elementData: ForesightElementData, newRect: DOMRect) {\r\n if (this._globalSettings.enableScrollPrediction) {\r\n // This means the foresightmanager is initializing registered elements, we dont want to calc the scroll direction here\r\n if (!elementData.elementBounds.originalRect) {\r\n return\r\n }\r\n // ONCE per animation frame we decide what the scroll direction is\r\n this.scrollDirection =\r\n this.scrollDirection ?? getScrollDirection(elementData.elementBounds.originalRect, newRect)\r\n if (this.scrollDirection === \"none\") {\r\n return\r\n }\r\n\r\n // ONCE per animation frame we decide the predicted scroll point\r\n this.predictedScrollPoint =\r\n this.predictedScrollPoint ??\r\n predictNextScrollPosition(\r\n this.trajectoryPositions.currentPoint,\r\n this.scrollDirection,\r\n this._globalSettings.scrollMargin\r\n )\r\n\r\n if (\r\n lineSegmentIntersectsRect(\r\n this.trajectoryPositions.currentPoint,\r\n this.predictedScrollPoint,\r\n elementData?.elementBounds.expandedRect\r\n )\r\n ) {\r\n this.callCallback(elementData, {\r\n kind: \"scroll\",\r\n subType: this.scrollDirection,\r\n })\r\n }\r\n if (this.debugger) {\r\n this.debugger.updateScrollTrajectoryVisuals(\r\n this.trajectoryPositions.currentPoint,\r\n this.predictedScrollPoint\r\n )\r\n }\r\n } else {\r\n if (\r\n isPointInRectangle(\r\n this.trajectoryPositions.currentPoint,\r\n elementData.elementBounds.expandedRect\r\n )\r\n ) {\r\n this.callCallback(elementData, {\r\n kind: \"mouse\",\r\n subType: \"hover\",\r\n })\r\n }\r\n }\r\n }\r\n\r\n private handlePositionChange = (entries: PositionObserverEntry[]) => {\r\n for (const entry of entries) {\r\n const elementData = this.elements.get(entry.target)\r\n if (!elementData) continue\r\n const wasPreviouslyIntersecting = elementData.isIntersectingWithViewport\r\n const isNowIntersecting = entry.isIntersecting\r\n elementData.isIntersectingWithViewport = isNowIntersecting\r\n\r\n if (wasPreviouslyIntersecting !== isNowIntersecting) {\r\n this.debugger?.updateElementVisibilityStatus(elementData)\r\n }\r\n if (!isNowIntersecting) {\r\n if (this._globalSettings.debug && wasPreviouslyIntersecting) {\r\n this.debugger?.removeElementOverlay(elementData)\r\n }\r\n continue\r\n }\r\n this.updateElementBounds(entry.boundingClientRect, elementData)\r\n this.handleScrollPrefetch(elementData, entry.boundingClientRect)\r\n }\r\n\r\n this.scrollDirection = null\r\n this.predictedScrollPoint = null\r\n }\r\n\r\n private initializeGlobalListeners() {\r\n if (this.isSetup) {\r\n return\r\n }\r\n // To avoid setting up listeners while ssr\r\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\r\n return\r\n }\r\n\r\n this.globalListenersController = new AbortController()\r\n const { signal } = this.globalListenersController\r\n document.addEventListener(\"mousemove\", this.handleMouseMove, { signal })\r\n document.addEventListener(\"keydown\", this.handleKeyDown, { signal })\r\n document.addEventListener(\"focusin\", this.handleFocusIn, { signal })\r\n\r\n //Mutation observer is to automatically unregister elements when they leave the DOM. Its a fail-safe for if the user forgets to do it.\r\n this.domObserver = new MutationObserver(this.handleDomMutations)\r\n this.domObserver.observe(document.documentElement, {\r\n childList: true,\r\n subtree: true,\r\n attributes: false,\r\n })\r\n\r\n // Handles all position based changes and update the rects of the elements. completely async to avoid dirtying the main thread.\r\n // Handles resize of elements\r\n // Handles resize of viewport\r\n // Handles scrolling\r\n this.positionObserver = new PositionObserver(this.handlePositionChange)\r\n\r\n this.isSetup = true\r\n }\r\n\r\n private removeGlobalListeners() {\r\n this.isSetup = false\r\n if (!this.debugger) {\r\n this.globalListenersController?.abort() // Remove all event listeners only in non debug mode\r\n this.globalListenersController = null\r\n } else {\r\n console.log(\r\n \"ForesightJS: All elements have successfully been unregistered. ForesightJS would typically perform cleanup events now, but these are currently skipped while in debug mode. Observers are cleared up.\"\r\n )\r\n }\r\n this.domObserver?.disconnect()\r\n this.domObserver = null\r\n this.positionObserver?.disconnect()\r\n this.positionObserver = null\r\n }\r\n}\r\n","import type { FocusableElement } from \"tabbable\"\r\n\r\n/**\r\n * Finds the index of a focused element within a cache of tabbable elements.\r\n * It uses a predictive search for O(1) performance in the common case of\r\n * sequential tabbing, and falls back to a linear search O(n) if the\r\n * prediction fails.\r\n *\r\n * @param isReversed - True if the user is tabbing backward (Shift+Tab).\r\n * @param lastFocusedIndex - The index of the previously focused element, or null if none.\r\n * @param tabbableElementsCache - The array of all tabbable elements.\r\n * @param targetElement - The new HTML element that has received focus.\r\n * @returns The index of the targetElement in the cache, or -1 if not found.\r\n */\r\nexport function getFocusedElementIndex(\r\n isReversed: boolean,\r\n lastFocusedIndex: number | null,\r\n tabbableElementsCache: FocusableElement[],\r\n targetElement: HTMLElement\r\n): number {\r\n // First, try to predict the next index based on the last known position.\r\n if (lastFocusedIndex !== null) {\r\n const predictedIndex = isReversed ? lastFocusedIndex - 1 : lastFocusedIndex + 1\r\n\r\n // Check if the prediction is valid and correct.\r\n if (\r\n predictedIndex >= 0 &&\r\n predictedIndex < tabbableElementsCache.length &&\r\n tabbableElementsCache[predictedIndex] === targetElement\r\n ) {\r\n return predictedIndex\r\n }\r\n }\r\n\r\n // Slow way if we dont find it\r\n return tabbableElementsCache.findIndex((element) => element === targetElement)\r\n}\r\n","import type { MousePosition, Point } from \"../../types/types\"\r\n\r\n/**\r\n * Predicts the next mouse position based on a history of recent movements.\r\n * It calculates velocity from the historical data and extrapolates a future point.\r\n * The `history` array is mutated by this function: the new `currentPoint` is added,\r\n * and if the history exceeds `positionHistorySize`, the oldest entry is removed.\r\n *\r\n * @param currentPoint - The current actual mouse coordinates.\r\n * @param history - An array of previous mouse positions with timestamps.\r\n * This array will be modified by this function.\r\n * @param positionHistorySize - The maximum number of past positions to store and consider\r\n * for the prediction.\r\n * @param trajectoryPredictionTimeInMs - How far into the future (in milliseconds)\r\n * to predict the mouse position.\r\n * @returns The predicted {@link Point} (x, y coordinates). If history is insufficient\r\n * (less than 2 points) or time delta is zero, returns the `currentPoint`.\r\n */\r\nexport function predictNextMousePosition(\r\n currentPoint: Point,\r\n history: MousePosition[],\r\n positionHistorySize: number,\r\n trajectoryPredictionTimeInMs: number\r\n): Point {\r\n const now = performance.now()\r\n const currentPosition: MousePosition = { point: currentPoint, time: now }\r\n const { x, y } = currentPoint\r\n\r\n history.push(currentPosition)\r\n if (history.length > positionHistorySize) {\r\n history.shift()\r\n }\r\n\r\n if (history.length < 2) {\r\n return { x, y }\r\n }\r\n\r\n const first = history[0]\r\n const last = history[history.length - 1]\r\n const dt = (last.time - first.time) / 1000\r\n\r\n if (dt === 0) {\r\n return { x, y }\r\n }\r\n\r\n const dx = last.point.x - first.point.x\r\n const dy = last.point.y - first.point.y\r\n const vx = dx / dt\r\n const vy = dy / dt\r\n\r\n const trajectoryPredictionTimeInSeconds = trajectoryPredictionTimeInMs / 1000\r\n const predictedX = x + vx * trajectoryPredictionTimeInSeconds\r\n const predictedY = y + vy * trajectoryPredictionTimeInSeconds\r\n\r\n return { x: predictedX, y: predictedY }\r\n}\r\n","import type { Rect, ScrollDirection } from \"../../types/types\"\r\n\r\nexport function getScrollDirection(oldRect: Rect, newRect: Rect): ScrollDirection {\r\n const scrollThreshold = 1\r\n const deltaY = newRect.top - oldRect.top\r\n const deltaX = newRect.left - oldRect.left\r\n\r\n // Check vertical scroll first (most common)\r\n if (deltaY < -scrollThreshold) {\r\n return \"down\" // Element moved up in viewport = scrolled down\r\n } else if (deltaY > scrollThreshold) {\r\n return \"up\" // Element moved down in viewport = scrolled up\r\n }\r\n\r\n // Check horizontal scroll\r\n if (deltaX < -scrollThreshold) {\r\n return \"right\" // Element moved left in viewport = scrolled right\r\n } else if (deltaX > scrollThreshold) {\r\n return \"left\" // Element moved right in viewport = scrolled left\r\n }\r\n\r\n return \"none\" // No significant movement detected\r\n}\r\n","import type { Point, ScrollDirection } from \"../../types/types\"\r\n\r\nexport function predictNextScrollPosition(\r\n currentPoint: Point,\r\n direction: ScrollDirection,\r\n scrollMargin: number\r\n) {\r\n const { x, y } = currentPoint\r\n const predictedPoint = { x, y }\r\n\r\n switch (direction) {\r\n case \"down\":\r\n predictedPoint.y += scrollMargin\r\n break\r\n case \"up\":\r\n predictedPoint.y -= scrollMargin\r\n break\r\n case \"left\":\r\n predictedPoint.x -= scrollMargin\r\n break\r\n case \"right\":\r\n predictedPoint.x += scrollMargin\r\n break\r\n }\r\n return predictedPoint\r\n}\r\n"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","SuppressedError","candidateSelector","join","NoElement","Element","matches","msMatchesSelector","webkitMatchesSelector","getRootNode","element","_element$getRootNode","ownerDocument","isInert","node","lookUp","_node$getAttribute","inertAtt","getAttribute","parentNode","getCandidatesIteratively","elements","includeContainer","options","candidates","elementsToCheck","Array","from","shift","tagName","assigned","assignedElements","nestedCandidates","children","flatten","push","scopeParent","filter","includes","shadowRoot","getShadowRoot","validShadowRoot","shadowRootFilter","_nestedCandidates","unshift","hasTabIndex","isNaN","parseInt","getTabIndex","Error","tabIndex","test","_node$getAttribute2","attValue","isContentEditable","sortOrderedTabbables","a","b","documentOrder","isInput","isNonTabbableRadio","type","isRadio","name","radioSet","radioScope","form","queryRadios","querySelectorAll","window","CSS","escape","err","console","error","message","checked","nodes","getCheckedRadio","isTabbableRadio","isZeroArea","_node$getBoundingClie","getBoundingClientRect","width","height","isHidden","_ref","displayCheck","getComputedStyle","visibility","nodeUnderDetails","parentElement","originalNode","rootNode","assignedSlot","host","_nodeRoot","_nodeRootHost","_nodeRootHost$ownerDo","_node$ownerDocument","nodeRoot","nodeRootHost","attached","contains","_nodeRoot2","_nodeRootHost2","_nodeRootHost2$ownerD","isNodeAttached","getClientRects","isNodeMatchingSelectorFocusable","disabled","isHiddenInput","slice","some","child","isDetailsWithSummary","item","isDisabledFromFieldset","isNodeMatchingSelectorTabbable","isValidShadowRootTabbable","shadowHostNode","sortByOrder","regularTabbables","orderedTabbables","forEach","isScope","candidateTabindex","getSortOrderTabIndex","content","sort","reduce","acc","sortable","concat","tabbable","container","bind","el","getCandidates","TRAJECTORY_PREDICTION_TIME_UNIT","POSITION_HISTORY_SIZE_UNIT","TAB_OFFSET_UNIT","MAX_HITSLOP","DEFAULT_IS_DEBUGGER_MINIMIZED","DEFAULT_SHOW_NAME_TAGS","formatValue","value","indent","spaces","repeat","isArray","entries","formattedEntries","map","_a","key","val","String","undefined","JSON","stringify","createAndAppendElement","tag","parent","attributes","document","createElement","id","className","data","setAttribute","appendChild","createAndAppendStyle","styleSheet","textContent","getIntersectingIcon","isIntersectingWithViewport","COPY_SVG_ICON","NO_ELEMENTS_STRING","DebuggerControlPanel","foresightManager","elementListItemsContainer","elementCountSpan","callbackCountSpan","elementListItems","Map","trajectoryEnabledCheckbox","tabEnabledCheckbox","scrollEnabledCheckbox","historySizeSlider","historyValueSpan","predictionTimeSlider","predictionValueSpan","tabOffsetSlider","tabOffsetValueSpan","scrollMarginSlider","scrollMarginValueSpan","showNameTagsCheckbox","sortOptionsPopup","sortButton","containerMinimizeButton","allSettingsSectionsContainer","debuggerElementsSection","isContainerMinimized","isMouseSettingsMinimized","isKeyboardSettingsMinimized","isScrollSettingsMinimized","isGeneralSettingsMinimized","SESSION_STORAGE_KEY","copySettingsButton","copyTimeoutId","closeSortDropdownHandler","foresightManagerInstance","_setupDOMAndListeners","debuggerSettings","controlsContainer","isControlPanelDefaultMinimized","createControlContainer","controlPanelStyleElement","getStyles","queryDOMElements","originalSectionStates","setupEventListeners","updateContainerVisibilityState","initialize","isInitiated","debuggerControlPanelInstance","instance","defineProperty","get","loadSectionStatesFromSessionStorage","storedStatesRaw","sessionStorage","getItem","loadedStates","parse","mouse","_b","keyboard","_c","scroll","_d","general","saveSectionStatesToSessionStorage","states","setItem","e","querySelector","handleCopySettings","obj","methodName","_this","navigator","clipboard","writeText","getManagerData","globalSettings","then","innerHTML","clearTimeout","setTimeout","catch","createInputEventListener","spanElement","unit","setting","addEventListener","target","alterGlobalSettings","createChangeEventListener","showNameTags","createSectionVisibilityToggleEventListener","section","isMinimizedFlagName","sectionHeader","stopPropagation","toggleMinimizeSection","classList","toggle","closest","dataset","sortElementList","log","sortAndReorderElements","updateSortOptionUI","remove","shouldMinimize","sectionContent","minimizeButton","style","display","elementListContent","_e","add","currentSort","button","btn","updateControlsState","settings","enableMousePrediction","enableTabPrediction","enableScrollPrediction","positionHistorySize","toString","trajectoryPredictionTime","tabOffset","scrollMargin","refreshRegisteredElementCountDisplay","elementsMap","visibleElementCount","totalElements","size","globalCallbackHits","tab","total","title","hover","trajectory","forwards","reverse","down","left","right","up","removeElementFromList","elementData","listItem","delete","registeredElements","updateElementVisibilityStatus","intersectingElement","intersectingIcon","addElementToList","sortOrder","elementsData","values","sortByDocumentPosition_1","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","fragment","createDocumentFragment","has","updateListItemContent","set","hitBehaviorText","unregisterOnCallback","hitSlopText","elementBounds","hitSlop","top_1","top","bottom","comprehensiveTitle","cleanup","removeEventListener","clear","rowsContentHeight","elementItemHeight","numItemsPerRow","updateElementOverlays","currentOverlays","newData","expandedOverlay","nameLabel","expandedRect","expandedWidth","expandedHeight","transform","Rect","intersect","rect1","rect2","Math","max","min","DOMRect","clip","rect","updatedRect","toJSON","clipOffsets","clippedRect","equals","x","y","sizeEqual","round","rootMargin","rootBounds","threshold","_","PositionIntersectionObserver","constructor","callback","clientRect","observe","observer","previousIntersectionRatio","visibleRect","isIntersecting","root","disconnect","IntersectionObserver","onIntersection","entry","intersectionRatio","boundingClientRect","previousClientRect","clientRectChanged","rootIntersection","PositionIntersectionObserverEntry","intersectionRect","RootBoundsObserver","nodeType","DOCUMENT_NODE","isDocument","defaultView","getRoot","isNode","ELEMENT_NODE","isElement","resizeObserver","ResizeObserver","inlineSize","blockSize","borderBoxSize","event","capture","passive","signal","controller","viewport","visualViewport","getWindowRect","handleResize","AbortController","abort","window2","innerWidth","innerHeight","VisibilityObserver","changedEntries","previousIntersection","intersections","observers","WeakMap","document2","unobserve","PositionObserver","rootBoundsObserver","onRootBoundsChange","visibilityObserver","onVisibilityChange","onResize","positionObservers","positions","positionObserver","notify","records","isEntryEqual","observePosition","PositionObserverEntry","onPositionChange","intersection","previous","first","second","evaluateRegistrationConditions","connection","isTouchDevice","matchMedia","maxTouchPoints","isLimitedConnection","effectiveType","saveData","shouldRegister","ForesightDebugger","callbackAnimations","debugElementOverlays","predictedMouseIndicator","mouseTrajectoryLine","scrollTrajectoryLine","animationPositionObserver","handleAnimationPositionChange","_i","entries_1","animationData","overlay","newLeft","newTop","newWidth","newHeight","_setupDOM","shadowHost","body","attachShadow","mode","debugContainer","controlPanel","debuggerCSS","debuggerInstance","trajectoryPositions","updateMouseTrajectoryVisuals","createElementOverlays","overlays","createOrUpdateElementOverlay","toggleNameTagVisibility","removeElement","removeElementOverlay","addElement","predictedPoint","currentPoint","dx","dy","sqrt","angle","atan2","PI","updateScrollTrajectoryVisuals","predictedScrollPoint","hideScrollTrajectoryVisuals","showCallbackAnimation","existingAnimation","timeoutId","animationOverlay","clampNumber","number","lowerBound","upperBound","isDebug","settingName","warn","lineSegmentIntersectsRect","p1","p2","t0","t1","clipTest","q","r","normalizeHitSlop","clampedValue","getExpandedRect","baseRect","areRectsEqual","isPointInRectangle","point","shouldUpdateSetting","newValue","currentValue","ForesightManager","isSetup","debugger","_globalCallbackHits","_globalSettings","debug","defaultHitSlop","resizeScrollThrottleDelay","onAnyCallbackFired","_elementData","_managerData","tabbableElementsCache","lastFocusedIndex","scrollDirection","domObserver","lastKeyDown","globalListenersController","handleMouseMove","updatePointerState","currentData","handleSingleCallbackInteraction","handleMultiCallbackInteraction","handleDomMutations","mutationsList","mutationsList_1","mutation","removedNodes","keys","isConnected","unregister","handleKeyDown","handleFocusIn","targetElement","HTMLElement","documentElement","isReversed","shiftKey","currentIndex","predictedIndex","findIndex","getFocusedElementIndex","elementsToPredict","callCallback","kind","subType","handlePositionChange","wasPreviouslyIntersecting","isNowIntersecting","updateElementBounds","handleScrollPrefetch","props","manager","register","isRegistered","initializeGlobalListeners","normalizedHitSlop","callbackHits","originalRect","isHovering","trajectoryHitData","isTrajectoryHit","trajectoryHitTime","trajectoryHitExpirationTimeoutId","foresightElementData","removeGlobalListeners","updateNumericSettings","updateBooleanSetting","oldPositionHistorySize","positionHistoryChanged","trajectoryTimeChanged","scrollMarginChanged","tabOffsetChanged","mousePredictionChanged","scrollPredictionChanged","tabPredictionChanged","debuggerSettingsChanged","hitSlopChanged","normalizedNewHitSlop","forceUpdateAllElementBounds","debugModeChanged","turnOnDebugMode","elementsArray_1","index","isLastElement","forceUpdateElementBounds","clientX","clientY","history","trajectoryPredictionTimeInMs","currentPosition","time","performance","now","last","dt","trajectoryPredictionTimeInSeconds","predictNextMousePosition","isNewPhysicalHover","isNewTrajectoryHit","newElementData_1","updateHitCounters","hitType","newOriginalRect","updatedData","newRect","oldRect","deltaY","deltaX","getScrollDirection","direction","predictNextScrollPosition","MutationObserver","childList","subtree"],"mappings":"aA+BO,IAAIA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,CACV,EACMH,EAASa,MAAMC,KAAMP,UAChC,EAgSkD,mBAApBQ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