"use strict";const y=require("./FocusScope-vAM-Q62b.cjs.js"),x=require("./filterDOMProps-WUskt27c.cjs.js"),T=require("./mergeProps-CxnHrnow.cjs.js"),f=require("react"),h=require("./context-CyT9C4U4.cjs.js");function w(l,n){const{"aria-label":u,"aria-labelledby":d,orientation:r="horizontal"}=l;let[a,b]=f.useState(!1);T.$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{var e;b(!!(n.current&&(!((e=n.current.parentElement)===null||e===void 0)&&e.closest('[role="toolbar"]'))))});const{direction:p}=h.$18f2051aff69b9bf$export$43bb16f9c6d9e3f7(),s=p==="rtl"&&r==="horizontal";let t=y.$9bf71ea28793e738$export$c5251b9e124bf29(n);const $=e=>{if(e.currentTarget.contains(e.target)){if(r==="horizontal"&&e.key==="ArrowRight"||r==="vertical"&&e.key==="ArrowDown")s?t.focusPrevious():t.focusNext();else if(r==="horizontal"&&e.key==="ArrowLeft"||r==="vertical"&&e.key==="ArrowUp")s?t.focusNext():t.focusPrevious();else if(e.key==="Tab"){e.stopPropagation(),o.current=document.activeElement,e.shiftKey?t.focusFirst():t.focusLast();return}else return;e.stopPropagation(),e.preventDefault()}},o=f.useRef(null),v=e=>{!e.currentTarget.contains(e.relatedTarget)&&!o.current&&(o.current=e.target)},g=e=>{var i;if(o.current&&!e.currentTarget.contains(e.relatedTarget)&&(!((i=n.current)===null||i===void 0)&&i.contains(e.target))){var c;(c=o.current)===null||c===void 0||c.focus(),o.current=null}};return{toolbarProps:{...x.$65484d02dcb7eb3e$export$457c3d6518dd4c6f(l,{labelable:!0}),role:a?"group":"toolbar","aria-orientation":r,"aria-label":u,"aria-labelledby":u==null?d:void 0,onKeyDownCapture:a?void 0:$,onFocusCapture:a?void 0:g,onBlurCapture:a?void 0:v}}}exports.$2680b1829e803644$export$fa142eb1681c520=w;
//# sourceMappingURL=useToolbar-D0DQSSBf.cjs.js.map
