import{f as y,a as b,g as I,h as g,w as F,j as K}from"./RovingFocusGroup-CP1IPgEn.js";import{P as h}from"./AppLogoIcon.vue_vue_type_script_setup_true_lang-DKWl2XLX.js";import{d as w,c as l,z as S,K as C,a as T,o as q,w as u,g as B,u as r,r as R,y as x}from"./app-Cb9hmj6k.js";var _=w({__name:"RovingFocusItem",props:{tabStopId:{type:String,required:!1},focusable:{type:Boolean,required:!1,default:!0},active:{type:Boolean,required:!1},allowShiftKey:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(d){const n=d,a=y(),f=b(),i=l(()=>n.tabStopId||f),c=l(()=>a.currentTabStopId.value===i.value),{getItems:p,CollectionItem:m}=I();S(()=>{n.focusable&&a.onFocusableItemAdd()}),C(()=>{n.focusable&&a.onFocusableItemRemove()});function v(e){if(e.key==="Tab"&&e.shiftKey){a.onItemShiftTab();return}if(e.target!==e.currentTarget)return;const t=g(e,a.orientation.value,a.dir.value);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||!n.allowShiftKey&&e.shiftKey)return;e.preventDefault();let o=[...p().map(s=>s.ref).filter(s=>s.dataset.disabled!=="")];if(t==="last")o.reverse();else if(t==="prev"||t==="next"){t==="prev"&&o.reverse();const s=o.indexOf(e.currentTarget);o=a.loop.value?F(o,s+1):o.slice(s+1)}x(()=>K(o))}}return(e,t)=>(q(),T(r(m),null,{default:u(()=>[B(r(h),{tabindex:c.value?0:-1,"data-orientation":r(a).orientation.value,"data-active":e.active?"":void 0,"data-disabled":e.focusable?void 0:"",as:e.as,"as-child":e.asChild,onMousedown:t[0]||(t[0]=o=>{e.focusable?r(a).onItemFocus(i.value):o.preventDefault()}),onFocus:t[1]||(t[1]=o=>r(a).onItemFocus(i.value)),onKeydown:v},{default:u(()=>[R(e.$slots,"default")]),_:3},8,["tabindex","data-orientation","data-active","data-disabled","as","as-child"])]),_:3}))}}),D=_;export{D as R};
