function t(t,o=!0){const e=t.ownerDocument.defaultView,i=e===window.top;let n=t,r=n.getBoundingClientRect(),l=!1;for(;n.parentElement&&(!r.height||!r.width);)l=!0,n=n.parentElement,r=n.getBoundingClientRect();const a=e.getComputedStyle(n)||{};let s=e.frameElement,h=r,p=h.top+(i?e.pageYOffset:0),c=h.left+(i?e.pageXOffset:0),d=p,g=c;if(s)for(d=h.top,g=h.left,p=h.top,c=h.left;s&&o;){const{frameElement:t,pageYOffset:o,pageXOffset:e}=s.ownerDocument.defaultView,i=s.ownerDocument.defaultView===window.top,n=window.getComputedStyle(s),r=Math.max(parseFloat(n.borderLeftWidth),0),l=Math.max(parseFloat(n.borderTopWidth),0);h=s.getBoundingClientRect(),d+=h.top+l+(i?o:0),g+=h.left+r+(i?e:0),s=t}const m=e.frameElement?{top:d-window.pageYOffset,left:g-window.pageXOffset,height:r.height,width:r.width}:r,f=function(t,o=window.visualViewport||{width:window.innerWidth,height:window.innerWidth}){return{top:t.top+t.height<0,bottom:t.top>o.height,left:t.left+t.width<0,right:t.left>o.width}}(m),u=function(t,o={height:document.documentElement.scrollHeight,width:document.documentElement.scrollWidth}){return{top:t.top+t.height+(window.scrollY||window.pageYOffset)<0,bottom:t.top>o.height,left:t.left+t.width+(window.scrollX||window.pageXOffset)<0,right:t.left>o.width}}(m),b=t=>+t?.replace("px","")||0,{height:w,width:x}=e.visualViewport||{width:e.innerWidth,height:e.innerHeight};return{hidden:l,offViewport:f.top||f.bottom||f.left||f.right,offscreen:u.top||u.bottom||u.left||u.right,offscreenTop:u.top,offscreenBottom:u.bottom,offscreenLeft:u.left,offscreenRight:u.right,fullscreen:d<=0&&g<=0&&r.width>=x&&r.height>=w,top:d,left:g,offsetTop:p,offsetLeft:c,width:r.width,height:r.height,margin:{top:b(a.marginTop),right:b(a.marginRight),bottom:b(a.marginBottom),left:b(a.marginLeft)},border:{top:b(a.borderTopWidth),right:b(a.borderRightWidth),bottom:b(a.borderBottomWidth),left:b(a.borderLeftWidth)},padding:{top:b(a.paddingTop),right:b(a.paddingRight),bottom:b(a.paddingBottom),left:b(a.paddingLeft)}}}const o=new Map,e=t=>1===t.length?t[0]:t;var i={sanitize:t=>l().commons.text.sanitize(t),sanitizeContext:r,isValidLang(t){const o=l();return!!t&&o.utils.isValidLang(t)},hasContent(t){const o=l(t),e=f(o,t);return!!e&&o.commons.dom.hasContentVirtual(e)},getRequiredContext(t){const o=l();return t?o.commons.aria.requiredContext(t):[]},isOffscreen:(...t)=>e(t.map(h)),isHidden:(...t)=>e(t.map(p)),isVisible:(t,o=!1)=>!!t.ownerDocument.defaultView&&e(function(t,o){const e=l(t,o);o&&(e.teardown(),e.setup());return e.commons.dom.isVisible(t,!1,!0)}(t,o)),isSRVisible:(...t)=>e(t.map(c)),name:(...t)=>e(t.map(s)),isOpaque:(...t)=>e(t.map(u)),getRoleType:(...t)=>e(t.map(d)),getRole:(...t)=>e(t.map(g)),getContrast:(...t)=>e(t.map(m)),runContrastAnalysis:t=>async function(t){const o=l();w();try{const e=(await o.run(Array.isArray(t)?t.map(r):r(t),{runOnly:["color-contrast"],restoreScroll:!0,pingWaitTime:5e3,resultTypes:["violations"]}))?.violations?.[0]?.nodes;return e?.map?.((t=>{const o=t.any[0],e=["fgColor","bgColor","contrastRatio","expectedContrastRatio"],i=parseInt(o.data.fontSize.split(" ")[0]),n="bold"===o.data.fontWeight;return{data:{...Object.fromEntries(Object.entries(o.data).filter((([t])=>e.includes(t)))),fontSize:i,isBold:n},selector:t.target}}))||[]}catch(t){console.error(t)}finally{n(document.body)}return[]}(t),isWidgetRole:t=>l().commons.aria.lookupTable.rolesOfType.widget.includes(t),isFocusable:(...t)=>e(t.map(b)),getTabbableElements:t=>function(t){const o=l(t,!0),e=f(o,t);return o.commons.dom.getTabbableElements(e).map((({actualNode:t})=>t))}(t),getFlattenedTree:n,getSource:t=>new(l().utils.DqElement)(t).source,getSelector(t){const o=l();return o._selectorData||(o._selectorData=o.utils.getSelectorData(o.utils.getFlattenedTree())),o.utils.getSelector(t)},getElementStack(t,o=!0){const e=l();return o&&(e.teardown(),e.setup()),e.commons.dom.getElementStack(t)},idrefs:(t,o)=>l(t).commons.dom.idrefs(t,o),table:{isRowHeader:t=>l(t).commons.table.isRowHeader(t),isColumnHeader:t=>l(t).commons.table.isColumnHeader(t),toGrid(t){const o=l(t);return o.teardown(),o.setup(),o.commons.table.toGrid(t)},isDataTable:t=>l(t).commons.table.isDataTable(t),getCellPosition:(t,o)=>l(t).commons.table.getCellPosition(t,o),traverse(t,o,e,i){if(!e[0]?.[0])return;return l(e[0][0]).commons.table.traverse(t,o,e,i)}},setupTrees:function(){w(),o.clear()},cleanupTrees:w,isAxeSetUp:t=>!!l(t)._tree};function n(t){const e=l(),i=e.utils.getFlattenedTree(t.ownerDocument);return o.set(e,i),i}function r(t){if(!t.ownerDocument||t.ownerDocument===document)return t;const o=l();o._selectorData=o.utils.getSelectorData(o.utils.getFlattenedTree());const e=[o.utils.getSelector(t)];let i=t.ownerDocument.defaultView.frameElement;for(;i;)e.unshift(o.utils.getSelector(i)),i=i.contentWindow.parent.frameElement;return e.flat()}function l(t=document.documentElement,e=!1){const i=t.ownerDocument,n=i.defaultView;if(!n)throw new ReferenceError("no context was found for this node");const r=n.axe;if(!r)throw new ReferenceError("axe was not found in this context");const l=o.get(r)?.[0];return(e||!o.has(r)||l&&!r.utils.getNodeFromTree(l,t))&&o.set(r,r.utils.getFlattenedTree(i)),r}function a(t){return!!l(t).utils.getNodeFromTree(t)}function s(t){const o=l(t),e=f(o,t);return e?o.commons.text.accessibleTextVirtual(e):""}function h(t){return l(t).commons.dom.isOffscreen(t)}function p(t){return l(t).commons.utils.isHidden(t)}function c(t){return l(t).commons.dom.isVisible(t,!0,!1)}function d(t){const o=l(t),e=function(t){return l(t).commons.aria.implicitRole(t)}(t),i=o.commons.aria.lookupTable.role[e];return i&&i.type}function g(t){const o=l(t);return a(t)?o.commons.aria.getRole(t):null}function m(t){const o=l(t);let e;try{const i=o.commons.color.getForegroundColor(t),n=o.commons.color.getBackgroundColor(t);e=o.commons.color.getContrast(n,i)}catch(t){console.error(t)}return e}function f(t,e){let i=o.get(t);return i||(i=t.utils.getFlattenedTree(e.ownerDocument),o.set(t,i)),t.utils.getNodeFromTree(i[0],e)}function u(t){return l(t).commons.dom.isOpaque(t)}function b(t){const o=l(t);return a(t)?o.commons.dom.isFocusable(t):void 0}function w(){o.forEach(((t,e)=>{e.teardown(),o.delete(e)}))}const{getRole:x,getContrast:y,name:v,isHidden:M}=i;function L(t){const o=new Map;try{const e=function(t){const o=y(t);if(!o)return;return{name:"Contrast",value:`\n AA ${Math.floor(100*o)/100}\n ${o<4.5?'':''}\n `}}(t),i=function(t){const o=x(t);if(o)return{name:"Role",value:o}}(t),n=i&&function(t){const o=v(t);return{name:"Accessible Text",value:M(t)?"hidden":o||"empty"}}(t);[e,i,n].filter(Boolean).forEach((({name:t,value:e})=>{o.set(t,e)}))}catch(t){console.error(t)}return o}const T=document.createElement("template");T.innerHTML='\n \n \n
\n
\n
\n
\n
\n
\n
\n \n';const E="tooltip--top",I="tooltip--bottom",j="tooltip--left",D="tooltip--right",A="tooltip--fullscreen",C={fullpage:"highlight--fullpage",offscreen:"highlight--offscreen"},k="highlight--hide",S=320,O=({top:t,right:o,bottom:e,left:i})=>`\n border-top-width: ${Math.max(t,0)}px;\n border-right-width: ${Math.max(o,0)}px;\n border-bottom-width: ${Math.max(e,0)}px;\n border-left-width: ${Math.max(i,0)}px;\n `.replace(/[\s\n]/g,""),Y="axe-highlighter";const z=new class{constructor(){this.target=new EventTarget}on(t,o){this.target.addEventListener(t,o)}remove(t,o){this.target.removeEventListener(t,o)}emit(t){this.target.dispatchEvent(new CustomEvent(t))}},H=function(t,o){let e;return function(...i){e||(e=setTimeout((()=>{t(...i),e=null}),o))}}(z.emit.bind(z),50),R=t=>{"selection"!==t.theme&&t.theme&&H("highlighter:change")};class ${static tagName="axe-highlighter";constructor(o,e=null){if(!o)return;const i=o.ownerDocument||document;let n;this.target=o,this.selector=e,this.axeHighlighter=i.createElement($.tagName);try{n=this.axeHighlighter.attachShadow({mode:"open"})}catch(t){n=this.axeHighlighter.shadowRoot}this.axeHighlighter.style.setProperty("--axe-highlight-counter",N.size+1),n.appendChild(T.content.cloneNode(!0)),this.position=n.getElementById("position"),this.highlight=n.getElementById("axe-highlight"),this.tooltip=n.getElementById("tooltip"),this.cachedLayout=o.layout||t(o)}updatePosition(){const{target:o}=this;if(!o.isConnected&&!o.frameId)return;const{width:e,height:i,margin:n,border:r,padding:l,hidden:a,offViewport:s,offscreen:h,fullscreen:p}=this.cachedLayout=o.layout||t(o);let{top:c,left:d}=this.cachedLayout;const{position:g}=this,{height:m,width:f,pageTop:u,pageLeft:b}=window.visualViewport||{width:window.innerWidth,height:window.innerHeight,pageTop:window.pageYOffset,pageLeft:window.pageXOffset},w=c+i/2>m/2+u,x=d>f-320+b,y=this.axeHighlighter.offsetParent;if(y&&"static"!==getComputedStyle(y).getPropertyValue("position")){const t=y.getBoundingClientRect();c-=t.top+u,d-=t.left+b}g.textContent=`\n #axe-highlight {\n top: ${c-Math.max(n.top,0)}px;\n left: ${d-Math.max(n.left,0)}px;\n }\n\n #tooltip {\n top: ${w?"auto":`${i+(c+Math.max(n.bottom,0))}px`};\n bottom: ${w?-(c-Math.max(n.top,0))+"px":"auto"};\n left: ${x?"auto":`${d}px`};\n right: ${x?f-d+"px":"auto"};\n }\n\n #margin {\n ${O(n)}\n height: ${i}px;\n width: ${e}px;\n }\n\n #border {\n ${O(r)}\n }\n\n #content {\n ${O(l)}\n }\n `;let v=s&&!p,M=h&&!p;if(o.frameId&&o.layout){const{layout:t}=o;v=t.top+t.heightu+m}this.highlight.classList.toggle(C.fullpage,p),this.highlight.classList.toggle(C.offscreen,v||M),this.showTooltip({offViewport:v,offscreen:M,showTooltip:!!M||this.options.showTooltip,hidden:a,flipY:w,flipX:x})}setTheme(t,o){const{classList:e}=this.highlight;e.remove(...e),e.add(`theme--${t}`);const{badgeContent:i}=o;i&&this.axeHighlighter.style.setProperty("--axe-highlight-badge-content",`'${i}'`),this.theme=t,R(this)}setOptions(t){this.options=t}showTooltip({hidden:t=!1,offViewport:o=!1,offscreen:e=!1,showTooltip:i=!1,flipX:n=!1,flipY:r=!1}={}){const{target:l,tooltip:a,cachedLayout:s,options:h}=this,{showMetadata:p}=h;if(!i)return a.innerHTML="",void(a.style.display="none");const{offscreenTop:c=!1,offscreenLeft:d=!1,offscreenBottom:g=!1,offscreenRight:m=!1,top:f,left:u,height:b,width:w,fullscreen:x}=s,y=f-(window.scrollY||window.pageYOffset)+"px",v=u-(window.scrollX||window.pageXOffset)+"px",M=l.tagName.toLowerCase(),T=l.getAttribute?.("id")||l.attributes?.id,C=Array.from(l.classList).join("."),k=T?`#${T}`:C.length?`.${C}`:"";!p||this.checks||l.frameId||(this.checks=L(l));const S=this.checks&&Array.from(this.checks.entries()).map((([t,o])=>`
${t}
${o}
`));a.innerHTML=`\n
\n ${M}${k}\n ${t?'(hidden)':""}\n ${parseFloat(w.toFixed(2))} x ${parseFloat(b.toFixed(2))}\n
\n ${S&&S.length?`
${S.join("")}`:""}\n `,a.style.display="block";let O=I;requestAnimationFrame((()=>{e?(this.tooltip.style.position="fixed",c?(this.tooltip.style.top="0",this.tooltip.style.bottom="auto",O=I):(this.tooltip.style.top=y,this.tooltip.style.bottom="auto"),g&&(this.tooltip.style.bottom="0",this.tooltip.style.top="auto",O=E),d?(this.tooltip.style.left="0",this.tooltip.style.right="auto",O=j):(this.tooltip.style.left=v,this.tooltip.style.right="auto"),m&&(this.tooltip.style.right="0",this.tooltip.style.left="auto",O=D)):(o?(this.tooltip.style.position="fixed",r?(this.tooltip.style.top="auto",this.tooltip.style.bottom="0"):this.tooltip.style.top="0"):(this.tooltip.style.position="",this.tooltip.style.top="",this.tooltip.style.bottom=""),r&&(O=E),O+=` ${n?D:j}`),a.classList.toggle(A,x),a.classList.remove(E,I,j,D),a.classList.add(...O.split(" "))}))}hide(){this.axeHighlighter.classList.add("highlight--hide"),R(this)}show(){this.axeHighlighter.classList.remove("highlight--hide"),R(this)}scrollIntoView({behavior:t="smooth"}={}){const o={block:"center",behavior:t,inline:"nearest"};this.target?.scrollIntoView?.(o)}destroy(){this.axeHighlighter.parentNode?.removeChild(this.axeHighlighter),N.delete(this.target),R(this)}}const N=new Map,V=t=>Array.from(N.keys()).find((o=>o.selector?.flat().join()===t.selector?.flat().join())),F=t=>N.has(t)||!(!t.selector||!V(t));let W=!1,B=!1;function P(){B||(window.requestAnimationFrame((()=>{N.forEach((t=>t.updatePosition())),B=!1})),B=!0)}function X(){Array.from(N.values()).forEach((t=>t.destroy()))}function Z(){Array.from(N.values()).forEach((t=>t.show()))}function G(){Array.from(N.values()).forEach((t=>t.hide()))}function U(t,o=null){let e=null;return W||(window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),window.addEventListener("beforeunload",(()=>{window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)})),W=!0),{highlight:function({theme:i="high-contrast",themeOptions:n={},showMetadata:r=!0,showTooltip:l=!0}={}){const a=N.get(t),s=V(t);if(e=a||new $(t,o),e.setTheme(i,n),e.setOptions({showTooltip:l,showMetadata:r}),s&&t.selector){N.get(s).destroy()}return a||(N.set(t,e),document.body.appendChild(e.axeHighlighter)),R(this||{theme:i}),e.updatePosition(),e},destroy:function(){e&&(e.destroy(),e=null)},scrollIntoView:t=>e?.scrollIntoView(t)}}export{S as TOOLTIP_MAX_WIDTH,X as clearHighlights,U as createHighlighter,z as emitter,V as findExistingHighlighterNode,G as hideHighlights,k as highlightHidden,C as highlightPosition,F as highlighterExists,N as highlighters,Z as showHighlights,Y as tagName,P as updateHighlighters};