"use strict";const h=require("react-dom"),n=require("react"),u=require("./mergeProps-CxnHrnow.cjs.js"),x=require("./useEvent-D0r31Azw.cjs.js"),b=require("./SSRProvider-DZRLwxPS.cjs.js"),$=require("./useControlledState-D0L6S_5r.cjs.js");function y(d,t,r){let{isDisabled:i}=d,s=u.$bdb11010cef70236$export$f680877a34711e37(),a=u.$bdb11010cef70236$export$f680877a34711e37(),o=b.$b5e257d569688ac6$export$535bd6ca7f90a273(),l=n.useRef(null),f=n.useCallback(()=>{l.current=requestAnimationFrame(()=>{r.current&&r.current.setAttribute("hidden","until-found")}),h.flushSync(()=>{t.toggle()})},[r,t]);x.$e9faafb641e167db$export$90fc3a17d93f704c(r,"beforematch",f);let c=n.useRef(null);return u.$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{if(l.current&&cancelAnimationFrame(l.current),r.current&&!i&&!o){let e=r.current;c.current==null||typeof e.getAnimations!="function"?t.isExpanded?(e.removeAttribute("hidden"),e.style.setProperty("--disclosure-panel-width","auto"),e.style.setProperty("--disclosure-panel-height","auto")):(e.setAttribute("hidden","until-found"),e.style.setProperty("--disclosure-panel-width","0px"),e.style.setProperty("--disclosure-panel-height","0px")):t.isExpanded!==c.current&&(t.isExpanded?(e.removeAttribute("hidden"),e.style.setProperty("--disclosure-panel-width",e.scrollWidth+"px"),e.style.setProperty("--disclosure-panel-height",e.scrollHeight+"px"),Promise.all(e.getAnimations().map(p=>p.finished)).then(()=>{e.style.setProperty("--disclosure-panel-width","auto"),e.style.setProperty("--disclosure-panel-height","auto")}).catch(()=>{})):(e.style.setProperty("--disclosure-panel-width",e.scrollWidth+"px"),e.style.setProperty("--disclosure-panel-height",e.scrollHeight+"px"),window.getComputedStyle(e).height,e.style.setProperty("--disclosure-panel-width","0px"),e.style.setProperty("--disclosure-panel-height","0px"),Promise.all(e.getAnimations().map(p=>p.finished)).then(()=>e.setAttribute("hidden","until-found")).catch(()=>{}))),c.current=t.isExpanded}},[i,r,t.isExpanded,o]),n.useEffect(()=>()=>{l.current&&cancelAnimationFrame(l.current)},[]),{buttonProps:{id:s,"aria-expanded":t.isExpanded,"aria-controls":a,onPress:e=>{!i&&e.pointerType!=="keyboard"&&t.toggle()},isDisabled:i,onPressStart(e){e.pointerType==="keyboard"&&!i&&t.toggle()}},panelProps:{id:a,role:"group","aria-labelledby":s,"aria-hidden":!t.isExpanded,hidden:o||i?i||!t.isExpanded:void 0}}}function g(d){let[t,r]=$.$458b0a5536c1a7cf$export$40bfa8c7b0832715(d.isExpanded,d.defaultExpanded||!1,d.onExpandedChange);const i=n.useCallback(()=>{r(!0)},[r]),s=n.useCallback(()=>{r(!1)},[r]),a=n.useCallback(()=>{r(!t)},[r,t]);return{isExpanded:t,setExpanded:r,expand:i,collapse:s,toggle:a}}exports.$5e910fae8e128ead$export$6e3e27031a30522f=y;exports.$bf996d45f4a36925$export$3fcbf6e4407997e0=g;
//# sourceMappingURL=useDisclosureState-mIvoKolL.cjs.js.map
