import{useCallback as e}from"react";import{useEventListener as t}from"./use-event-listener.js";import{useUpdateEffect as r}from"./use-update-effect.js";import{getAllFocusable as o}from"../../../utils/dist/esm/dom-query.js";import{isRefObject as s}from"../../../utils/dist/esm/assertion.js";import{contains as i}from"../../../utils/dist/esm/dom.js";import{focus as m}from"../../../utils/dist/esm/focus.js";var l={preventScroll:!0,shouldFocus:!1};function n(n,u){void 0===u&&(u=l);var{focusRef:c,preventScroll:f,shouldFocus:p,visible:d}=u,v=s(n)?n.current:n,a=p&&d,j=e((()=>{if(v&&a&&!i(v,document.activeElement))if(null!=c&&c.current)m(c.current,{preventScroll:f,nextTick:!0});else{var e=o(v);e.length>0&&m(e[0],{preventScroll:f,nextTick:!0})}}),[a,f,v,c]);r((()=>{j()}),[j]),t("transitionend",j,v)}export{n as useFocusOnShow};
//# sourceMappingURL=use-focus-on-show.js.map
