import{L as e,P as t,d as n,h as r}from"./jsx-runtime-DLhMyTcm.js";import{t as i}from"./react-dom-BrxRG89u.js";import{a,i as o,o as s}from"./button-DxvPbmBs.js";var c=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),l={[c.startingStyle]:``},u={[c.endingStyle]:``},d={transitionStatus(e){return e===`starting`?l:e===`ending`?u:null}},f=`none`,p=`trigger-press`,m=`trigger-hover`,h=`trigger-focus`,g=`outside-press`,_=`item-press`,v=`close-press`,y=`focus-out`,b=`escape-key`,x=`list-navigation`,S=`cancel-open`,C=`sibling-open`,w=`disabled`,T=`imperative-action`,E=`window-resize`;function D(e,t,r,i){let a=!1,o=!1,s=i??n;return{reason:e,event:t??new Event(`base-ui`),cancel(){a=!0},allowPropagation(){o=!0},get isCanceled(){return a},get isPropagationAllowed(){return o},trigger:r,...s}}var O=e(t()),k=0;function A(e,t=`mui`){let[n,r]=O.useState(e),i=e||n;return O.useEffect(()=>{n??(k+=1,r(`${t}-${k}`))},[n,t]),i}var j=a.useId;function M(e,t){if(j!==void 0){let n=j();return e??(t?`${t}-${n}`:n)}return A(e,t)}function N(e){return M(e,`base-ui`)}var P=[];function F(e){O.useEffect(e,P)}var I=null;globalThis.requestAnimationFrame;var L=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,--this.callbacksCount)}},R=class e{static create(){return new e}static request(e){return L.request(e)}static cancel(e){return L.cancel(e)}currentId=I;request(e){this.cancel(),this.currentId=L.request(()=>{this.currentId=I,e()})}cancel=()=>{this.currentId!==I&&(L.cancel(this.currentId),this.currentId=I)};disposeEffect=()=>this.cancel};function z(){let e=r(R.create).current;return F(e.disposeEffect),e}function B(e){return e==null?e:`current`in e?e.current:e}function V(e,t=!1,n=!1){let[r,i]=O.useState(e&&t?`idle`:void 0),[a,s]=O.useState(e);return e&&!a&&(s(!0),i(`starting`)),!e&&a&&r!==`ending`&&!n&&i(`ending`),!e&&!a&&r===`ending`&&i(void 0),o(()=>{if(!e&&a&&r!==`ending`&&n){let e=R.request(()=>{i(`ending`)});return()=>{R.cancel(e)}}},[e,a,r,n]),o(()=>{if(!e||t)return;let n=R.request(()=>{i(void 0)});return()=>{R.cancel(n)}},[t,e]),o(()=>{if(!e||!t)return;e&&a&&r!==`idle`&&i(`starting`);let n=R.request(()=>{i(`idle`)});return()=>{R.cancel(n)}},[t,e,a,i,r]),O.useMemo(()=>({mounted:a,setMounted:s,transitionStatus:r}),[a,r])}var H=e(i());function U(e,t=!1,n=!0){let r=z();return s((i,a=null)=>{r.cancel();function o(){H.flushSync(i)}let s=B(e);if(s==null)return;let l=s;if(typeof l.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=c.startingStyle;if(!l.hasAttribute(e)){r.request(i);return}let t=new MutationObserver(()=>{l.hasAttribute(e)||(t.disconnect(),i())});t.observe(l,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}function i(){Promise.all(l.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||o()}).catch(()=>{let e=l.getAnimations();if(n){if(a?.aborted)return;o()}else e.length>0&&e.some(e=>e.pending||e.playState!==`finished`)&&i()})}if(t){e();return}r.request(i)}})}function W(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=s(i),o=U(r,n,!1);O.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}function G({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=O.useRef(e!==void 0),[a,o]=O.useState(t);return[i?e:a,O.useCallback(e=>{i||o(e)},[])]}export{h as C,c as D,E,d as O,C as S,p as T,T as _,B as a,f as b,F as c,D as d,S as f,y as g,b as h,V as i,N as l,w as m,W as n,R as o,v as p,U as r,z as s,G as t,M as u,_ as v,m as w,g as x,x as y};