import{slicedToArray as r}from"../../_virtual/_rollupPluginBabelHelpers.js";import{useState as e,useEffect as u,useCallback as o}from"react";import n from"../useEventListener/index.js";import c from"../usePrevious/index.js";function t(t){var l=t.ref,a=t.focusCallback,i=t.blurCallback,f=e(!1),s=r(f,2),m=s[0],b=s[1],v=c(m);u((function(){void 0!==v&&(m?a&&a():i&&i())}),[i,a,m,v]);var p=o((function(){l.current.focus()}),[l]),d=o((function(){l.current.blur()}),[l]);return n({eventName:"focus",ref:l,callback:function(){b(!0)}}),n({eventName:"blur",ref:l,callback:function(){b(!1)}}),{isFocused:m,focus:p,blur:d}}export{t as default};
