@manototh/do11y 0.1.0 → 0.1.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > Originally derived from [github.com/axiomhq/do11y](https://github.com/axiomhq/do11y)
4
4
 
5
- Do11y is a documentation observability tool. It streams behavioral events from your docs site to [Supabase](https://supabase.com) (or any HTTP endpoint) in real time:
5
+ Do11y is a documentation observability tool. It streams behavioral events from your docs site to [Supabase](https://supabase.com) (or any HTTP endpoint or OpenTelemetry-compatible backend) in real time:
6
6
 
7
7
  - Page views
8
8
  - Scroll depth
@@ -42,6 +42,8 @@ Do11y supports the latest versions of the following frameworks:
42
42
  - Nextra
43
43
  - MkDocs Material
44
44
  - VitePress
45
+ - Starlight (Astro)
46
+ - Docsy (Hugo)
45
47
 
46
48
  For other frameworks, use manual setup with custom selectors.
47
49
 
package/dist/do11y.js CHANGED
@@ -66,9 +66,11 @@
66
66
  const EVENT_TOC_CLICK = "browser.do11y.toc_click";
67
67
  const EVENT_FEEDBACK = "browser.do11y.feedback";
68
68
  const EVENT_EXPAND_COLLAPSE = "browser.do11y.expand_collapse";
69
- const VERSION = "0.1.0";
69
+ const VERSION = "0.1.2";
70
70
  const _alreadyLoaded = !!window.__do11yInitialized;
71
71
  window.__do11yInitialized = true;
72
+ const _isInIframe = window.self !== window.top;
73
+ if (_isInIframe && !_alreadyLoaded) window.__do11yInitialized = false;
72
74
  const config = {
73
75
  destination: "supabase",
74
76
  supabaseUrl: "",
@@ -115,7 +117,9 @@
115
117
  navigationSelector: null,
116
118
  footerSelector: null,
117
119
  contentSelector: null,
118
- useOtelBrowserInstrumentations: false
120
+ useOtelBrowserInstrumentations: false,
121
+ testRunId: void 0,
122
+ testFramework: void 0
119
123
  };
120
124
  const FRAMEWORK_PRESETS = {
121
125
  mintlify: {
@@ -125,9 +129,9 @@
125
129
  navigationSelector: "nav, [role=\"navigation\"], #navbar, #sidebar, [class*=\"nav\"], [class*=\"sidebar\"]",
126
130
  footerSelector: "footer, [role=\"contentinfo\"], [class*=\"footer\"]",
127
131
  contentSelector: "main, article, [role=\"main\"], [class*=\"content\"]",
128
- tabContainerSelector: "[role=\"tablist\"], [class*=\"tab\"]",
132
+ tabContainerSelector: "tabs, [role=\"tablist\"], [class*=\"tab\"]",
129
133
  tocSelector: "#table-of-contents, [data-testid=\"table-of-contents\"], [class*=\"table-of-contents\"], [class*=\"toc\"]",
130
- feedbackSelector: "[class*=\"feedback\"], [class*=\"helpful\"]"
134
+ feedbackSelector: "feedback-toolbar, #feedback-thumbs-up, #feedback-thumbs-down, [class*=\"feedback\"], [class*=\"helpful\"]"
131
135
  },
132
136
  docusaurus: {
133
137
  searchSelector: ".DocSearch, .DocSearch-Button",
@@ -183,6 +187,17 @@
183
187
  tabContainerSelector: "starlight-tabs [role=\"tablist\"], [role=\"tablist\"]",
184
188
  tocSelector: ".right-sidebar-panel, starlight-toc, mobile-starlight-toc",
185
189
  feedbackSelector: "[class*=\"feedback\"], [class*=\"helpful\"]"
190
+ },
191
+ docsy: {
192
+ searchSelector: ".td-search input, .td-search__input, #docsearch-0, #docsearch-1",
193
+ copyButtonSelector: "button[aria-label*=\"copy\" i], button[title*=\"copy\" i], .td-click-to-copy",
194
+ codeBlockSelector: ".highlight, pre.chroma, pre",
195
+ navigationSelector: "nav, [role=\"navigation\"], .td-sidebar, .td-navbar, [class*=\"sidebar\"]",
196
+ footerSelector: "footer, [role=\"contentinfo\"], .td-footer, [class*=\"footer\"]",
197
+ contentSelector: "main, article, [role=\"main\"], .td-content, [class*=\"content\"]",
198
+ tabContainerSelector: ".nav-tabs[role=\"tablist\"], [role=\"tablist\"], .tab-content",
199
+ tocSelector: ".td-toc, nav[id=\"TableOfContents\"], [class*=\"toc\"]",
200
+ feedbackSelector: ".feedback--answer, [class*=\"feedback\"], [class*=\"helpful\"]"
186
201
  }
187
202
  };
188
203
  const SELECTOR_KEYS = [
@@ -558,6 +573,8 @@
558
573
  ...getBrowserContext(),
559
574
  ...eventData
560
575
  };
576
+ if (config.testRunId) event._testRunId = config.testRunId;
577
+ if (config.testFramework) event._testFramework = config.testFramework;
561
578
  if (config.debug) console.log("[Do11y] Event queued:", eventName, event);
562
579
  if (config.destination === "otlp" && _otelLogger) {
563
580
  _otelLogger.emit({
@@ -775,6 +792,8 @@
775
792
  /**
776
793
  * Synchronous flush used on `beforeunload`. For OTLP mode the SDK
777
794
  * handles flush on its own; for HTTP/Supabase we use fetch with keepalive.
795
+ * sendBeacon is not used because Supabase requires custom headers
796
+ * (apikey, Authorization) which sendBeacon does not support.
778
797
  */
779
798
  function flushSync() {
780
799
  if (config.destination === "otlp") return;
@@ -794,6 +813,7 @@
794
813
  if (config.debug) console.log("[Do11y] Sync flushed", events.length, "events");
795
814
  }
796
815
  function trackPageView() {
816
+ pageExited = false;
797
817
  const session = updatePageSequence(window.location.pathname);
798
818
  const referrerDomain = getReferrerDomain();
799
819
  const referrerInfo = classifyReferrer(referrerDomain);
@@ -967,7 +987,10 @@
967
987
  let lastActivityTime = Date.now();
968
988
  let totalActiveTime = 0;
969
989
  let isPageVisible = true;
990
+ let pageExited = false;
970
991
  function emitPageExit() {
992
+ if (pageExited) return;
993
+ pageExited = true;
971
994
  if (isPageVisible) totalActiveTime += Date.now() - lastActivityTime;
972
995
  const totalTime = Date.now() - pageLoadTime;
973
996
  const engagementRatio = totalTime > 0 ? totalActiveTime / totalTime : 0;
@@ -985,6 +1008,7 @@
985
1008
  [ATTR_DO11Y_REFERRER_CATEGORY]: session.referrerCategory,
986
1009
  [ATTR_DO11Y_AI_PLATFORM]: session.aiPlatform
987
1010
  });
1011
+ flush();
988
1012
  }
989
1013
  function setupEngagementTracking() {
990
1014
  document.addEventListener("visibilitychange", () => {
@@ -1044,21 +1068,39 @@
1044
1068
  const id = entry.target.getAttribute("data-do11y-section-id");
1045
1069
  if (!id) return;
1046
1070
  if (entry.isIntersecting) {
1047
- if (!sectionTimers[id]) sectionTimers[id] = {
1048
- start: Date.now(),
1049
- reported: false
1050
- };
1071
+ if (!sectionTimers[id]) {
1072
+ const timer = {
1073
+ start: Date.now(),
1074
+ reported: false,
1075
+ timeoutId: null
1076
+ };
1077
+ timer.timeoutId = setTimeout(() => {
1078
+ if (sectionTimers[id] && !sectionTimers[id].reported) {
1079
+ const heading = entry.target.textContent?.trim() ?? "";
1080
+ queueEvent(EVENT_SECTION_VISIBLE, {
1081
+ [ATTR_DO11Y_SECTION_HEADING]: sanitizeText(heading, 100),
1082
+ [ATTR_DO11Y_SECTION_HEADING_LEVEL]: parseInt(entry.target.tagName.charAt(1), 10),
1083
+ [ATTR_DO11Y_SECTION_VISIBLE_SECONDS]: Math.round(threshold / 1e3)
1084
+ });
1085
+ sectionTimers[id].reported = true;
1086
+ }
1087
+ }, threshold);
1088
+ sectionTimers[id] = timer;
1089
+ }
1051
1090
  } else {
1052
- if (sectionTimers[id] && !sectionTimers[id].reported) {
1053
- const elapsed = Date.now() - sectionTimers[id].start;
1054
- if (elapsed >= threshold) {
1055
- const heading = entry.target.textContent?.trim() ?? "";
1056
- queueEvent(EVENT_SECTION_VISIBLE, {
1057
- [ATTR_DO11Y_SECTION_HEADING]: sanitizeText(heading, 100),
1058
- [ATTR_DO11Y_SECTION_HEADING_LEVEL]: parseInt(entry.target.tagName.charAt(1), 10),
1059
- [ATTR_DO11Y_SECTION_VISIBLE_SECONDS]: Math.round(elapsed / 1e3)
1060
- });
1061
- sectionTimers[id].reported = true;
1091
+ if (sectionTimers[id]) {
1092
+ if (sectionTimers[id].timeoutId) clearTimeout(sectionTimers[id].timeoutId);
1093
+ if (!sectionTimers[id].reported) {
1094
+ const elapsed = Date.now() - sectionTimers[id].start;
1095
+ if (elapsed >= threshold) {
1096
+ const heading = entry.target.textContent?.trim() ?? "";
1097
+ queueEvent(EVENT_SECTION_VISIBLE, {
1098
+ [ATTR_DO11Y_SECTION_HEADING]: sanitizeText(heading, 100),
1099
+ [ATTR_DO11Y_SECTION_HEADING_LEVEL]: parseInt(entry.target.tagName.charAt(1), 10),
1100
+ [ATTR_DO11Y_SECTION_VISIBLE_SECONDS]: Math.round(elapsed / 1e3)
1101
+ });
1102
+ sectionTimers[id].reported = true;
1103
+ }
1062
1104
  }
1063
1105
  }
1064
1106
  delete sectionTimers[id];
@@ -1081,6 +1123,7 @@
1081
1123
  Object.keys(sectionTimers).forEach((id) => {
1082
1124
  const timer = sectionTimers[id];
1083
1125
  if (timer && !timer.reported) {
1126
+ if (timer.timeoutId) clearTimeout(timer.timeoutId);
1084
1127
  const elapsed = now - timer.start;
1085
1128
  if (elapsed >= threshold) {
1086
1129
  const escapedId = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(id) : id.replace(/["\\]/g, "\\$&");
@@ -1190,9 +1233,10 @@
1190
1233
  });
1191
1234
  }
1192
1235
  let mutationObserver = null;
1236
+ let pathPollId = null;
1193
1237
  function init() {
1194
1238
  if (window.Do11yConfig && typeof window.Do11yConfig === "object") {
1195
- for (const key in window.Do11yConfig) if (Object.prototype.hasOwnProperty.call(window.Do11yConfig, key) && Object.prototype.hasOwnProperty.call(config, key)) config[key] = window.Do11yConfig[key];
1239
+ for (const key in config) if (Object.prototype.hasOwnProperty.call(window.Do11yConfig, key)) config[key] = window.Do11yConfig[key];
1196
1240
  }
1197
1241
  const metaDestination = document.querySelector("meta[name=\"do11y-destination\"]");
1198
1242
  if (metaDestination) {
@@ -1261,38 +1305,26 @@
1261
1305
  setupFeedbackTracking();
1262
1306
  setupExpandCollapseTracking();
1263
1307
  let lastPath = window.location.pathname;
1264
- mutationObserver = new MutationObserver(() => {
1265
- if (window.location.pathname !== lastPath) {
1266
- lastPath = window.location.pathname;
1267
- emitPageExit();
1268
- trackedScrollDepths = /* @__PURE__ */ new Set();
1269
- pageLoadTime = Date.now();
1270
- lastActivityTime = Date.now();
1271
- totalActiveTime = 0;
1272
- isPageVisible = true;
1273
- trackPageView();
1274
- observeHeadings();
1275
- checkScrollDepth();
1276
- }
1277
- });
1308
+ const handlePathChange = () => {
1309
+ if (window.location.pathname === lastPath) return;
1310
+ lastPath = window.location.pathname;
1311
+ emitPageExit();
1312
+ trackedScrollDepths = /* @__PURE__ */ new Set();
1313
+ pageLoadTime = Date.now();
1314
+ lastActivityTime = Date.now();
1315
+ totalActiveTime = 0;
1316
+ isPageVisible = true;
1317
+ trackPageView();
1318
+ observeHeadings();
1319
+ checkScrollDepth();
1320
+ };
1321
+ mutationObserver = new MutationObserver(handlePathChange);
1278
1322
  mutationObserver.observe(document.body, {
1279
1323
  childList: true,
1280
1324
  subtree: true
1281
1325
  });
1282
- window.addEventListener("popstate", () => {
1283
- if (window.location.pathname !== lastPath) {
1284
- lastPath = window.location.pathname;
1285
- emitPageExit();
1286
- trackedScrollDepths = /* @__PURE__ */ new Set();
1287
- pageLoadTime = Date.now();
1288
- lastActivityTime = Date.now();
1289
- totalActiveTime = 0;
1290
- isPageVisible = true;
1291
- trackPageView();
1292
- observeHeadings();
1293
- checkScrollDepth();
1294
- }
1295
- });
1326
+ window.addEventListener("popstate", handlePathChange);
1327
+ pathPollId = window.setInterval(handlePathChange, 200);
1296
1328
  Object.freeze(config);
1297
1329
  if (config.debug) console.log("[Do11y] Initialized successfully");
1298
1330
  }
@@ -1310,9 +1342,13 @@
1310
1342
  clearTimeout(flushTimeout);
1311
1343
  flushTimeout = null;
1312
1344
  }
1345
+ if (pathPollId !== null) {
1346
+ clearInterval(pathPollId);
1347
+ pathPollId = null;
1348
+ }
1313
1349
  flushSync();
1314
1350
  }
1315
- if (!_alreadyLoaded) if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init);
1351
+ if (!_alreadyLoaded && !_isInIframe) if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init);
1316
1352
  else init();
1317
1353
  window.Do11y = window.Do11y ?? {
1318
1354
  getConfig: () => ({
package/dist/do11y.min.js CHANGED
@@ -1 +1 @@
1
- (function(){let e=`browser.do11y.referrer_category`,t=`browser.do11y.ai_platform`,n=`browser.do11y.scroll.threshold`,r=`browser.do11y.scroll.percent`,i=`browser.do11y.section.heading`,a=`browser.do11y.section.heading_level`,o=`browser.do11y.section.visible_seconds`,s=`browser.do11y.expand.summary`,c=`browser.do11y.expand.action`,l=`browser.do11y.expand.section`,u=`browser.do11y.scroll_depth`,d=`browser.do11y.search_opened`,f=`browser.do11y.section_visible`,p=`browser.do11y.expand_collapse`,m=`0.1.0`,ee=!!window.__do11yInitialized;window.__do11yInitialized=!0;let h={destination:`supabase`,supabaseUrl:``,supabaseKey:``,supabaseTable:`do11y_events`,endpoint:``,headers:{},bodyTransform:void 0,otelSdkEndpoint:``,otelSdkHeaders:{},otelSdkServiceName:`do11y`,otelSdkResourceAttributes:{},otelSdkCdnUrl:`https://esm.sh/`,debug:!1,flushInterval:5e3,maxBatchSize:10,trackOutboundLinks:!0,trackInternalLinks:!0,trackScrollDepth:!0,scrollThresholds:[25,50,75,90],allowedDomains:null,respectDNT:!0,maxRetries:2,retryDelay:1e3,rateLimitMs:100,framework:`mintlify`,trackSectionVisibility:!0,sectionVisibleThreshold:3,trackTabSwitches:!0,trackTocClicks:!0,trackExpandCollapse:!0,trackFeedback:!0,tabContainerSelector:null,tocSelector:null,feedbackSelector:null,searchSelector:null,copyButtonSelector:null,codeBlockSelector:null,navigationSelector:null,footerSelector:null,contentSelector:null,useOtelBrowserInstrumentations:!1},g={mintlify:{searchSelector:`#search-bar-entry, #search-bar-entry-mobile, [class*="search"]`,copyButtonSelector:`button[class*="copy"], button[aria-label*="copy" i]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], #navbar, #sidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`[role="tablist"], [class*="tab"]`,tocSelector:`#table-of-contents, [data-testid="table-of-contents"], [class*="table-of-contents"], [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},docusaurus:{searchSelector:`.DocSearch, .DocSearch-Button`,copyButtonSelector:`button.clean-btn[aria-label*="copy" i], button[class*="copyButton"]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .navbar, .sidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`.tabs[role="tablist"], [class*="tabs"]`,tocSelector:`.table-of-contents, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},nextra:{searchSelector:`.nextra-search input, input[placeholder*="search" i], button[aria-label*="search" i]`,copyButtonSelector:`button[class*="copy"], button[aria-label*="copy" i], button[title*="copy" i]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`[role="tablist"], [class*="tab"]`,tocSelector:`.nextra-toc, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},"mkdocs-material":{searchSelector:`.md-search__input`,copyButtonSelector:`.md-clipboard, .md-code__button[title="Copy to clipboard"]`,codeBlockSelector:`pre, code, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .md-nav, .md-sidebar`,footerSelector:`footer, [role="contentinfo"], .md-footer`,contentSelector:`main, article, [role="main"], .md-content`,tabContainerSelector:`.tabbed-labels, .md-typeset .tabbed-set`,tocSelector:`.md-sidebar--secondary .md-nav, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},vitepress:{searchSelector:`.VPNavBarSearch button, .VPNavBarSearchButton, #local-search`,copyButtonSelector:`button.copy, .vp-code-copy, button.copy[title*="Copy"]`,codeBlockSelector:`div[class*="language-"], pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .VPNav, .VPSidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], .VPFooter, [class*="footer"]`,contentSelector:`main, article, [role="main"], .VPContent, [class*="content"]`,tabContainerSelector:`.vp-code-group .tabs, [role="tablist"]`,tocSelector:`.VPDocAsideOutline, .VPLocalNavOutlineDropdown, a.outline-link`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},starlight:{searchSelector:`site-search button[data-open-modal], sl-doc-search .DocSearch-Button, button[aria-label*="search" i]`,copyButtonSelector:`.expressive-code .copy button, .copy button[data-code]`,codeBlockSelector:`.expressive-code pre, pre`,navigationSelector:`nav, [role="navigation"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, .sl-markdown-content, [role="main"]`,tabContainerSelector:`starlight-tabs [role="tablist"], [role="tablist"]`,tocSelector:`.right-sidebar-panel, starlight-toc, mobile-starlight-toc`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`}},_=[`searchSelector`,`copyButtonSelector`,`codeBlockSelector`,`navigationSelector`,`footerSelector`,`contentSelector`,`tabContainerSelector`,`tocSelector`,`feedbackSelector`];function te(){let e=g[h.framework];e?_.forEach(t=>{h[t]||(h[t]=e[t])}):h.framework!==`custom`&&h.debug&&console.warn(`[Do11y] Unknown framework "${h.framework}". Falling back to generic selectors. Supported: `+Object.keys(g).join(`, `)+`, custom`);let t=g.mintlify;t&&_.forEach(e=>{h[e]||(h[e]=t[e])})}function v(){if(h.respectDNT&&(navigator.doNotTrack===`1`||navigator.doNotTrack===`yes`||window.doNotTrack===`1`))return h.debug&&console.log(`[Do11y] Disabled: Do Not Track is enabled`),!0;if(h.allowedDomains&&h.allowedDomains.length>0){let e=window.location.hostname;if(!h.allowedDomains.some(t=>e===t||e.endsWith(`.`+t)))return h.debug&&console.log(`[Do11y] Disabled: Domain not allowed:`,e),!0}return!1}function y(e){if(!e||typeof e!=`string`)return null;try{return document.querySelector(e),e}catch{return h.debug&&console.warn(`[Do11y] Invalid CSS selector rejected:`,e),null}}function b(e){if(typeof e.className==`string`)return e.className;let t=e.className;return t&&typeof t.baseVal==`string`?t.baseVal:``}function x(e){let t=e.match(/(?:^|\s)language-([\w-]+)(?:\s|$)/);return t?t[1]:null}function ne(e){if(!e)return`unknown`;let t=e;for(let e=0;t&&e<12;e++,t=t.parentElement){for(let e of[`language`,`data-language`,`data-lang`,`data-code-lang`]){let n=t.getAttribute(e);if(n)return n}let e=x(b(t));if(e)return e;let n=t.querySelector(`:scope > span.lang`)?.textContent?.trim();if(n)return n;let r=t.querySelector(`[data-language], [data-lang], [data-code-lang], [class*="language-"], [language]`);if(r){let e=r.getAttribute(`language`)??r.getAttribute(`data-language`)??r.getAttribute(`data-lang`)??r.getAttribute(`data-code-lang`)??x(b(r));if(e)return e}}return`unknown`}function re(e){if(e.startsWith(`#`))return e;let t=e.indexOf(`#`);if(t===-1)return null;let n=e.slice(0,t);return!n||n===window.location.pathname||n===`${window.location.pathname}${window.location.search}`?e.slice(t):null}function ie(e){let t=y(h.tocSelector)??`.table-of-contents, .VPDocAsideOutline, .VPLocalNavOutlineDropdown, [class*="toc"], [class*="TableOfContents"], [class*="page-outline"], .right-sidebar-panel, starlight-toc`,n=e.closest(t);return n?((n===e||n.tagName===`A`)&&(n=e.closest(`.VPDocAsideOutline, .VPLocalNavOutlineDropdown, nav, aside, .right-sidebar-panel, starlight-toc`)??n.parentElement),n):null}function S(e,t){if(!e||typeof e!=`string`)return null;let n=t??100,r=e;return r=r.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,`[email]`),r=r.replace(/\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g,`[phone]`),r=r.replace(/\b\d{3}-\d{2}-\d{4}\b/g,`[redacted]`),r=r.replace(/\b(?:\d[ -]?){13,19}\b/g,`[card]`),r=r.replace(/eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,`[token]`),r=r.replace(/\bxa[a-z]{2}-[A-Za-z0-9_-]{20,}/g,`[token]`),r=r.replace(/\b[0-9a-fA-F]{32,}\b/g,`[redacted]`),r.trim().substring(0,n)}function ae(){if(window.crypto&&typeof window.crypto.randomUUID==`function`)return window.crypto.randomUUID();if(window.crypto&&typeof window.crypto.getRandomValues==`function`){let e=new Uint8Array(16);window.crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return t.slice(0,8)+`-`+t.slice(8,12)+`-`+t.slice(12,16)+`-`+t.slice(16,20)+`-`+t.slice(20)}return`no-crypto-00-0000-0000-000000000000`}function oe(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.startTime==`string`&&Array.isArray(t.pageSequence)&&typeof t.pageCount==`number`}function C(){let e=null;try{let t=sessionStorage.getItem(`do11y_session`);if(t){let n=JSON.parse(t);oe(n)&&(e=n)}}catch{}return e||(e={id:ae(),startTime:new Date().toISOString(),pageSequence:[],pageCount:0,referrerCategory:null,aiPlatform:null},w(e)),e}function w(e){try{sessionStorage.setItem(`do11y_session`,JSON.stringify(e))}catch{}}function T(e){let t=C();return t.pageCount++,t.pageSequence.push({path:e,timestamp:new Date().toISOString(),index:t.pageCount}),t.pageSequence.length>50&&(t.pageSequence=t.pageSequence.slice(-50)),w(t),t}function se(){return{"browser.do11y.viewport_category":ce(),"browser.family":le(),"device.type":ue(),"browser.language":(navigator.language||``).split(`-`)[0]||`unknown`,"browser.do11y.timezone_offset":new Date().getTimezoneOffset()/60}}function ce(){let e=window.innerWidth;return e<640?`mobile`:e<1024?`tablet`:e<1440?`desktop`:`large-desktop`}function le(){let e=navigator.userAgent;return e.includes(`Firefox`)?`Firefox`:e.includes(`Edg`)?`Edge`:e.includes(`Chrome`)?`Chrome`:e.includes(`Safari`)?`Safari`:`Other`}function ue(){let e=navigator.userAgent;return/Mobile|Android|iPhone|iPad/.test(e)?/iPad|Tablet/.test(e)?`tablet`:`mobile`:`desktop`}let de=[{match:`chatgpt`,platform:`ChatGPT`},{match:`chat.com`,platform:`ChatGPT`},{match:`openai`,platform:`ChatGPT`},{match:`perplexity`,platform:`Perplexity`},{match:`claude.ai`,platform:`Claude`},{match:`anthropic`,platform:`Claude`},{match:`gemini`,platform:`Gemini`},{match:`copilot`,platform:`Copilot`},{match:`deepseek`,platform:`DeepSeek`},{match:`meta.ai`,platform:`Meta AI`},{match:`grok`,platform:`Grok`},{match:`x.ai`,platform:`Grok`},{match:`mistral`,platform:`Mistral`},{match:`you.com`,platform:`You.com`},{match:`phind`,platform:`Phind`}];function fe(e){if(!e||e===`direct`)return{referrerCategory:`direct`,aiPlatform:null};if(e===`internal`)return{referrerCategory:`internal`,aiPlatform:null};if(e===`unknown`)return{referrerCategory:`unknown`,aiPlatform:null};let t=e.toLowerCase();for(let e of de)if(t.indexOf(e.match)!==-1)return{referrerCategory:`ai`,aiPlatform:e.platform};return/google\.|bing\.|baidu\.|yandex\.|duckduckgo\.|yahoo\./.test(t)?{referrerCategory:`search-engine`,aiPlatform:null}:/github\.|gitlab\.|bitbucket\./.test(t)?{referrerCategory:`code-host`,aiPlatform:null}:/stackoverflow\.|stackexchange\.|reddit\.|news\.ycombinator\./.test(t)?{referrerCategory:`community`,aiPlatform:null}:/twitter\.|x\.com|linkedin\.|facebook\.|threads\.net/.test(t)?{referrerCategory:`social`,aiPlatform:null}:{referrerCategory:`other`,aiPlatform:null}}function pe(){try{if(!document.referrer)return`direct`;let e=new URL(document.referrer);return e.hostname===window.location.hostname?`internal`:e.hostname}catch{return`unknown`}}function me(){return{"url.path":window.location.pathname,"url.fragment":window.location.hash||null,"url.query":window.location.search?`has_params`:null,"browser.do11y.page_title":S(document.title,150)}}let E=[],D=null,O={},k=!1;function A(e,t){if(k)return;let n=Date.now();if(h.rateLimitMs>0&&O[e]&&n-O[e]<h.rateLimitMs){h.debug&&console.log(`[Do11y] Rate limited:`,e);return}O[e]=n;let r=C(),i={_time:new Date().toISOString(),eventName:e,"browser.do11y.version":m,"session.id":r.id,"browser.do11y.session_page_count":r.pageCount,...me(),...se(),...t};if(h.debug&&console.log(`[Do11y] Event queued:`,e,i),h.destination===`otlp`&&j){j.emit({eventName:e,severityNumber:9,attributes:i,body:``});return}E.push(i),E.length>100&&(E=E.slice(-100),h.debug&&console.warn(`[Do11y] Event queue capped at 100 events`)),E.length>=h.maxBatchSize?F():he()}function he(){D||=setTimeout(F,h.flushInterval)}let j=null;function ge(e){try{let t=new URL(e);return!(t.protocol!==`https:`||!t.hostname.endsWith(`.supabase.co`))}catch{return!1}}function _e(e){try{let t=new URL(e);if(t.protocol!==`https:`)return!1;let n=t.hostname;return!(n===`localhost`||n===`127.0.0.1`||n===`::1`||/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/.test(n))}catch{return!1}}function M(){return h.destination===`supabase`?h.supabaseUrl?ge(h.supabaseUrl)?!h.supabaseKey||typeof h.supabaseKey!=`string`||h.supabaseKey.length<10?(h.debug&&console.warn(`[Do11y] Invalid or missing Supabase publishable key`),!1):/^[a-zA-Z0-9_-]+$/.test(h.supabaseTable)?!0:(h.debug&&console.warn(`[Do11y] Invalid table name`),!1):(h.debug&&console.warn(`[Do11y] Invalid Supabase URL. Must be https://<project>.supabase.co`),!1):(h.debug&&console.warn(`[Do11y] No Supabase URL configured`),!1):h.destination===`http`?h.endpoint?_e(h.endpoint)?!0:(h.debug&&console.warn(`[Do11y] Invalid HTTP endpoint. Must be HTTPS and not a private address.`),!1):(h.debug&&console.warn(`[Do11y] No HTTP endpoint configured`),!1):h.destination===`otlp`?h.otelSdkEndpoint?(N().catch(e=>{h.debug&&console.warn(`[Do11y] OTel SDK initialization failed:`,e)}),!0):(h.debug&&console.warn(`[Do11y] No OTLP endpoint configured`),!1):(h.debug&&console.warn(`[Do11y] Unknown destination:`,h.destination),!1)}async function N(){if(j)return;let e=h.otelSdkCdnUrl.replace(/\/+$/,``)+`/`,t=await import(`${e}@opentelemetry/api-logs`),n=await import(`${e}@opentelemetry/sdk-logs`),r=await import(`${e}@opentelemetry/exporter-logs-otlp-http`),i={"service.name":h.otelSdkServiceName||`do11y`,"service.version":m,"telemetry.sdk.name":`do11y`,"telemetry.sdk.language":`webjs`,"telemetry.sdk.version":m,...h.otelSdkResourceAttributes},a=new n.LoggerProvider({resource:{attributes:i},processors:[new n.BatchLogRecordProcessor({exporter:new r.OTLPLogExporter({url:h.otelSdkEndpoint.replace(/\/$/,``)+`/v1/logs`,headers:h.otelSdkHeaders})})]});t.logs.setGlobalLoggerProvider(a),j=a.getLogger(`do11y`),h.debug&&console.log(`[Do11y] OTel SDK initialized with endpoint:`,h.otelSdkEndpoint)}function P(e){if(h.destination===`supabase`){let t=h.supabaseUrl.replace(/\/$/,``)+`/rest/v1/`+h.supabaseTable,n=h.bodyTransform??(e=>e.map(e=>({payload:e})));return{url:t,headers:{apikey:h.supabaseKey,Authorization:`Bearer `+h.supabaseKey,"Content-Type":`application/json`,Prefer:`return=minimal`},body:JSON.stringify(n(e))}}let t=h.bodyTransform??(e=>e);return{url:h.endpoint,headers:{"Content-Type":`application/json`,...h.headers},body:JSON.stringify(t(e))}}function F(e){if(D&&=(clearTimeout(D),null),E.length===0||!M())return;let t=typeof e==`number`?e:h.maxRetries,n=E.slice();E=[],ve(P(n),n,t)}function I(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function ve(e,t,n){let r=I(e.url);h.debug&&r&&console.log(`[Do11y] Cross-origin request to`,new URL(e.url).origin,`- requires CORS headers on the server`),fetch(e.url,{method:`POST`,headers:e.headers,body:e.body,keepalive:!0,mode:r?`cors`:`same-origin`}).then(e=>{if(e.ok){h.debug&&console.log(`[Do11y] Flushed`,t.length,`events`);return}if(n>0&&(e.status>=500||e.status===429)){h.debug&&console.log(`[Do11y] Retrying after error:`,e.status),E=t.concat(E),setTimeout(()=>{F(n-1)},h.retryDelay*(h.maxRetries-n+1));return}h.debug&&e.text().then(t=>{let n=`[Do11y] Ingest failed: ${e.status}`;e.status===0&&e.type===`opaque`?console.error(n,`- CORS error: server did not return Access-Control-Allow-Origin`):console.error(n,t)}).catch(()=>{})}).catch(e=>{if(n>0){if(h.debug){let t=r?` (this may be a CORS issue — try using an OTel Collector proxy)`:``;console.log(`[Do11y] Network error, retrying:`,e.message+t)}E=t.concat(E),setTimeout(()=>{F(n-1)},h.retryDelay*(h.maxRetries-n+1))}else h.debug&&console.error(`[Do11y] Failed to send events:`,e.message)})}function ye(){if(h.destination===`otlp`||E.length===0||!M())return;let e=E;E=[];let t=P(e);try{fetch(t.url,{method:`POST`,headers:t.headers,body:t.body,keepalive:!0})}catch{}h.debug&&console.log(`[Do11y] Sync flushed`,e.length,`events`)}function L(){let n=T(window.location.pathname),r=pe(),i=fe(r);n.pageCount===1&&(n.referrerCategory=i.referrerCategory,n.aiPlatform=i.aiPlatform,w(n)),A(`browser.do11y.page_view`,{"browser.do11y.referrer_domain":r,[e]:i.referrerCategory,[t]:i.aiPlatform,"browser.do11y.is_first_page":n.pageCount===1,"browser.do11y.previous_path":n.pageSequence.length>1?n.pageSequence[n.pageSequence.length-2].path:null})}function be(){document.addEventListener(`click`,e=>{let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`);if(!n)return;let r=`other`,i=null;try{if(n.startsWith(`#`))r=`anchor`;else if(n.startsWith(`/`)||n.startsWith(`./`)||n.startsWith(`../`))r=`internal`;else if(n.startsWith(`http`)){let e=new URL(n);e.hostname===window.location.hostname?r=`internal`:(r=`external`,i=e.hostname)}else n.startsWith(`mailto:`)&&(r=`email`)}catch{}r===`internal`&&!h.trackInternalLinks||r===`external`&&!h.trackOutboundLinks||(A(`browser.do11y.link_click`,{"browser.do11y.link.type":r,"browser.do11y.link.target_url":n,"browser.do11y.link.target_domain":i,"browser.do11y.link.text":S(t.textContent,100),"browser.do11y.link.context":xe(t),"browser.do11y.link.section":S(R(t),100),"browser.do11y.link.index":Se(t,n)}),F())},!0)}function xe(e){return e.closest(h.navigationSelector)?`navigation`:e.closest(h.footerSelector)?`footer`:e.closest(h.contentSelector)?`content`:`other`}function R(e){let t=e;for(;t&&t!==document.body;){let e=t.previousElementSibling;for(;e;){if(/^H[1-6]$/.test(e.tagName))return e.textContent?.trim().substring(0,100)??null;let t=e.querySelectorAll(`h1, h2, h3, h4, h5, h6`);if(t.length>0)return t[t.length-1].textContent?.trim().substring(0,100)??null;e=e.previousElementSibling}t=t.parentElement}return null}function Se(e,t){if(typeof CSS>`u`||typeof CSS.escape!=`function`)return 1;try{let n=document.querySelectorAll(`a[href="`+CSS.escape(t)+`"]`);for(let t=0;t<n.length;t++)if(n[t]===e)return t+1}catch{}return 1}let z=new Set,B=null;function Ce(e){let t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let e=window.getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function we(){if(!h.trackScrollDepth)return;if(h.contentSelector){let e=document.querySelector(h.contentSelector);e&&(B=Ce(e))}let e=!1;function t(){e||=(window.requestAnimationFrame(()=>{V(),e=!1}),!0)}if(window.addEventListener(`scroll`,t),B&&(B.addEventListener(`scroll`,t),h.debug)){let e=B;console.log(`[do11y] Using container-based scroll tracking:`,e.className||e.tagName)}V()}function V(){let e,t,i;B&&B.scrollHeight>B.clientHeight?(e=B.scrollTop,t=B.scrollHeight,i=B.clientHeight):(e=window.scrollY||document.documentElement.scrollTop,t=document.documentElement.scrollHeight,i=window.innerHeight);let a=t-i;if(a<=0){h.scrollThresholds.forEach(e=>{z.has(e)||(z.add(e),A(u,{[n]:e,[r]:100}))});return}let o=Math.round(e/a*100);h.scrollThresholds.forEach(e=>{o>=e&&!z.has(e)&&(z.add(e),A(u,{[n]:e,[r]:o}))})}let H=Date.now(),U=Date.now(),W=0,G=!0;function K(){G&&(W+=Date.now()-U);let n=Date.now()-H,r=n>0?W/n:0,i=0;z.forEach(e=>{e>i&&(i=e)}),X();let a=C();A(`browser.do11y.page_exit`,{"browser.do11y.page_exit.total_time_seconds":Math.round(n/1e3),"browser.do11y.page_exit.active_time_seconds":Math.round(W/1e3),"browser.do11y.page_exit.engagement_ratio":Math.round(r*100)/100,"browser.do11y.page_exit.max_scroll_depth":i,[e]:a.referrerCategory,[t]:a.aiPlatform})}function Te(){document.addEventListener(`visibilitychange`,()=>{document.hidden?G&&=(W+=Date.now()-U,!1):(U=Date.now(),G=!0)}),window.addEventListener(`beforeunload`,()=>{K(),Ne()})}function Ee(){document.addEventListener(`click`,e=>{e.target.closest(h.searchSelector)&&A(d,{})},!0),document.addEventListener(`keydown`,e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&A(d,{"browser.do11y.search.trigger":`keyboard`})})}function De(e){if(!e)return 1;try{let t=document.querySelectorAll(h.codeBlockSelector);for(let n=0;n<t.length;n++)if(t[n]===e)return n+1}catch{}return 1}function Oe(){document.addEventListener(`click`,e=>{let t=e.target.closest(h.copyButtonSelector);if(t){let e=t.closest(`[class*="language-"], [language]`)??t.closest(h.codeBlockSelector)??t.closest(`.expressive-code`)?.querySelector(`pre`)??t.closest(`div, section`)?.querySelector(`pre`)??t.parentElement?.querySelector(`pre`)??null,n=ne((e?e.tagName===`PRE`?e.querySelector(`code`):e.querySelector(`code[class*="language-"], code[language]`)??e.querySelector(`code`):null)??e??t);A(`browser.do11y.code_copied`,{"browser.do11y.code.language":n,"browser.do11y.code.section":S(R(e??t),100),"browser.do11y.code.index":De(e)})}},!0)}let q=null,J={};function ke(){if(!h.trackSectionVisibility||typeof IntersectionObserver>`u`)return;let e=h.sectionVisibleThreshold*1e3;q=new IntersectionObserver(t=>{t.forEach(t=>{let n=t.target.getAttribute(`data-do11y-section-id`);if(n)if(t.isIntersecting)J[n]||(J[n]={start:Date.now(),reported:!1});else{if(J[n]&&!J[n].reported){let r=Date.now()-J[n].start;if(r>=e){let e=t.target.textContent?.trim()??``;A(f,{[i]:S(e,100),[a]:parseInt(t.target.tagName.charAt(1),10),[o]:Math.round(r/1e3)}),J[n].reported=!0}}delete J[n]}})},{threshold:.5}),Y()}function Y(){q&&document.querySelectorAll(`h2, h3`).forEach((e,t)=>{e.setAttribute(`data-do11y-section-id`,`section-`+t),q.observe(e)})}function X(){if(!q)return;let e=Date.now(),t=h.sectionVisibleThreshold*1e3;Object.keys(J).forEach(n=>{let r=J[n];if(r&&!r.reported){let s=e-r.start;if(s>=t){let e=typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(n):n.replace(/["\\]/g,`\\$&`),t=document.querySelector(`[data-do11y-section-id="`+e+`"]`);t&&A(f,{[i]:S(t.textContent?.trim()??``,100),[a]:parseInt(t.tagName.charAt(1),10),[o]:Math.round(s/1e3)})}}}),J={}}function Ae(){h.trackTabSwitches&&document.addEventListener(`click`,e=>{let t=`[role="tab"], .tabs button, .tabs a, .tabbed-labels label`,n=y(h.tabContainerSelector);n&&(t+=`, `+n+` button, `+n+` a, `+n+` label`);let r=e.target.closest(t);if(!r||r.getAttribute(`aria-selected`)===`true`||r.classList.contains(`active`)||r.classList.contains(`is-active`))return;let i=S(r.textContent,50);if(!i)return;let a=S(R(r),100);A(`browser.do11y.tab_switch`,{"browser.do11y.tab.label":i,"browser.do11y.tab.group":a,"browser.do11y.tab.is_default":!1})})}function je(){h.trackTocClicks&&document.addEventListener(`click`,e=>{let t=e.target.closest(`a`);if(!t)return;let n=ie(t);if(!n)return;let r=t.getAttribute(`href`),i=r?re(r):null;if(!i)return;let a=S(t.textContent,100),o=null;try{let e=i.slice(1),t=document.getElementById(e);t&&/^H[1-6]$/.test(t.tagName)&&(o=parseInt(t.tagName.charAt(1),10))}catch{}let s=n.querySelectorAll(`a[href*="#"]`),c=1;for(let e=0;e<s.length;e++)if(s[e]===t){c=e+1;break}A(`browser.do11y.toc_click`,{"browser.do11y.toc.heading":a,"browser.do11y.toc.heading_level":o,"browser.do11y.toc.position":c})},!0)}function Me(){h.trackFeedback&&document.addEventListener(`click`,e=>{let t=e.target.closest(`button, [role="button"], a`);if(!t||!t.closest(y(h.feedbackSelector)??`[class*="feedback"], [class*="helpful"], [class*="rating"], [class*="was-this"], [data-feedback]`))return;let n=(t.textContent??``).trim().toLowerCase(),r=(t.getAttribute(`aria-label`)??``).toLowerCase(),i=(t.getAttribute(`title`)??``).toLowerCase(),a=t.getAttribute(`data-value`)??t.getAttribute(`data-md-value`)??t.getAttribute(`data-feedback`),o=a&&/^[\w\s.,!?-]{1,50}$/.test(a)?a:null,s=null;o?s=o:/\byes\b|👍|thumbs.?up|helpful/i.test(n+` `+r+` `+i)?s=`yes`:/\bno\b|👎|thumbs.?down|not.?helpful/i.test(n+` `+r+` `+i)&&(s=`no`),s&&A(`browser.do11y.feedback`,{"browser.do11y.feedback.rating":s})})}function Z(){h.trackExpandCollapse&&(document.addEventListener(`toggle`,e=>{let t=e.target;if(t.tagName!==`DETAILS`)return;let n=t.querySelector(`summary`),r=S(n?n.textContent:``,100);A(p,{[s]:r,[c]:t.open?`expand`:`collapse`,[l]:S(R(t),100)})},!0),document.addEventListener(`click`,e=>{let t=e.target.closest(`[aria-expanded], [class*="accordion"] button, [class*="collapsible"] button`);if(!t||t.closest(`details`)||t.closest(`nav, [role="navigation"], header`))return;let n=t.getAttribute(`aria-expanded`)===`true`;A(p,{[s]:S(t.textContent,100),[c]:n?`collapse`:`expand`,[l]:S(R(t),100)})}))}let Q=null;function $(){if(window.Do11yConfig&&typeof window.Do11yConfig==`object`)for(let e in window.Do11yConfig)Object.prototype.hasOwnProperty.call(window.Do11yConfig,e)&&Object.prototype.hasOwnProperty.call(h,e)&&(h[e]=window.Do11yConfig[e]);let e=document.querySelector(`meta[name="do11y-destination"]`);if(e){let t=e.getAttribute(`content`);(t===`supabase`||t===`http`||t===`otlp`)&&(h.destination=t)}let t=document.querySelector(`meta[name="do11y-url"]`);t&&(h.supabaseUrl=t.getAttribute(`content`)??h.supabaseUrl);let n=document.querySelector(`meta[name="do11y-key"]`);n&&(h.supabaseKey=n.getAttribute(`content`)??h.supabaseKey);let r=document.querySelector(`meta[name="do11y-table"]`);r&&(h.supabaseTable=r.getAttribute(`content`)??h.supabaseTable);let i=document.querySelector(`meta[name="do11y-endpoint"]`);i&&(h.endpoint=i.getAttribute(`content`)??h.endpoint);let a=document.querySelector(`meta[name="do11y-otlp-endpoint"]`);a&&(h.otelSdkEndpoint=a.getAttribute(`content`)??h.otelSdkEndpoint);let o=document.querySelector(`meta[name="do11y-otlp-headers"]`);if(o)try{let e=JSON.parse(o.getAttribute(`content`)??`{}`);typeof e==`object`&&e&&(h.otelSdkHeaders=e)}catch{}let s=document.querySelector(`meta[name="do11y-debug"]`);s&&s.getAttribute(`content`)===`true`&&(h.debug=!0);let c=document.querySelector(`meta[name="do11y-domains"]`);if(c){let e=c.getAttribute(`content`);e&&(h.allowedDomains=e.split(`,`).map(e=>e.trim()))}let l=document.querySelector(`meta[name="do11y-framework"]`);l&&(h.framework=l.getAttribute(`content`)??h.framework);let u=document.querySelector(`meta[name="do11y-use-otel-instrumentations"]`);if(u&&u.getAttribute(`content`)===`true`&&(h.useOtelBrowserInstrumentations=!0),te(),h.debug){let e=h.destination===`supabase`?!!h.supabaseKey:h.destination===`otlp`?!!h.otelSdkEndpoint:!!h.endpoint;console.log(`[Do11y] Initializing with config:`,{destination:h.destination,hasCredentials:e,framework:h.framework,allowedDomains:h.allowedDomains,respectDNT:h.respectDNT})}if(v()){k=!0,h.debug&&console.log(`[Do11y] Tracking disabled`);return}(h.destination===`supabase`?h.supabaseKey:h.destination===`otlp`?h.otelSdkEndpoint:h.endpoint)||h.debug&&(console.warn(`[Do11y] No destination configured. Events will not be sent.`),h.destination===`supabase`?console.warn(`[Do11y] Add <meta name="do11y-url"> and <meta name="do11y-key"> to enable.`):h.destination===`otlp`?console.warn(`[Do11y] Add <meta name="do11y-otlp-endpoint"> to enable.`):console.warn(`[Do11y] Add <meta name="do11y-endpoint"> to enable.`)),L(),be(),we(),Te(),Ee(),Oe(),ke(),Ae(),je(),Me(),Z();let d=window.location.pathname;Q=new MutationObserver(()=>{window.location.pathname!==d&&(d=window.location.pathname,K(),z=new Set,H=Date.now(),U=Date.now(),W=0,G=!0,L(),Y(),V())}),Q.observe(document.body,{childList:!0,subtree:!0}),window.addEventListener(`popstate`,()=>{window.location.pathname!==d&&(d=window.location.pathname,K(),z=new Set,H=Date.now(),U=Date.now(),W=0,G=!0,L(),Y(),V())}),Object.freeze(h),h.debug&&console.log(`[Do11y] Initialized successfully`)}function Ne(){Q&&=(Q.disconnect(),null),q&&=(X(),q.disconnect(),null),D&&=(clearTimeout(D),null),ye()}ee||(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,$):$()),window.Do11y=window.Do11y??{getConfig:()=>({destination:h.destination,hasCredentials:h.destination===`supabase`?!!h.supabaseKey:h.destination===`otlp`?!!h.otelSdkEndpoint:!!h.endpoint,isDisabled:k,allowedDomains:h.allowedDomains,respectDNT:h.respectDNT}),flush:F,isEnabled:()=>k?!1:h.destination===`supabase`?!!h.supabaseKey:h.destination===`otlp`?!!h.otelSdkEndpoint:!!h.endpoint,getQueueSize:()=>E.length,version:m}})();
1
+ (function(){let e=`browser.do11y.referrer_category`,t=`browser.do11y.ai_platform`,n=`browser.do11y.scroll.threshold`,r=`browser.do11y.scroll.percent`,i=`browser.do11y.section.heading`,a=`browser.do11y.section.heading_level`,o=`browser.do11y.section.visible_seconds`,s=`browser.do11y.expand.summary`,c=`browser.do11y.expand.action`,l=`browser.do11y.expand.section`,u=`browser.do11y.scroll_depth`,d=`browser.do11y.search_opened`,f=`browser.do11y.section_visible`,p=`browser.do11y.expand_collapse`,m=`0.1.2`,h=!!window.__do11yInitialized;window.__do11yInitialized=!0;let g=window.self!==window.top;g&&!h&&(window.__do11yInitialized=!1);let _={destination:`supabase`,supabaseUrl:``,supabaseKey:``,supabaseTable:`do11y_events`,endpoint:``,headers:{},bodyTransform:void 0,otelSdkEndpoint:``,otelSdkHeaders:{},otelSdkServiceName:`do11y`,otelSdkResourceAttributes:{},otelSdkCdnUrl:`https://esm.sh/`,debug:!1,flushInterval:5e3,maxBatchSize:10,trackOutboundLinks:!0,trackInternalLinks:!0,trackScrollDepth:!0,scrollThresholds:[25,50,75,90],allowedDomains:null,respectDNT:!0,maxRetries:2,retryDelay:1e3,rateLimitMs:100,framework:`mintlify`,trackSectionVisibility:!0,sectionVisibleThreshold:3,trackTabSwitches:!0,trackTocClicks:!0,trackExpandCollapse:!0,trackFeedback:!0,tabContainerSelector:null,tocSelector:null,feedbackSelector:null,searchSelector:null,copyButtonSelector:null,codeBlockSelector:null,navigationSelector:null,footerSelector:null,contentSelector:null,useOtelBrowserInstrumentations:!1,testRunId:void 0,testFramework:void 0},v={mintlify:{searchSelector:`#search-bar-entry, #search-bar-entry-mobile, [class*="search"]`,copyButtonSelector:`button[class*="copy"], button[aria-label*="copy" i]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], #navbar, #sidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`tabs, [role="tablist"], [class*="tab"]`,tocSelector:`#table-of-contents, [data-testid="table-of-contents"], [class*="table-of-contents"], [class*="toc"]`,feedbackSelector:`feedback-toolbar, #feedback-thumbs-up, #feedback-thumbs-down, [class*="feedback"], [class*="helpful"]`},docusaurus:{searchSelector:`.DocSearch, .DocSearch-Button`,copyButtonSelector:`button.clean-btn[aria-label*="copy" i], button[class*="copyButton"]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .navbar, .sidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`.tabs[role="tablist"], [class*="tabs"]`,tocSelector:`.table-of-contents, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},nextra:{searchSelector:`.nextra-search input, input[placeholder*="search" i], button[aria-label*="search" i]`,copyButtonSelector:`button[class*="copy"], button[aria-label*="copy" i], button[title*="copy" i]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`[role="tablist"], [class*="tab"]`,tocSelector:`.nextra-toc, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},"mkdocs-material":{searchSelector:`.md-search__input`,copyButtonSelector:`.md-clipboard, .md-code__button[title="Copy to clipboard"]`,codeBlockSelector:`pre, code, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .md-nav, .md-sidebar`,footerSelector:`footer, [role="contentinfo"], .md-footer`,contentSelector:`main, article, [role="main"], .md-content`,tabContainerSelector:`.tabbed-labels, .md-typeset .tabbed-set`,tocSelector:`.md-sidebar--secondary .md-nav, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},vitepress:{searchSelector:`.VPNavBarSearch button, .VPNavBarSearchButton, #local-search`,copyButtonSelector:`button.copy, .vp-code-copy, button.copy[title*="Copy"]`,codeBlockSelector:`div[class*="language-"], pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .VPNav, .VPSidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], .VPFooter, [class*="footer"]`,contentSelector:`main, article, [role="main"], .VPContent, [class*="content"]`,tabContainerSelector:`.vp-code-group .tabs, [role="tablist"]`,tocSelector:`.VPDocAsideOutline, .VPLocalNavOutlineDropdown, a.outline-link`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},starlight:{searchSelector:`site-search button[data-open-modal], sl-doc-search .DocSearch-Button, button[aria-label*="search" i]`,copyButtonSelector:`.expressive-code .copy button, .copy button[data-code]`,codeBlockSelector:`.expressive-code pre, pre`,navigationSelector:`nav, [role="navigation"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, .sl-markdown-content, [role="main"]`,tabContainerSelector:`starlight-tabs [role="tablist"], [role="tablist"]`,tocSelector:`.right-sidebar-panel, starlight-toc, mobile-starlight-toc`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},docsy:{searchSelector:`.td-search input, .td-search__input, #docsearch-0, #docsearch-1`,copyButtonSelector:`button[aria-label*="copy" i], button[title*="copy" i], .td-click-to-copy`,codeBlockSelector:`.highlight, pre.chroma, pre`,navigationSelector:`nav, [role="navigation"], .td-sidebar, .td-navbar, [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], .td-footer, [class*="footer"]`,contentSelector:`main, article, [role="main"], .td-content, [class*="content"]`,tabContainerSelector:`.nav-tabs[role="tablist"], [role="tablist"], .tab-content`,tocSelector:`.td-toc, nav[id="TableOfContents"], [class*="toc"]`,feedbackSelector:`.feedback--answer, [class*="feedback"], [class*="helpful"]`}},y=[`searchSelector`,`copyButtonSelector`,`codeBlockSelector`,`navigationSelector`,`footerSelector`,`contentSelector`,`tabContainerSelector`,`tocSelector`,`feedbackSelector`];function ee(){let e=v[_.framework];e?y.forEach(t=>{_[t]||(_[t]=e[t])}):_.framework!==`custom`&&_.debug&&console.warn(`[Do11y] Unknown framework "${_.framework}". Falling back to generic selectors. Supported: `+Object.keys(v).join(`, `)+`, custom`);let t=v.mintlify;t&&y.forEach(e=>{_[e]||(_[e]=t[e])})}function te(){if(_.respectDNT&&(navigator.doNotTrack===`1`||navigator.doNotTrack===`yes`||window.doNotTrack===`1`))return _.debug&&console.log(`[Do11y] Disabled: Do Not Track is enabled`),!0;if(_.allowedDomains&&_.allowedDomains.length>0){let e=window.location.hostname;if(!_.allowedDomains.some(t=>e===t||e.endsWith(`.`+t)))return _.debug&&console.log(`[Do11y] Disabled: Domain not allowed:`,e),!0}return!1}function b(e){if(!e||typeof e!=`string`)return null;try{return document.querySelector(e),e}catch{return _.debug&&console.warn(`[Do11y] Invalid CSS selector rejected:`,e),null}}function x(e){if(typeof e.className==`string`)return e.className;let t=e.className;return t&&typeof t.baseVal==`string`?t.baseVal:``}function S(e){let t=e.match(/(?:^|\s)language-([\w-]+)(?:\s|$)/);return t?t[1]:null}function C(e){if(!e)return`unknown`;let t=e;for(let e=0;t&&e<12;e++,t=t.parentElement){for(let e of[`language`,`data-language`,`data-lang`,`data-code-lang`]){let n=t.getAttribute(e);if(n)return n}let e=S(x(t));if(e)return e;let n=t.querySelector(`:scope > span.lang`)?.textContent?.trim();if(n)return n;let r=t.querySelector(`[data-language], [data-lang], [data-code-lang], [class*="language-"], [language]`);if(r){let e=r.getAttribute(`language`)??r.getAttribute(`data-language`)??r.getAttribute(`data-lang`)??r.getAttribute(`data-code-lang`)??S(x(r));if(e)return e}}return`unknown`}function ne(e){if(e.startsWith(`#`))return e;let t=e.indexOf(`#`);if(t===-1)return null;let n=e.slice(0,t);return!n||n===window.location.pathname||n===`${window.location.pathname}${window.location.search}`?e.slice(t):null}function re(e){let t=b(_.tocSelector)??`.table-of-contents, .VPDocAsideOutline, .VPLocalNavOutlineDropdown, [class*="toc"], [class*="TableOfContents"], [class*="page-outline"], .right-sidebar-panel, starlight-toc`,n=e.closest(t);return n?((n===e||n.tagName===`A`)&&(n=e.closest(`.VPDocAsideOutline, .VPLocalNavOutlineDropdown, nav, aside, .right-sidebar-panel, starlight-toc`)??n.parentElement),n):null}function w(e,t){if(!e||typeof e!=`string`)return null;let n=t??100,r=e;return r=r.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,`[email]`),r=r.replace(/\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g,`[phone]`),r=r.replace(/\b\d{3}-\d{2}-\d{4}\b/g,`[redacted]`),r=r.replace(/\b(?:\d[ -]?){13,19}\b/g,`[card]`),r=r.replace(/eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,`[token]`),r=r.replace(/\bxa[a-z]{2}-[A-Za-z0-9_-]{20,}/g,`[token]`),r=r.replace(/\b[0-9a-fA-F]{32,}\b/g,`[redacted]`),r.trim().substring(0,n)}function ie(){if(window.crypto&&typeof window.crypto.randomUUID==`function`)return window.crypto.randomUUID();if(window.crypto&&typeof window.crypto.getRandomValues==`function`){let e=new Uint8Array(16);window.crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return t.slice(0,8)+`-`+t.slice(8,12)+`-`+t.slice(12,16)+`-`+t.slice(16,20)+`-`+t.slice(20)}return`no-crypto-00-0000-0000-000000000000`}function ae(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.startTime==`string`&&Array.isArray(t.pageSequence)&&typeof t.pageCount==`number`}function T(){let e=null;try{let t=sessionStorage.getItem(`do11y_session`);if(t){let n=JSON.parse(t);ae(n)&&(e=n)}}catch{}return e||(e={id:ie(),startTime:new Date().toISOString(),pageSequence:[],pageCount:0,referrerCategory:null,aiPlatform:null},E(e)),e}function E(e){try{sessionStorage.setItem(`do11y_session`,JSON.stringify(e))}catch{}}function oe(e){let t=T();return t.pageCount++,t.pageSequence.push({path:e,timestamp:new Date().toISOString(),index:t.pageCount}),t.pageSequence.length>50&&(t.pageSequence=t.pageSequence.slice(-50)),E(t),t}function se(){return{"browser.do11y.viewport_category":ce(),"browser.family":le(),"device.type":ue(),"browser.language":(navigator.language||``).split(`-`)[0]||`unknown`,"browser.do11y.timezone_offset":new Date().getTimezoneOffset()/60}}function ce(){let e=window.innerWidth;return e<640?`mobile`:e<1024?`tablet`:e<1440?`desktop`:`large-desktop`}function le(){let e=navigator.userAgent;return e.includes(`Firefox`)?`Firefox`:e.includes(`Edg`)?`Edge`:e.includes(`Chrome`)?`Chrome`:e.includes(`Safari`)?`Safari`:`Other`}function ue(){let e=navigator.userAgent;return/Mobile|Android|iPhone|iPad/.test(e)?/iPad|Tablet/.test(e)?`tablet`:`mobile`:`desktop`}let de=[{match:`chatgpt`,platform:`ChatGPT`},{match:`chat.com`,platform:`ChatGPT`},{match:`openai`,platform:`ChatGPT`},{match:`perplexity`,platform:`Perplexity`},{match:`claude.ai`,platform:`Claude`},{match:`anthropic`,platform:`Claude`},{match:`gemini`,platform:`Gemini`},{match:`copilot`,platform:`Copilot`},{match:`deepseek`,platform:`DeepSeek`},{match:`meta.ai`,platform:`Meta AI`},{match:`grok`,platform:`Grok`},{match:`x.ai`,platform:`Grok`},{match:`mistral`,platform:`Mistral`},{match:`you.com`,platform:`You.com`},{match:`phind`,platform:`Phind`}];function fe(e){if(!e||e===`direct`)return{referrerCategory:`direct`,aiPlatform:null};if(e===`internal`)return{referrerCategory:`internal`,aiPlatform:null};if(e===`unknown`)return{referrerCategory:`unknown`,aiPlatform:null};let t=e.toLowerCase();for(let e of de)if(t.indexOf(e.match)!==-1)return{referrerCategory:`ai`,aiPlatform:e.platform};return/google\.|bing\.|baidu\.|yandex\.|duckduckgo\.|yahoo\./.test(t)?{referrerCategory:`search-engine`,aiPlatform:null}:/github\.|gitlab\.|bitbucket\./.test(t)?{referrerCategory:`code-host`,aiPlatform:null}:/stackoverflow\.|stackexchange\.|reddit\.|news\.ycombinator\./.test(t)?{referrerCategory:`community`,aiPlatform:null}:/twitter\.|x\.com|linkedin\.|facebook\.|threads\.net/.test(t)?{referrerCategory:`social`,aiPlatform:null}:{referrerCategory:`other`,aiPlatform:null}}function pe(){try{if(!document.referrer)return`direct`;let e=new URL(document.referrer);return e.hostname===window.location.hostname?`internal`:e.hostname}catch{return`unknown`}}function me(){return{"url.path":window.location.pathname,"url.fragment":window.location.hash||null,"url.query":window.location.search?`has_params`:null,"browser.do11y.page_title":w(document.title,150)}}let D=[],O=null,k={},A=!1;function j(e,t){if(A)return;let n=Date.now();if(_.rateLimitMs>0&&k[e]&&n-k[e]<_.rateLimitMs){_.debug&&console.log(`[Do11y] Rate limited:`,e);return}k[e]=n;let r=T(),i={_time:new Date().toISOString(),eventName:e,"browser.do11y.version":m,"session.id":r.id,"browser.do11y.session_page_count":r.pageCount,...me(),...se(),...t};if(_.testRunId&&(i._testRunId=_.testRunId),_.testFramework&&(i._testFramework=_.testFramework),_.debug&&console.log(`[Do11y] Event queued:`,e,i),_.destination===`otlp`&&M){M.emit({eventName:e,severityNumber:9,attributes:i,body:``});return}D.push(i),D.length>100&&(D=D.slice(-100),_.debug&&console.warn(`[Do11y] Event queue capped at 100 events`)),D.length>=_.maxBatchSize?F():he()}function he(){O||=setTimeout(F,_.flushInterval)}let M=null;function ge(e){try{let t=new URL(e);return!(t.protocol!==`https:`||!t.hostname.endsWith(`.supabase.co`))}catch{return!1}}function _e(e){try{let t=new URL(e);if(t.protocol!==`https:`)return!1;let n=t.hostname;return!(n===`localhost`||n===`127.0.0.1`||n===`::1`||/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/.test(n))}catch{return!1}}function N(){return _.destination===`supabase`?_.supabaseUrl?ge(_.supabaseUrl)?!_.supabaseKey||typeof _.supabaseKey!=`string`||_.supabaseKey.length<10?(_.debug&&console.warn(`[Do11y] Invalid or missing Supabase publishable key`),!1):/^[a-zA-Z0-9_-]+$/.test(_.supabaseTable)?!0:(_.debug&&console.warn(`[Do11y] Invalid table name`),!1):(_.debug&&console.warn(`[Do11y] Invalid Supabase URL. Must be https://<project>.supabase.co`),!1):(_.debug&&console.warn(`[Do11y] No Supabase URL configured`),!1):_.destination===`http`?_.endpoint?_e(_.endpoint)?!0:(_.debug&&console.warn(`[Do11y] Invalid HTTP endpoint. Must be HTTPS and not a private address.`),!1):(_.debug&&console.warn(`[Do11y] No HTTP endpoint configured`),!1):_.destination===`otlp`?_.otelSdkEndpoint?(ve().catch(e=>{_.debug&&console.warn(`[Do11y] OTel SDK initialization failed:`,e)}),!0):(_.debug&&console.warn(`[Do11y] No OTLP endpoint configured`),!1):(_.debug&&console.warn(`[Do11y] Unknown destination:`,_.destination),!1)}async function ve(){if(M)return;let e=_.otelSdkCdnUrl.replace(/\/+$/,``)+`/`,t=await import(`${e}@opentelemetry/api-logs`),n=await import(`${e}@opentelemetry/sdk-logs`),r=await import(`${e}@opentelemetry/exporter-logs-otlp-http`),i={"service.name":_.otelSdkServiceName||`do11y`,"service.version":m,"telemetry.sdk.name":`do11y`,"telemetry.sdk.language":`webjs`,"telemetry.sdk.version":m,..._.otelSdkResourceAttributes},a=new n.LoggerProvider({resource:{attributes:i},processors:[new n.BatchLogRecordProcessor({exporter:new r.OTLPLogExporter({url:_.otelSdkEndpoint.replace(/\/$/,``)+`/v1/logs`,headers:_.otelSdkHeaders})})]});t.logs.setGlobalLoggerProvider(a),M=a.getLogger(`do11y`),_.debug&&console.log(`[Do11y] OTel SDK initialized with endpoint:`,_.otelSdkEndpoint)}function P(e){if(_.destination===`supabase`){let t=_.supabaseUrl.replace(/\/$/,``)+`/rest/v1/`+_.supabaseTable,n=_.bodyTransform??(e=>e.map(e=>({payload:e})));return{url:t,headers:{apikey:_.supabaseKey,Authorization:`Bearer `+_.supabaseKey,"Content-Type":`application/json`,Prefer:`return=minimal`},body:JSON.stringify(n(e))}}let t=_.bodyTransform??(e=>e);return{url:_.endpoint,headers:{"Content-Type":`application/json`,..._.headers},body:JSON.stringify(t(e))}}function F(e){if(O&&=(clearTimeout(O),null),D.length===0||!N())return;let t=typeof e==`number`?e:_.maxRetries,n=D.slice();D=[],be(P(n),n,t)}function ye(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function be(e,t,n){let r=ye(e.url);_.debug&&r&&console.log(`[Do11y] Cross-origin request to`,new URL(e.url).origin,`- requires CORS headers on the server`),fetch(e.url,{method:`POST`,headers:e.headers,body:e.body,keepalive:!0,mode:r?`cors`:`same-origin`}).then(e=>{if(e.ok){_.debug&&console.log(`[Do11y] Flushed`,t.length,`events`);return}if(n>0&&(e.status>=500||e.status===429)){_.debug&&console.log(`[Do11y] Retrying after error:`,e.status),D=t.concat(D),setTimeout(()=>{F(n-1)},_.retryDelay*(_.maxRetries-n+1));return}_.debug&&e.text().then(t=>{let n=`[Do11y] Ingest failed: ${e.status}`;e.status===0&&e.type===`opaque`?console.error(n,`- CORS error: server did not return Access-Control-Allow-Origin`):console.error(n,t)}).catch(()=>{})}).catch(e=>{if(n>0){if(_.debug){let t=r?` (this may be a CORS issue — try using an OTel Collector proxy)`:``;console.log(`[Do11y] Network error, retrying:`,e.message+t)}D=t.concat(D),setTimeout(()=>{F(n-1)},_.retryDelay*(_.maxRetries-n+1))}else _.debug&&console.error(`[Do11y] Failed to send events:`,e.message)})}function xe(){if(_.destination===`otlp`||D.length===0||!N())return;let e=D;D=[];let t=P(e);try{fetch(t.url,{method:`POST`,headers:t.headers,body:t.body,keepalive:!0})}catch{}_.debug&&console.log(`[Do11y] Sync flushed`,e.length,`events`)}function I(){G=!1;let n=oe(window.location.pathname),r=pe(),i=fe(r);n.pageCount===1&&(n.referrerCategory=i.referrerCategory,n.aiPlatform=i.aiPlatform,E(n)),j(`browser.do11y.page_view`,{"browser.do11y.referrer_domain":r,[e]:i.referrerCategory,[t]:i.aiPlatform,"browser.do11y.is_first_page":n.pageCount===1,"browser.do11y.previous_path":n.pageSequence.length>1?n.pageSequence[n.pageSequence.length-2].path:null})}function Se(){document.addEventListener(`click`,e=>{let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`);if(!n)return;let r=`other`,i=null;try{if(n.startsWith(`#`))r=`anchor`;else if(n.startsWith(`/`)||n.startsWith(`./`)||n.startsWith(`../`))r=`internal`;else if(n.startsWith(`http`)){let e=new URL(n);e.hostname===window.location.hostname?r=`internal`:(r=`external`,i=e.hostname)}else n.startsWith(`mailto:`)&&(r=`email`)}catch{}r===`internal`&&!_.trackInternalLinks||r===`external`&&!_.trackOutboundLinks||(j(`browser.do11y.link_click`,{"browser.do11y.link.type":r,"browser.do11y.link.target_url":n,"browser.do11y.link.target_domain":i,"browser.do11y.link.text":w(t.textContent,100),"browser.do11y.link.context":Ce(t),"browser.do11y.link.section":w(L(t),100),"browser.do11y.link.index":we(t,n)}),F())},!0)}function Ce(e){return e.closest(_.navigationSelector)?`navigation`:e.closest(_.footerSelector)?`footer`:e.closest(_.contentSelector)?`content`:`other`}function L(e){let t=e;for(;t&&t!==document.body;){let e=t.previousElementSibling;for(;e;){if(/^H[1-6]$/.test(e.tagName))return e.textContent?.trim().substring(0,100)??null;let t=e.querySelectorAll(`h1, h2, h3, h4, h5, h6`);if(t.length>0)return t[t.length-1].textContent?.trim().substring(0,100)??null;e=e.previousElementSibling}t=t.parentElement}return null}function we(e,t){if(typeof CSS>`u`||typeof CSS.escape!=`function`)return 1;try{let n=document.querySelectorAll(`a[href="`+CSS.escape(t)+`"]`);for(let t=0;t<n.length;t++)if(n[t]===e)return t+1}catch{}return 1}let R=new Set,z=null;function Te(e){let t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let e=window.getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function Ee(){if(!_.trackScrollDepth)return;if(_.contentSelector){let e=document.querySelector(_.contentSelector);e&&(z=Te(e))}let e=!1;function t(){e||=(window.requestAnimationFrame(()=>{B(),e=!1}),!0)}if(window.addEventListener(`scroll`,t),z&&(z.addEventListener(`scroll`,t),_.debug)){let e=z;console.log(`[do11y] Using container-based scroll tracking:`,e.className||e.tagName)}B()}function B(){let e,t,i;z&&z.scrollHeight>z.clientHeight?(e=z.scrollTop,t=z.scrollHeight,i=z.clientHeight):(e=window.scrollY||document.documentElement.scrollTop,t=document.documentElement.scrollHeight,i=window.innerHeight);let a=t-i;if(a<=0){_.scrollThresholds.forEach(e=>{R.has(e)||(R.add(e),j(u,{[n]:e,[r]:100}))});return}let o=Math.round(e/a*100);_.scrollThresholds.forEach(e=>{o>=e&&!R.has(e)&&(R.add(e),j(u,{[n]:e,[r]:o}))})}let V=Date.now(),H=Date.now(),U=0,W=!0,G=!1;function K(){if(G)return;G=!0,W&&(U+=Date.now()-H);let n=Date.now()-V,r=n>0?U/n:0,i=0;R.forEach(e=>{e>i&&(i=e)}),X();let a=T();j(`browser.do11y.page_exit`,{"browser.do11y.page_exit.total_time_seconds":Math.round(n/1e3),"browser.do11y.page_exit.active_time_seconds":Math.round(U/1e3),"browser.do11y.page_exit.engagement_ratio":Math.round(r*100)/100,"browser.do11y.page_exit.max_scroll_depth":i,[e]:a.referrerCategory,[t]:a.aiPlatform}),F()}function De(){document.addEventListener(`visibilitychange`,()=>{document.hidden?W&&=(U+=Date.now()-H,!1):(H=Date.now(),W=!0)}),window.addEventListener(`beforeunload`,()=>{K(),Ie()})}function Oe(){document.addEventListener(`click`,e=>{e.target.closest(_.searchSelector)&&j(d,{})},!0),document.addEventListener(`keydown`,e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&j(d,{"browser.do11y.search.trigger":`keyboard`})})}function ke(e){if(!e)return 1;try{let t=document.querySelectorAll(_.codeBlockSelector);for(let n=0;n<t.length;n++)if(t[n]===e)return n+1}catch{}return 1}function Ae(){document.addEventListener(`click`,e=>{let t=e.target.closest(_.copyButtonSelector);if(t){let e=t.closest(`[class*="language-"], [language]`)??t.closest(_.codeBlockSelector)??t.closest(`.expressive-code`)?.querySelector(`pre`)??t.closest(`div, section`)?.querySelector(`pre`)??t.parentElement?.querySelector(`pre`)??null,n=C((e?e.tagName===`PRE`?e.querySelector(`code`):e.querySelector(`code[class*="language-"], code[language]`)??e.querySelector(`code`):null)??e??t);j(`browser.do11y.code_copied`,{"browser.do11y.code.language":n,"browser.do11y.code.section":w(L(e??t),100),"browser.do11y.code.index":ke(e)})}},!0)}let q=null,J={};function je(){if(!_.trackSectionVisibility||typeof IntersectionObserver>`u`)return;let e=_.sectionVisibleThreshold*1e3;q=new IntersectionObserver(t=>{t.forEach(t=>{let n=t.target.getAttribute(`data-do11y-section-id`);if(n)if(t.isIntersecting){if(!J[n]){let r={start:Date.now(),reported:!1,timeoutId:null};r.timeoutId=setTimeout(()=>{if(J[n]&&!J[n].reported){let r=t.target.textContent?.trim()??``;j(f,{[i]:w(r,100),[a]:parseInt(t.target.tagName.charAt(1),10),[o]:Math.round(e/1e3)}),J[n].reported=!0}},e),J[n]=r}}else{if(J[n]&&(J[n].timeoutId&&clearTimeout(J[n].timeoutId),!J[n].reported)){let r=Date.now()-J[n].start;if(r>=e){let e=t.target.textContent?.trim()??``;j(f,{[i]:w(e,100),[a]:parseInt(t.target.tagName.charAt(1),10),[o]:Math.round(r/1e3)}),J[n].reported=!0}}delete J[n]}})},{threshold:.5}),Y()}function Y(){q&&document.querySelectorAll(`h2, h3`).forEach((e,t)=>{e.setAttribute(`data-do11y-section-id`,`section-`+t),q.observe(e)})}function X(){if(!q)return;let e=Date.now(),t=_.sectionVisibleThreshold*1e3;Object.keys(J).forEach(n=>{let r=J[n];if(r&&!r.reported){r.timeoutId&&clearTimeout(r.timeoutId);let s=e-r.start;if(s>=t){let e=typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(n):n.replace(/["\\]/g,`\\$&`),t=document.querySelector(`[data-do11y-section-id="`+e+`"]`);t&&j(f,{[i]:w(t.textContent?.trim()??``,100),[a]:parseInt(t.tagName.charAt(1),10),[o]:Math.round(s/1e3)})}}}),J={}}function Me(){_.trackTabSwitches&&document.addEventListener(`click`,e=>{let t=`[role="tab"], .tabs button, .tabs a, .tabbed-labels label`,n=b(_.tabContainerSelector);n&&(t+=`, `+n+` button, `+n+` a, `+n+` label`);let r=e.target.closest(t);if(!r||r.getAttribute(`aria-selected`)===`true`||r.classList.contains(`active`)||r.classList.contains(`is-active`))return;let i=w(r.textContent,50);if(!i)return;let a=w(L(r),100);j(`browser.do11y.tab_switch`,{"browser.do11y.tab.label":i,"browser.do11y.tab.group":a,"browser.do11y.tab.is_default":!1})})}function Ne(){_.trackTocClicks&&document.addEventListener(`click`,e=>{let t=e.target.closest(`a`);if(!t)return;let n=re(t);if(!n)return;let r=t.getAttribute(`href`),i=r?ne(r):null;if(!i)return;let a=w(t.textContent,100),o=null;try{let e=i.slice(1),t=document.getElementById(e);t&&/^H[1-6]$/.test(t.tagName)&&(o=parseInt(t.tagName.charAt(1),10))}catch{}let s=n.querySelectorAll(`a[href*="#"]`),c=1;for(let e=0;e<s.length;e++)if(s[e]===t){c=e+1;break}j(`browser.do11y.toc_click`,{"browser.do11y.toc.heading":a,"browser.do11y.toc.heading_level":o,"browser.do11y.toc.position":c})},!0)}function Pe(){_.trackFeedback&&document.addEventListener(`click`,e=>{let t=e.target.closest(`button, [role="button"], a`);if(!t||!t.closest(b(_.feedbackSelector)??`[class*="feedback"], [class*="helpful"], [class*="rating"], [class*="was-this"], [data-feedback]`))return;let n=(t.textContent??``).trim().toLowerCase(),r=(t.getAttribute(`aria-label`)??``).toLowerCase(),i=(t.getAttribute(`title`)??``).toLowerCase(),a=t.getAttribute(`data-value`)??t.getAttribute(`data-md-value`)??t.getAttribute(`data-feedback`),o=a&&/^[\w\s.,!?-]{1,50}$/.test(a)?a:null,s=null;o?s=o:/\byes\b|👍|thumbs.?up|helpful/i.test(n+` `+r+` `+i)?s=`yes`:/\bno\b|👎|thumbs.?down|not.?helpful/i.test(n+` `+r+` `+i)&&(s=`no`),s&&j(`browser.do11y.feedback`,{"browser.do11y.feedback.rating":s})})}function Fe(){_.trackExpandCollapse&&(document.addEventListener(`toggle`,e=>{let t=e.target;if(t.tagName!==`DETAILS`)return;let n=t.querySelector(`summary`),r=w(n?n.textContent:``,100);j(p,{[s]:r,[c]:t.open?`expand`:`collapse`,[l]:w(L(t),100)})},!0),document.addEventListener(`click`,e=>{let t=e.target.closest(`[aria-expanded], [class*="accordion"] button, [class*="collapsible"] button`);if(!t||t.closest(`details`)||t.closest(`nav, [role="navigation"], header`))return;let n=t.getAttribute(`aria-expanded`)===`true`;j(p,{[s]:w(t.textContent,100),[c]:n?`collapse`:`expand`,[l]:w(L(t),100)})}))}let Z=null,Q=null;function $(){if(window.Do11yConfig&&typeof window.Do11yConfig==`object`)for(let e in _)Object.prototype.hasOwnProperty.call(window.Do11yConfig,e)&&(_[e]=window.Do11yConfig[e]);let e=document.querySelector(`meta[name="do11y-destination"]`);if(e){let t=e.getAttribute(`content`);(t===`supabase`||t===`http`||t===`otlp`)&&(_.destination=t)}let t=document.querySelector(`meta[name="do11y-url"]`);t&&(_.supabaseUrl=t.getAttribute(`content`)??_.supabaseUrl);let n=document.querySelector(`meta[name="do11y-key"]`);n&&(_.supabaseKey=n.getAttribute(`content`)??_.supabaseKey);let r=document.querySelector(`meta[name="do11y-table"]`);r&&(_.supabaseTable=r.getAttribute(`content`)??_.supabaseTable);let i=document.querySelector(`meta[name="do11y-endpoint"]`);i&&(_.endpoint=i.getAttribute(`content`)??_.endpoint);let a=document.querySelector(`meta[name="do11y-otlp-endpoint"]`);a&&(_.otelSdkEndpoint=a.getAttribute(`content`)??_.otelSdkEndpoint);let o=document.querySelector(`meta[name="do11y-otlp-headers"]`);if(o)try{let e=JSON.parse(o.getAttribute(`content`)??`{}`);typeof e==`object`&&e&&(_.otelSdkHeaders=e)}catch{}let s=document.querySelector(`meta[name="do11y-debug"]`);s&&s.getAttribute(`content`)===`true`&&(_.debug=!0);let c=document.querySelector(`meta[name="do11y-domains"]`);if(c){let e=c.getAttribute(`content`);e&&(_.allowedDomains=e.split(`,`).map(e=>e.trim()))}let l=document.querySelector(`meta[name="do11y-framework"]`);l&&(_.framework=l.getAttribute(`content`)??_.framework);let u=document.querySelector(`meta[name="do11y-use-otel-instrumentations"]`);if(u&&u.getAttribute(`content`)===`true`&&(_.useOtelBrowserInstrumentations=!0),ee(),_.debug){let e=_.destination===`supabase`?!!_.supabaseKey:_.destination===`otlp`?!!_.otelSdkEndpoint:!!_.endpoint;console.log(`[Do11y] Initializing with config:`,{destination:_.destination,hasCredentials:e,framework:_.framework,allowedDomains:_.allowedDomains,respectDNT:_.respectDNT})}if(te()){A=!0,_.debug&&console.log(`[Do11y] Tracking disabled`);return}(_.destination===`supabase`?_.supabaseKey:_.destination===`otlp`?_.otelSdkEndpoint:_.endpoint)||_.debug&&(console.warn(`[Do11y] No destination configured. Events will not be sent.`),_.destination===`supabase`?console.warn(`[Do11y] Add <meta name="do11y-url"> and <meta name="do11y-key"> to enable.`):_.destination===`otlp`?console.warn(`[Do11y] Add <meta name="do11y-otlp-endpoint"> to enable.`):console.warn(`[Do11y] Add <meta name="do11y-endpoint"> to enable.`)),I(),Se(),Ee(),De(),Oe(),Ae(),je(),Me(),Ne(),Pe(),Fe();let d=window.location.pathname,f=()=>{window.location.pathname!==d&&(d=window.location.pathname,K(),R=new Set,V=Date.now(),H=Date.now(),U=0,W=!0,I(),Y(),B())};Z=new MutationObserver(f),Z.observe(document.body,{childList:!0,subtree:!0}),window.addEventListener(`popstate`,f),Q=window.setInterval(f,200),Object.freeze(_),_.debug&&console.log(`[Do11y] Initialized successfully`)}function Ie(){Z&&=(Z.disconnect(),null),q&&=(X(),q.disconnect(),null),O&&=(clearTimeout(O),null),Q!==null&&(clearInterval(Q),Q=null),xe()}!h&&!g&&(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,$):$()),window.Do11y=window.Do11y??{getConfig:()=>({destination:_.destination,hasCredentials:_.destination===`supabase`?!!_.supabaseKey:_.destination===`otlp`?!!_.otelSdkEndpoint:!!_.endpoint,isDisabled:A,allowedDomains:_.allowedDomains,respectDNT:_.respectDNT}),flush:F,isEnabled:()=>A?!1:_.destination===`supabase`?!!_.supabaseKey:_.destination===`otlp`?!!_.otelSdkEndpoint:!!_.endpoint,getQueueSize:()=>D.length,version:m}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manototh/do11y",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Documentation observability",
5
5
  "type": "module",
6
6
  "main": "./dist/do11y.min.js",