import{r as s,e as b}from"./app-BwDemWQz.js";import{u as g}from"./Button-B-KWyoQR.js";var S=globalThis!=null&&globalThis.document?s.useLayoutEffect:()=>{};function U(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}var M=b[" useInsertionEffect ".trim().toString()]||S;function z({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,c,a]=O({defaultProp:t,onChange:n}),u=e!==void 0,f=u?e:o;{const d=s.useRef(e!==void 0);s.useEffect(()=>{const l=d.current;l!==u&&console.warn(`${r} is changing from ${l?"controlled":"uncontrolled"} to ${u?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=u},[u,r])}const i=s.useCallback(d=>{var l;if(u){const m=w(d)?d(e):d;m!==e&&((l=a.current)==null||l.call(a,m))}else c(d)},[u,e,c,a]);return[f,i]}function O({defaultProp:e,onChange:t}){const[n,r]=s.useState(e),o=s.useRef(n),c=s.useRef(t);return M(()=>{c.current=t},[t]),s.useEffect(()=>{var a;o.current!==n&&((a=c.current)==null||a.call(c,n),o.current=n)},[n,o]),[n,r,c]}function w(e){return typeof e=="function"}function C(e){const[t,n]=s.useState(void 0);return S(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const c=o[0];let a,u;if("borderBoxSize"in c){const f=c.borderBoxSize,i=Array.isArray(f)?f[0]:f;a=i.inlineSize,u=i.blockSize}else a=e.offsetWidth,u=e.offsetHeight;n({width:a,height:u})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function y(e,t){return s.useReducer((n,r)=>t[n][r]??n,e)}var R=e=>{const{present:t,children:n}=e,r=P(t),o=typeof n=="function"?n({present:r.isPresent}):s.Children.only(n),c=g(r.ref,T(o));return typeof n=="function"||r.isPresent?s.cloneElement(o,{ref:c}):null};R.displayName="Presence";function P(e){const[t,n]=s.useState(),r=s.useRef(null),o=s.useRef(e),c=s.useRef("none"),a=e?"mounted":"unmounted",[u,f]=y(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const i=A(r.current);c.current=u==="mounted"?i:"none"},[u]),S(()=>{const i=r.current,d=o.current;if(d!==e){const m=c.current,N=A(i);e?f("MOUNT"):N==="none"||(i==null?void 0:i.display)==="none"?f("UNMOUNT"):f(d&&m!==N?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,f]),S(()=>{if(t){let i;const d=t.ownerDocument.defaultView??window,l=N=>{const p=A(r.current).includes(CSS.escape(N.animationName));if(N.target===t&&p&&(f("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",i=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=N=>{N.target===t&&(c.current=A(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{d.clearTimeout(i),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:s.useCallback(i=>{r.current=i?getComputedStyle(i):null,n(i)},[])}}function A(e){return(e==null?void 0:e.animationName)||"none"}function T(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}export{R as P,C as a,z as b,U as c,S as u};
