import{a5 as g,ar as p}from"./c625DOTJ.js";import{s as I,w}from"./DkGSCXZX.js";import{g as y,h as i,w as A}from"./B-4V-jI8.js";import{n as v}from"./DRSikRWz.js";function N(e){e.setAttribute("data-highlighted","")}function j(e){e.removeAttribute("data-highlighted")}function C(e,t=500){let r=null;return function(...a){const o=()=>{r=null,e(...a)};r&&clearTimeout(r),r=setTimeout(o,t)}}function T(e){y&&I(1).then(()=>{const t=document.activeElement;!i(t)||t===e||(t.tabIndex=-1,e&&(e.tabIndex=0,e.focus()))})}function b(){return Array.from(document.querySelectorAll('a[href]:not([tabindex="-1"]), button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), textarea:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])'))}function k(e){const t=b(),a=t.indexOf(e)+1,o=t[a];return a=0&&i(o)?o:null}const S=new Set(["Shift","Control","Alt","Meta","CapsLock","NumLock"]),E={onMatch:T,getCurrentItem:()=>document.activeElement};function z(e={}){const t={...E,...e},r=A(g([])),a=C(()=>{r.update(()=>[])});return{typed:r,resetTyped:a,handleTypeaheadSearch:(l,m)=>{if(S.has(l))return;const u=t.getCurrentItem(),s=p(r);if(!Array.isArray(s))return;s.push(l.toLowerCase()),r.set(s);const f=m.filter(n=>!(n.getAttribute("disabled")==="true"||n.getAttribute("aria-disabled")==="true"||n.hasAttribute("data-disabled"))),h=s.length>1&&s.every(n=>n===s[0])?s[0]:s.join(""),x=i(u)?f.indexOf(u):-1;let c=w(f,Math.max(x,0));h.length===1&&(c=c.filter(n=>n!==u));const d=c.find(n=>(n==null?void 0:n.innerText)&&n.innerText.toLowerCase().startsWith(h.toLowerCase()));i(d)&&d!==u&&t.onMatch(d),a()}}}function B(){return v(10)}export{N as a,k as b,z as c,q as d,B as g,T as h,j as r};