import{N as x,D as E,aS as f,bd as v,f as r,aT as T,y as g,cf as b,P as k}from"./index-BKKvzUDD.js";function y(p,{disabled:o,beforeFocus:a,afterFocus:c,beforeBlur:u,afterBlur:e}={}){const{emit:d}=x(),n=T(),i=g(!1),h=s=>{const t=v(a)?a(s):!1;r(o)||i.value||t||(i.value=!0,d("focus",s),c==null||c())},C=s=>{var l;const t=v(u)?u(s):!1;r(o)||s.relatedTarget&&((l=n.value)!=null&&l.contains(s.relatedTarget))||t||(i.value=!1,d("blur",s),e==null||e())},m=s=>{var t,l;r(o)||b(s.target)||(t=n.value)!=null&&t.contains(document.activeElement)&&n.value!==document.activeElement||(l=p.value)==null||l.focus()};return E([n,()=>r(o)],([s,t])=>{s&&(t?s.removeAttribute("tabindex"):s.setAttribute("tabindex","-1"))}),f(n,"focus",h,!0),f(n,"blur",C,!0),f(n,"click",m,!0),{isFocused:i,wrapperRef:n,handleFocus:h,handleBlur:C}}function A({afterComposition:p,emit:o}){const a=g(!1),c=n=>{o==null||o("compositionstart",n),a.value=!0},u=n=>{o==null||o("compositionupdate",n),a.value=!0},e=n=>{o==null||o("compositionend",n),a.value&&(a.value=!1,k(()=>p(n)))};return{isComposing:a,handleComposition:n=>{n.type==="compositionend"?e(n):u(n)},handleCompositionStart:c,handleCompositionUpdate:u,handleCompositionEnd:e}}export{A as a,y as u};
