import{computePosition as e,offset as t,shift as n,flip as r,size as o,hide as i,arrow as u,limitShift as s}from"../node_modules/@floating-ui/dom/dist/floating-ui.dom.js";export{autoUpdate,platform}from"../node_modules/@floating-ui/dom/dist/floating-ui.dom.js";import*as f from"react";import{useLayoutEffect as a,useEffect as l}from"react";import{r as c}from"../../../react-dom/index.js";var d="undefined"!=typeof document?a:l;function m(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;0!=r--;)if(!m(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;0!=r--;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;0!=r--;){const n=o[r];if(("_owner"!==n||!e.$$typeof)&&!m(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function p(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function g(e,t){const n=p(e);return Math.round(t*n)/n}function y(e){const t=f.useRef(e);return d((()=>{t.current=e})),t}function w(t){void 0===t&&(t={});const{placement:n="bottom",strategy:r="absolute",middleware:o=[],platform:i,elements:{reference:u,floating:s}={},transform:a=!0,whileElementsMounted:l,open:w}=t,[h,x]=f.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[S,b]=f.useState(o);m(S,o)||b(o);const[P,R]=f.useState(null),[j,M]=f.useState(null),k=f.useCallback((e=>{e!==_.current&&(_.current=e,R(e))}),[]),v=f.useCallback((e=>{e!==A.current&&(A.current=e,M(e))}),[]),C=u||P,O=s||j,_=f.useRef(null),A=f.useRef(null),D=f.useRef(h),$=null!=l,z=y(l),E=y(i),F=y(w),U=f.useCallback((()=>{if(!_.current||!A.current)return;const t={placement:n,strategy:r,middleware:S};E.current&&(t.platform=E.current),e(_.current,A.current,t).then((e=>{const t={...e,isPositioned:!1!==F.current};V.current&&!m(D.current,t)&&(D.current=t,c.flushSync((()=>{x(t)})))}))}),[S,n,r,E,F]);d((()=>{!1===w&&D.current.isPositioned&&(D.current.isPositioned=!1,x((e=>({...e,isPositioned:!1}))))}),[w]);const V=f.useRef(!1);d((()=>(V.current=!0,()=>{V.current=!1})),[]),d((()=>{if(C&&(_.current=C),O&&(A.current=O),C&&O){if(z.current)return z.current(C,O,U);U()}}),[C,O,U,z,$]);const q=f.useMemo((()=>({reference:_,floating:A,setReference:k,setFloating:v})),[k,v]),B=f.useMemo((()=>({reference:C,floating:O})),[C,O]),G=f.useMemo((()=>{const e={position:r,left:0,top:0};if(!B.floating)return e;const t=g(B.floating,h.x),n=g(B.floating,h.y);return a?{...e,transform:"translate("+t+"px, "+n+"px)",...p(B.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:t,top:n}}),[r,a,B.floating,h.x,h.y]);return f.useMemo((()=>({...h,update:U,refs:q,elements:B,floatingStyles:G})),[h,U,q,B,G])}const h=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}="function"==typeof e?e(t):e;return n&&(o=n,{}.hasOwnProperty.call(o,"current"))?null!=n.current?u({element:n.current,padding:r}).fn(t):{}:n?u({element:n,padding:r}).fn(t):{};var o}}),x=(e,n)=>({...t(e),options:[e,n]}),S=(e,t)=>({...n(e),options:[e,t]}),b=(e,t)=>({...s(e),options:[e,t]}),P=(e,t)=>({...r(e),options:[e,t]}),R=(e,t)=>({...o(e),options:[e,t]}),j=(e,t)=>({...i(e),options:[e,t]}),M=(e,t)=>({...h(e),options:[e,t]});export{M as arrow,e as computePosition,P as flip,j as hide,b as limitShift,x as offset,S as shift,R as size,w as useFloating};
//# sourceMappingURL=floating-ui.react-dom.js.map
