import{c as H}from"./button-CZmOQP7j.js";import{r as s,j as d}from"./app-BBZbvTSO.js";import{c as V,a as p,u as z}from"./index-CbDI-tXU.js";import{c as q}from"./index-IvSACaye.js";import{u as J}from"./utils-YhN_nlHn.js";import{b as Q,u as W}from"./Combination-9YgcTppv.js";import{P as G}from"./index-13DH8-b5.js";import{u as X}from"./index-BosTFUDi.js";/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Z=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Fe=H("Circle",Z);var _="rovingFocusGroup.onEntryFocus",$={bubbles:!1,cancelable:!0},I="RovingFocusGroup",[A,N,ee]=q(I),[oe,ge]=V(I,[ee]),[te,re]=oe(I),O=s.forwardRef((e,r)=>d.jsx(A.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(A.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(ne,{...e,ref:r})})}));O.displayName=I;var ne=s.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:c,orientation:o,loop:E=!1,dir:T,currentTabStopId:v,defaultCurrentTabStopId:w,onCurrentTabStopIdChange:S,onEntryFocus:m,preventScrollOnEntryFocus:a=!1,...b}=e,F=s.useRef(null),g=J(r,F),R=X(T),[C,t]=z({prop:v,defaultProp:w??null,onChange:S,caller:I}),[i,x]=s.useState(!1),u=W(m),l=N(c),h=s.useRef(!1),[L,P]=s.useState(0);return s.useEffect(()=>{const n=F.current;if(n)return n.addEventListener(_,u),()=>n.removeEventListener(_,u)},[u]),d.jsx(te,{scope:c,orientation:o,dir:R,loop:E,currentTabStopId:C,onItemFocus:s.useCallback(n=>t(n),[t]),onItemShiftTab:s.useCallback(()=>x(!0),[]),onFocusableItemAdd:s.useCallback(()=>P(n=>n+1),[]),onFocusableItemRemove:s.useCallback(()=>P(n=>n-1),[]),children:d.jsx(G.div,{tabIndex:i||L===0?-1:0,"data-orientation":o,...b,ref:g,style:{outline:"none",...e.style},onMouseDown:p(e.onMouseDown,()=>{h.current=!0}),onFocus:p(e.onFocus,n=>{const M=!h.current;if(n.target===n.currentTarget&&M&&!i){const D=new CustomEvent(_,$);if(n.currentTarget.dispatchEvent(D),!D.defaultPrevented){const y=l().filter(f=>f.focusable),U=y.find(f=>f.active),B=y.find(f=>f.id===C),Y=[U,B,...y].filter(Boolean).map(f=>f.ref.current);k(Y,a)}}h.current=!1}),onBlur:p(e.onBlur,()=>x(!1))})})}),K="RovingFocusGroupItem",j=s.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:c,focusable:o=!0,active:E=!1,tabStopId:T,children:v,...w}=e,S=Q(),m=T||S,a=re(K,c),b=a.currentTabStopId===m,F=N(c),{onFocusableItemAdd:g,onFocusableItemRemove:R,currentTabStopId:C}=a;return s.useEffect(()=>{if(o)return g(),()=>R()},[o,g,R]),d.jsx(A.ItemSlot,{scope:c,id:m,focusable:o,active:E,children:d.jsx(G.span,{tabIndex:b?0:-1,"data-orientation":a.orientation,...w,ref:r,onMouseDown:p(e.onMouseDown,t=>{o?a.onItemFocus(m):t.preventDefault()}),onFocus:p(e.onFocus,()=>a.onItemFocus(m)),onKeyDown:p(e.onKeyDown,t=>{if(t.key==="Tab"&&t.shiftKey){a.onItemShiftTab();return}if(t.target!==t.currentTarget)return;const i=ae(t,a.orientation,a.dir);if(i!==void 0){if(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;t.preventDefault();let u=F().filter(l=>l.focusable).map(l=>l.ref.current);if(i==="last")u.reverse();else if(i==="prev"||i==="next"){i==="prev"&&u.reverse();const l=u.indexOf(t.currentTarget);u=a.loop?ue(u,l+1):u.slice(l+1)}setTimeout(()=>k(u))}}),children:typeof v=="function"?v({isCurrentTabStop:b,hasTabStop:C!=null}):v})})});j.displayName=K;var se={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ce(e,r){return r!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ae(e,r,c){const o=ce(e.key,c);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return se[o]}function k(e,r=!1){const c=document.activeElement;for(const o of e)if(o===c||(o.focus({preventScroll:r}),document.activeElement!==c))return}function ue(e,r){return e.map((c,o)=>e[(r+o)%e.length])}var Re=O,Ce=j;export{Fe as C,Ce as I,Re as R,ge as c};
