Module 396533

1,331 characters · in no known chunk
Dependencies
Required by (3)
Lazily required by (0)none
Requires (3)
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(64700),i=n(311907),s=n(775602);function a(e){let{key:t,isExpanded:n,durationMs:a=100,minHeightOverride:o,maxHeightOverride:l,maxAnimationHeight:u}=e,c=(0,i.bG)([s.A],()=>s.A.useReducedMotion),[d,_]=r.useState(null),f=r.useCallback(()=>{},[]),p=c?f:_,h=r.useRef(null),m=r.useRef(null),E=r.useRef(t),g=r.useRef(a);g.current=a;let A=r.useRef(o);A.current=o;let I=r.useRef(l);I.current=l;let T=r.useRef(u);T.current=u;let[S,y]=r.useState(!1),v=r.useCallback(()=>y(!1),[]);return r.useLayoutEffect(()=>{void 0!==t&&(h.current=null,m.current=null,y(!1))},[t]),r.useLayoutEffect(()=>{if(null==d)return;let{height:e}=d.getBoundingClientRect();!n&&(null==h.current||e<h.current)&&(h.current=e),n&&(null==m.current||e>m.current)&&(m.current=e);let r=A.current??h.current,i=I.current??m.current,s=E.current!==t;if(E.current=t,null==r||null==i||s)return;let a=Math.min(T.current??i,i),o=n?r:a,l=n?a:r;if(o===l)return;y(!0),d.style.height=`${o}px`,d.style.transition="";let u=null;return u=requestAnimationFrame(()=>{u=null,d.style.height=`${l}px`,d.style.transition=`height ${g.current}ms ease-in-out`}),()=>null!=u?cancelAnimationFrame(u):void 0},[t,d,n]),r.useLayoutEffect(()=>{null==d||S||(d.style.height="",d.style.transition="")},[t,d,S]),{ref:p,isTransitioning:S,onTransitionEnd:v}}}