import{newFocus as t,NEW_FOCUS as r}from"./solver.js";import{getAllAffectedNodes as n}from"./utils/all-affected.js";import{getAllTabbableNodes as o,getTabbableNodes as e}from"./utils/DOMutils.js";import{pickFirstFocus as i}from"./utils/firstFocus.js";import{isNotAGuard as u,isDefined as f}from"./utils/is.js";import{getTopCommonParent as a,allParentAutofocusables as s}from"./utils/parenting.js";var m=function(m,c){var l=document&&document.activeElement,d=n(m).filter(u),p=a(l||m,m,d),v=o(d),j=e(d).filter((function(t){var r=t.node;return u(r)}));if(j[0]||(j=v)[0]){var g,h,x,E,M=o([p]).map((function(t){return t.node})),O=(g=M,h=j,x=new Map,h.forEach((function(t){return x.set(t.node,t)})),g.map((function(t){return x.get(t)})).filter(f)),w=O.map((function(t){return t.node})),D=t(w,M,l,c);if(D===r){var F=v.map((function(t){return t.node})).filter((E=s(d),function(t){return t.autofocus||t.dataset&&!!t.dataset.autofocus||E.indexOf(t)>=0}));return{node:F&&F.length?i(F):i(w)}}return void 0===D?D:O[D]}};export{m as getFocusMerge};
//# sourceMappingURL=focusMerge.js.map
