const t=function(){let t,e,o,n,u,c,i=!0,s=0,r={};function m(t){const e=t.getBoundingClientRect(),o=document.documentElement,n=document.defaultView,u=document.body;let c=e.top+(n.pageYOffset||o.scrollTop||u.scrollTop)-(o.clientTop||u.clientTop||0),i=e.left+(n.pageXOffset||o.scrollLeft||u.scrollLeft)-(o.clientLeft||u.clientLeft||0);return{top:c,left:i,width:e.width,height:e.height,bottom:c+e.height,right:i+e.width}}function l(t,e,o){t.addEventListener(e,o,!0)}function d(){e.classList.remove("FlyingFocus-visible"),i=!0,clearTimeout(c)}function a(){const e=f(o);e.top!==r.top||e.left!==r.left||e.width!==r.width||e.height!==r.height?(r=e,t=0):t++,c=setTimeout(a,t<3?100:1e3)}function f(t){if(i)return;const o=function(t){let e=[t];const o=t.getAttribute("id"),n=Array.prototype.slice.call(document.querySelectorAll(`label[for="${o}"]:not(.visuallyhidden)`));e=e.concat(n);const u={top:1e6,left:1e6,bottom:-1e4,right:-1e4};for(var c=0,i=e.length;c<i;c++){const t=m(e[c]);u.top=Math.min(u.top,t.top),u.left=Math.min(u.left,t.left),u.bottom=Math.max(u.bottom,t.bottom),u.right=Math.max(u.right,t.right)}return u.width=u.right-u.left,u.height=u.bottom-u.top,u}(t);return o.top===r.top&&o.left===r.left&&o.width===r.width&&o.height===r.height||(e.style.left=o.left+"px",e.style.top=o.top+"px",e.style.width=o.width+"px",e.style.height=o.height+"px"),o}return{init:function(m){document&&document.getElementById("FlyingFocus")||(m?e=m:(e=document.createElement("div"),document.body.appendChild(e)),e.id="FlyingFocus",l(document.documentElement,"keydown",t=>{t.keyCode<65&&(s=new Date)}),l(document,"focusin",m=>{n=setTimeout(()=>{const n=m.target;"FlyingFocus"!==n.id&&(i&&new Date-s>100||(clearTimeout(u),clearTimeout(c),e.style.transitionDuration=e.style.WebkitTransitionDuration=(i?0:.15)+"s",t=0,c=setTimeout(a,100),i&&(e.classList.add("FlyingFocus-visible"),i=!1),r=f(n),o=n))},1)}),l(document,"focusout",()=>{i||(clearTimeout(n),clearTimeout(u),u=setTimeout(d,10))}),l(document.documentElement,"mousedown",t=>{t.detail&&d()}),l(document.documentElement,"touchstart",t=>{t.detail&&d()}),l(window,"resize",()=>f(o)))}}}(),e=()=>{t.init(),console.log("Swiss Re UI helpers loaded")};export{e as g}