import{f as I,s as J,c as K,o as N,h as Q,b as T,l as U}from"./vendor-floating-ui-dom-WyXykhNi.js";import{r,c as X}from"./vendor-react-BUCujlKS.js";var Y=typeof document<"u",Z=function(){},R=Y?r.useLayoutEffect:Z;function w(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!w(e[o],t[o]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,a[o]))return!1;for(o=n;o--!==0;){const p=a[o];if(!(p==="_owner"&&e.$$typeof)&&!w(e[p],t[p]))return!1}return!0}return e!==e&&t!==t}function z(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function O(e,t){const n=z(e);return Math.round(t*n)/n}function $(e){const t=r.useRef(e);return R(()=>{t.current=e}),t}function te(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:a,elements:{reference:p,floating:A}={},transform:k=!0,whileElementsMounted:D,open:x}=e,[f,C]=r.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[M,q]=r.useState(o);w(M,o)||q(o);const[B,V]=r.useState(null),[W,G]=r.useState(null),_=r.useCallback(s=>{s!==c.current&&(c.current=s,V(s))},[]),v=r.useCallback(s=>{s!==m.current&&(m.current=s,G(s))},[]),i=p||B,u=A||W,c=r.useRef(null),m=r.useRef(null),y=r.useRef(f),H=D!=null,S=$(D),P=$(a),F=$(x),g=r.useCallback(()=>{if(!c.current||!m.current)return;const s={placement:t,strategy:n,middleware:M};P.current&&(s.platform=P.current),K(c.current,m.current,s).then(h=>{const d={...h,isPositioned:F.current!==!1};E.current&&!w(y.current,d)&&(y.current=d,X.flushSync(()=>{C(d)}))})},[M,t,n,P,F]);R(()=>{x===!1&&y.current.isPositioned&&(y.current.isPositioned=!1,C(s=>({...s,isPositioned:!1})))},[x]);const E=r.useRef(!1);R(()=>(E.current=!0,()=>{E.current=!1}),[]),R(()=>{if(i&&(c.current=i),u&&(m.current=u),i&&u){if(S.current)return S.current(i,u,g);g()}},[i,u,g,S,H]);const j=r.useMemo(()=>({reference:c,floating:m,setReference:_,setFloating:v}),[_,v]),l=r.useMemo(()=>({reference:i,floating:u}),[i,u]),L=r.useMemo(()=>{const s={position:n,left:0,top:0};if(!l.floating)return s;const h=O(l.floating,f.x),d=O(l.floating,f.y);return k?{...s,transform:"translate("+h+"px, "+d+"px)",...z(l.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:h,top:d}},[n,k,l.floating,f.x,f.y]);return r.useMemo(()=>({...f,update:g,refs:j,elements:l,floatingStyles:L}),[f,g,j,l,L])}const ne=(e,t)=>{const n=N(e);return{name:n.name,fn:n.fn,options:[e,t]}},re=(e,t)=>{const n=T(e);return{name:n.name,fn:n.fn,options:[e,t]}},se=(e,t)=>({fn:U(e).fn,options:[e,t]}),oe=(e,t)=>{const n=I(e);return{name:n.name,fn:n.fn,options:[e,t]}},fe=(e,t)=>{const n=J(e);return{name:n.name,fn:n.fn,options:[e,t]}},ie=(e,t)=>{const n=Q(e);return{name:n.name,fn:n.fn,options:[e,t]}};export{re as a,oe as f,ie as h,se as l,ne as o,fe as s,te as u};
