import{i as e,n as t}from"./jsx-runtime-DG_AJzB_.js";import{a as n,f as r}from"./createReactComponent-_L2mp4Ui.js";import{V as i,ut as a}from"./getDisabledMountTransitionStyles-C-jmk481.js";import{v as o}from"./useBaseUiId-BCer0ph2.js";var s=e(t()),c=new Map([[`select`,`listbox`],[`combobox`,`listbox`],[`label`,!1]]);function l(e,t={}){let n=`rootStore`in e?e.rootStore:e,l=n.useState(`open`),u=n.useState(`floatingId`),d=n.useState(`domReferenceElement`),f=n.useState(`floatingElement`),{enabled:p=!0,role:m=`dialog`}=t,h=o(),g=d?.id||h,_=s.useMemo(()=>a(f)?.id||u,[f,u]),v=c.get(m)??m,y=i()!=null,b=s.useMemo(()=>v===`tooltip`||m===`label`?r:{"aria-haspopup":v===`alertdialog`?`dialog`:v,"aria-expanded":`false`,...v===`listbox`&&{role:`combobox`},...v===`menu`&&y&&{role:`menuitem`},...m===`select`&&{"aria-autocomplete":`none`},...m===`combobox`&&{"aria-autocomplete":`list`}},[v,y,m]),x=s.useMemo(()=>v===`tooltip`||m===`label`?{[`aria-${m===`label`?`labelledby`:`describedby`}`]:l?_:void 0}:{...b,"aria-expanded":l?`true`:`false`,"aria-controls":l?_:void 0,...v===`menu`&&{id:g}},[v,_,l,g,m,b]),S=s.useMemo(()=>{let e={id:_,...v&&{role:v}};return v===`tooltip`||m===`label`?e:{...e,...v===`menu`&&{"aria-labelledby":g}}},[v,_,g,m]),C=s.useCallback(({active:e,selected:t})=>{let n={role:`option`,...e&&{id:`${_}-fui-option`}};switch(m){case`select`:case`combobox`:return{...n,"aria-selected":t};default:}return{}},[_,m]);return s.useMemo(()=>p?{reference:x,floating:S,item:C,trigger:b}:{},[p,x,S,b,C])}var u=s.forwardRef(function(e,t){let{className:r,render:i,orientation:a=`horizontal`,...o}=e;return n(`div`,e,{state:s.useMemo(()=>({orientation:a}),[a]),ref:t,props:[{role:`separator`,"aria-orientation":a},o]})});export{l as n,u as t};