import{d as B,aj as k,a_ as x,ak as G,b3 as O,o as w,c as A,w as g,a as M,k as i,ai as N,ag as P,A as c,al as V}from"./EJiqiqZX.js";import{f as $,E as j,a as D}from"./Cqd5VgjX.js";const[H,U]=V("RovingFocusGroup");var K=B({__name:"RovingFocusGroup",props:{orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!1},currentTabStopId:{type:[String,null],required:!1},defaultCurrentTabStopId:{type:String,required:!1},preventScrollOnEntryFocus:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["entryFocus","update:currentTabStopId"],setup(b,{expose:F,emit:I}){const a=b,p=I,{loop:S,orientation:f,dir:y}=k(a),v=x(y),l=G(a,"currentTabStopId",p,{defaultValue:a.defaultCurrentTabStopId,passive:a.currentTabStopId===void 0}),r=c(!1),n=c(!1),d=c(0),{getItems:m,CollectionSlot:T}=O({isProvider:!0});function C(e){const o=!n.value;if(e.currentTarget&&e.target===e.currentTarget&&o&&!r.value){const s=new CustomEvent(j,D);if(e.currentTarget.dispatchEvent(s),p("entryFocus",s),!s.defaultPrevented){const u=m().map(t=>t.ref).filter(t=>t.dataset.disabled!==""),_=u.find(t=>t.getAttribute("data-active")===""),R=u.find(t=>t.getAttribute("data-highlighted")===""),E=u.find(t=>t.id===l.value),q=[_,R,E,...u].filter(Boolean);$(q,a.preventScrollOnEntryFocus)}}n.value=!1}function h(){setTimeout(()=>{n.value=!1},1)}return F({getItems:m}),U({loop:S,dir:v,orientation:f,currentTabStopId:l,onItemFocus:e=>{l.value=e},onItemShiftTab:()=>{r.value=!0},onFocusableItemAdd:()=>{d.value++},onFocusableItemRemove:()=>{d.value--}}),(e,o)=>(w(),A(i(T),null,{default:g(()=>[M(i(N),{tabindex:r.value||d.value===0?-1:0,"data-orientation":i(f),as:e.as,"as-child":e.asChild,dir:i(v),style:{outline:"none"},onMousedown:o[0]||(o[0]=s=>n.value=!0),onMouseup:h,onFocus:C,onBlur:o[1]||(o[1]=s=>r.value=!1)},{default:g(()=>[P(e.$slots,"default")]),_:3},8,["tabindex","data-orientation","as","as-child","dir"])]),_:3}))}}),J=K;export{J as R,H as i};