import{rectToClientRect as t,arrow as e,autoPlacement as n,detectOverflow as o,flip as i,hide as r,inline as c,limitShift as l,offset as s,shift as f,size as u,computePosition as a}from"@floating-ui/core";const h=Math.min,d=Math.max,p=Math.round,g=Math.floor,m=t=>({x:t,y:t});function y(){return"undefined"!=typeof window}function w(t){return b(t)?(t.nodeName||"").toLowerCase():"#document"}function x(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function v(t){var e;return null==(e=(b(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function b(t){return!!y()&&(t instanceof Node||t instanceof x(t).Node)}function L(t){return!!y()&&(t instanceof Element||t instanceof x(t).Element)}function R(t){return!!y()&&(t instanceof HTMLElement||t instanceof x(t).HTMLElement)}function T(t){return!(!y()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof x(t).ShadowRoot)}function C(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=z(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&"inline"!==i&&"contents"!==i}function S(t){return/^(table|td|th)$/.test(w(t))}function E(t){try{if(t.matches(":popover-open"))return!0}catch(t){}try{return t.matches(":modal")}catch(t){return!1}}const F=/transform|translate|scale|rotate|perspective|filter/,D=/paint|layout|strict|content/,W=t=>!!t&&"none"!==t;let O;function H(t){const e=L(t)?z(t):t;return W(e.transform)||W(e.translate)||W(e.scale)||W(e.rotate)||W(e.perspective)||!M()&&(W(e.backdropFilter)||W(e.filter))||F.test(e.willChange||"")||D.test(e.contain||"")}function M(){return null==O&&(O="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),O}function P(t){return/^(html|body|#document)$/.test(w(t))}function z(t){return x(t).getComputedStyle(t)}function B(t){return L(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function V(t){if("html"===w(t))return t;const e=t.assignedSlot||t.parentNode||T(t)&&t.host||v(t);return T(e)?e.host:e}function A(t){const e=V(t);return P(e)?t.ownerDocument?t.ownerDocument.body:t.body:R(e)&&C(e)?e:A(e)}function N(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=A(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=x(i);if(r){const t=$(c);return e.concat(c,c.visualViewport||[],C(i)?i:[],t&&n?N(t):[])}return e.concat(i,N(i,[],n))}function $(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function k(t){const e=z(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=R(t),r=i?t.offsetWidth:n,c=i?t.offsetHeight:o,l=p(n)!==r||p(o)!==c;return l&&(n=r,o=c),{width:n,height:o,$:l}}function I(t){return L(t)?t:t.contextElement}function q(t){const e=I(t);if(!R(e))return m(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=k(e);let c=(r?p(n.width):n.width)/o,l=(r?p(n.height):n.height)/i;return c&&Number.isFinite(c)||(c=1),l&&Number.isFinite(l)||(l=1),{x:c,y:l}}const X=m(0);function Y(t){const e=x(t);return M()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:X}function _(e,n,o,i){void 0===n&&(n=!1),void 0===o&&(o=!1);const r=e.getBoundingClientRect(),c=I(e);let l=m(1);n&&(i?L(i)&&(l=q(i)):l=q(e));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==x(t))&&e}(c,o,i)?Y(c):m(0);let f=(r.left+s.x)/l.x,u=(r.top+s.y)/l.y,a=r.width/l.x,h=r.height/l.y;if(c){const t=x(c),e=i&&L(i)?x(i):i;let n=t,o=$(n);for(;o&&i&&e!==n;){const t=q(o),e=o.getBoundingClientRect(),i=z(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;f*=t.x,u*=t.y,a*=t.x,h*=t.y,f+=r,u+=c,n=x(o),o=$(n)}}return t({width:a,height:h,x:f,y:u})}function j(t,e){const n=B(t).scrollLeft;return e?e.left+n:_(v(t)).left+n}function G(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-j(t,n),y:n.top+e.scrollTop}}function J(e,n,o){let i;if("viewport"===n)i=function(t,e){const n=x(t),o=v(t),i=n.visualViewport;let r=o.clientWidth,c=o.clientHeight,l=0,s=0;if(i){r=i.width,c=i.height;const t=M();(!t||t&&"fixed"===e)&&(l=i.offsetLeft,s=i.offsetTop)}const f=j(o);if(f<=0){const t=o.ownerDocument,e=t.body,n=getComputedStyle(e),i="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,c=Math.abs(o.clientWidth-e.clientWidth-i);c<=25&&(r-=c)}else f<=25&&(r+=f);return{width:r,height:c,x:l,y:s}}(e,o);else if("document"===n)i=function(t){const e=v(t),n=B(t),o=t.ownerDocument.body,i=d(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=d(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let c=-n.scrollLeft+j(t);const l=-n.scrollTop;return"rtl"===z(o).direction&&(c+=d(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:c,y:l}}(v(e));else if(L(n))i=function(t,e){const n=_(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=R(t)?q(t):m(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(n,o);else{const t=Y(e);i={x:n.x-t.x,y:n.y-t.y,width:n.width,height:n.height}}return t(i)}function K(t,e){const n=V(t);return!(n===e||!L(n)||P(n))&&("fixed"===z(n).position||K(n,e))}function Q(t,e,n){const o=R(e),i=v(e),r="fixed"===n,c=_(t,!0,r,e);let l={scrollLeft:0,scrollTop:0};const s=m(0);function f(){s.x=j(i)}if(o||!o&&!r)if(("body"!==w(e)||C(i))&&(l=B(e)),o){const t=_(e,!0,r,e);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else i&&f();r&&!o&&i&&f();const u=!i||o||r?m(0):G(i,l);return{x:c.left+l.scrollLeft-s.x-u.x,y:c.top+l.scrollTop-s.y-u.y,width:c.width,height:c.height}}function U(t){return"static"===z(t).position}function Z(t,e){if(!R(t)||"fixed"===z(t).position)return null;if(e)return e(t);let n=t.offsetParent;return v(t)===n&&(n=n.ownerDocument.body),n}function tt(t,e){const n=x(t);if(E(t))return n;if(!R(t)){let e=V(t);for(;e&&!P(e);){if(L(e)&&!U(e))return e;e=V(e)}return n}let o=Z(t,e);for(;o&&S(o)&&U(o);)o=Z(o,e);return o&&P(o)&&U(o)&&!H(o)?n:o||function(t){let e=V(t);for(;R(e)&&!P(e);){if(H(e))return e;if(E(e))return null;e=V(e)}return null}(t)||n}const et={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,c=v(o),l=!!e&&E(e.floating);if(o===c||l&&r)return n;let s={scrollLeft:0,scrollTop:0},f=m(1);const u=m(0),a=R(o);if((a||!a&&!r)&&(("body"!==w(o)||C(c))&&(s=B(o)),a)){const t=_(o);f=q(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const h=!c||a||r?m(0):G(c,s);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-s.scrollLeft*f.x+u.x+h.x,y:n.y*f.y-s.scrollTop*f.y+u.y+h.y}},getDocumentElement:v,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[..."clippingAncestors"===n?E(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=N(t,[],!1).filter((t=>L(t)&&"body"!==w(t))),i=null;const r="fixed"===z(t).position;let c=r?V(t):t;for(;L(c)&&!P(c);){const e=z(c),n=H(c);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&("absolute"===i.position||"fixed"===i.position)||C(c)&&!n&&K(t,c))?o=o.filter((t=>t!==c)):i=e,c=V(c)}return e.set(t,o),o}(e,this._c):[].concat(n),o],c=J(e,r[0],i);let l=c.top,s=c.right,f=c.bottom,u=c.left;for(let t=1;t{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const a=f&&l?function(t,e){let n,o=null;const i=v(t);function r(){var t;clearTimeout(n),null==(t=o)||t.disconnect(),o=null}return function c(l,s){void 0===l&&(l=!1),void 0===s&&(s=1),r();const f=t.getBoundingClientRect(),{left:u,top:a,width:p,height:m}=f;if(l||e(),!p||!m)return;const y={rootMargin:-g(a)+"px "+-g(i.clientWidth-(u+p))+"px "+-g(i.clientHeight-(a+m))+"px "+-g(u)+"px",threshold:d(0,h(1,s))||1};let w=!0;function x(e){const o=e[0].intersectionRatio;if(o!==s){if(!w)return c();o?c(!1,o):n=setTimeout((()=>{c(!1,1e-7)}),1e3)}1!==o||nt(f,t.getBoundingClientRect())||c(),w=!1}try{o=new IntersectionObserver(x,{...y,root:i.ownerDocument})}catch(t){o=new IntersectionObserver(x,y)}o.observe(t)}(!0),r}(f,n):null;let p,m=-1,y=null;c&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===f&&y&&e&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{var t;null==(t=y)||t.observe(e)}))),n()})),f&&!s&&y.observe(f),e&&y.observe(e));let w=s?_(t):null;return s&&function e(){const o=_(t);w&&!nt(w,o)&&n();w=o,p=requestAnimationFrame(e)}(),n(),()=>{var t;u.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),null==a||a(),null==(t=y)||t.disconnect(),y=null,s&&cancelAnimationFrame(p)}}const it=o,rt=s,ct=n,lt=f,st=i,ft=u,ut=r,at=e,ht=c,dt=l,pt=(t,e,n)=>{const o=new Map,i={platform:et,...n},r={...i.platform,_c:o};return a(t,e,{...i,platform:r})};export{at as arrow,ct as autoPlacement,ot as autoUpdate,pt as computePosition,it as detectOverflow,st as flip,N as getOverflowAncestors,ut as hide,ht as inline,dt as limitShift,rt as offset,et as platform,lt as shift,ft as size};