import{a as e,o as t,r as n}from"./Presence-Dgnb3wo9.js";import{$t as r,Et as i,J as a,Jt as o,Kt as s,Tn as c,Wn as l,X as u,Xn as d,at as f,bn as p,or as m,rr as h,st as g,vt as _,xn as v}from"./dist-CoD0k1Bd.js";import{n as y,t as b}from"./Primitive-GZZWGonv.js";import{c as x,i as S}from"./useForwardExpose--BtaxwkE.js";function C(e){let t=n({dir:d(`ltr`)});return a(()=>e?.value||t.dir?.value||`ltr`)}function w(){let e=d();return{primitiveElement:e,currentElement:a(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:S(e))}}var T=`data-reka-collection-item`;function E(e={}){let{key:t=``,isProvider:n=!1}=e,r=`${t}CollectionProvider`,s;if(n){let e=d(new Map);s={collectionRef:d(),itemMap:e},o(r,s)}else s=i(r);let c=(e=!1)=>{let t=s.collectionRef.value;if(!t)return[];let n=Array.from(t.querySelectorAll(`[${T}]`)),r=new Map(n.map((e,t)=>[e,t])),i=Array.from(s.itemMap.value.values()).sort((e,t)=>(r.get(e.ref)??-1)-(r.get(t.ref)??-1));return e?i:i.filter(e=>e.ref.dataset.disabled!==``)},u=g({name:`CollectionSlot`,inheritAttrs:!1,setup(e,{slots:t,attrs:n}){let{primitiveElement:r,currentElement:i}=w();return p(i,()=>{s.collectionRef.value=i.value}),()=>_(y,{ref:r,...n},t)}}),f=g({name:`CollectionItem`,inheritAttrs:!1,props:{value:{validator:()=>!0}},setup(e,{slots:t,attrs:n}){let{primitiveElement:r,currentElement:i}=w();return v(t=>{if(i.value){let n=l(i.value);s.itemMap.value.set(n,{ref:i.value,value:e.value}),t(()=>s.itemMap.value.delete(n))}}),()=>_(y,{...n,[T]:``,ref:r},t)}});return{getItems:c,reactiveItems:a(()=>Array.from(s.itemMap.value.values())),itemMapSize:a(()=>s.itemMap.value.size),CollectionSlot:u,CollectionItem:f}}var D=g({__name:`VisuallyHidden`,props:{feature:{type:String,required:!1,default:`focusable`},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`span`}},setup(e){return(e,t)=>(s(),u(m(b),{as:e.as,"as-child":e.asChild,"aria-hidden":e.feature===`focusable`||e.feature===`fully-hidden`?`true`:void 0,"data-hidden":e.feature===`fully-hidden`?``:void 0,tabindex:e.feature===`fully-hidden`?`-1`:void 0,style:{position:`absolute`,border:0,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`,whiteSpace:`nowrap`,wordWrap:`normal`,top:`-1px`,left:`-1px`}},{default:c(()=>[r(e.$slots,`default`)]),_:3},8,[`as`,`as-child`,`aria-hidden`,`data-hidden`,`tabindex`]))}}),O=`rovingFocusGroup.onEntryFocus`,k={bubbles:!1,cancelable:!0},A={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function j(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function M(e,t,n){let r=j(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return A[r]}function N(t,n=!1){let r=e();for(let i of t)if(i===r||(i.focus({preventScroll:n}),e()!==r))return}function P(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var[F,I]=t(`RovingFocusGroup`),L=g({__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(e,{expose:t,emit:n}){let i=e,a=n,{loop:o,orientation:l,dir:p}=h(i),g=C(p),_=x(i,`currentTabStopId`,a,{defaultValue:i.defaultCurrentTabStopId,passive:i.currentTabStopId===void 0}),v=d(!1),y=d(!1),S=d(0),{getItems:w,CollectionSlot:T}=E({isProvider:!0});function D(e){let t=!y.value;if(e.currentTarget&&e.target===e.currentTarget&&t&&!v.value){let t=new CustomEvent(O,k);if(e.currentTarget.dispatchEvent(t),a(`entryFocus`,t),!t.defaultPrevented){let e=w().map(e=>e.ref).filter(e=>e.dataset.disabled!==``);N([e.find(e=>e.getAttribute(`data-active`)===``),e.find(e=>e.getAttribute(`data-highlighted`)===``),e.find(e=>e.id===_.value),...e].filter(Boolean),i.preventScrollOnEntryFocus)}}y.value=!1}function A(){setTimeout(()=>{y.value=!1},1)}return t({getItems:w}),I({loop:o,dir:g,orientation:l,currentTabStopId:_,onItemFocus:e=>{_.value=e},onItemShiftTab:()=>{v.value=!0},onFocusableItemAdd:()=>{S.value++},onFocusableItemRemove:()=>{S.value--}}),(e,t)=>(s(),u(m(T),null,{default:c(()=>[f(m(b),{tabindex:v.value||S.value===0?-1:0,"data-orientation":m(l),as:e.as,"as-child":e.asChild,dir:m(g),style:{outline:`none`},onMousedown:t[0]||=e=>y.value=!0,onMouseup:A,onFocus:D,onBlur:t[1]||=e=>v.value=!1},{default:c(()=>[r(e.$slots,`default`)]),_:3},8,[`tabindex`,`data-orientation`,`as`,`as-child`,`dir`])]),_:3}))}});export{P as a,w as c,M as i,C as l,F as n,D as o,N as r,E as s,L as t};