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