function n(t){return new Promise((e,i)=>{let a;const o=new MutationObserver(()=>{t.hasAttribute("data-themed")&&(a&&clearTimeout(a),o.disconnect(),e())});if(o.observe(t,{attributes:!0,attributeFilter:["data-themed"]}),t.hasAttribute("data-themed")){o.disconnect(),e();return}a=setTimeout(()=>{o.disconnect(),i(new Error("Timeout waiting for data-themed attribute"))},5e3)})}const r=10;async function s(t,e){try{t.hasAttribute("data-themed")||await n(t),await e()}catch{throw new Error("The interactive element inside the KoliBri web component could not be focused. Try calling the focus method on the web component after a short delay again.")}}function c(t){const e=t.getRootNode();return e instanceof ShadowRoot?e.activeElement===t:document.activeElement===t}async function u(t){let e=0;do t&&t.focus(),await new Promise(i=>requestAnimationFrame(i)),e++;while(!c(t)&&e<r)}export{s as d,u as s,n as w};
//# sourceMappingURL=element-focus-BKUtVrWY-WEZqUgal.js.map
