const L=Math.min,v=Math.max,Z=Math.round,I=Math.floor,tt=t=>({x:t,y:t}),C={left:"right",right:"left",bottom:"top",top:"bottom"},D={start:"end",end:"start"};function et(t,e,n){return v(t,L(e,n))}function nt(t,e){return typeof t=="function"?t(e):t}function b(t){return t.split("-")[0]}function y(t){return t.split("-")[1]}function O(t){return t==="x"?"y":"x"}function M(t){return t==="y"?"height":"width"}const k=new Set(["top","bottom"]);function R(t){return k.has(b(t))?"y":"x"}function V(t){return O(R(t))}function ot(t,e,n){n===void 0&&(n=!1);const o=y(t),r=V(t),s=M(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=u(i)),[i,u(i)]}function rt(t){const e=u(t);return[l(t),e,l(e)]}function l(t){return t.replace(/start|end/g,e=>D[e])}const d=["left","right"],g=["right","left"],j=["top","bottom"],B=["bottom","top"];function F(t,e,n){switch(t){case"top":case"bottom":return n?e?g:d:e?d:g;case"left":case"right":return e?j:B;default:return[]}}function st(t,e,n,o){const r=y(t);let s=F(b(t),n==="start",o);return r&&(s=s.map(i=>i+"-"+r),e&&(s=s.concat(s.map(l)))),s}function u(t){return t.replace(/left|right|bottom|top/g,e=>C[e])}function H(t){return{top:0,right:0,bottom:0,left:0,...t}}function it(t){return typeof t!="number"?H(t):{top:t,right:t,bottom:t,left:t}}function ct(t){const{x:e,y:n,width:o,height:r}=t;return{width:o,height:r,top:n,left:e,right:e+o,bottom:n+r,x:e,y:n}}function a(){return typeof window<"u"}function m(t){return S(t)?(t.nodeName||"").toLowerCase():"#document"}function c(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function _(t){var e;return(e=(S(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function S(t){return a()?t instanceof Node||t instanceof c(t).Node:!1}function x(t){return a()?t instanceof Element||t instanceof c(t).Element:!1}function A(t){return a()?t instanceof HTMLElement||t instanceof c(t).HTMLElement:!1}function h(t){return!a()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof c(t).ShadowRoot}const W=new Set(["inline","contents"]);function E(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=P(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!W.has(r)}const X=new Set(["table","td","th"]);function at(t){return X.has(m(t))}const Y=[":popover-open",":modal"];function $(t){return Y.some(e=>{try{return t.matches(e)}catch{return!1}})}const q=["transform","translate","scale","rotate","perspective"],z=["transform","translate","scale","rotate","perspective","filter"],G=["paint","layout","strict","content"];function J(t){const e=K(),n=x(t)?P(t):t;return q.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||z.some(o=>(n.willChange||"").includes(o))||G.some(o=>(n.contain||"").includes(o))}function lt(t){let e=f(t);for(;A(e)&&!N(e);){if(J(e))return e;if($(e))return null;e=f(e)}return null}function K(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Q=new Set(["html","body","#document"]);function N(t){return Q.has(m(t))}function P(t){return c(t).getComputedStyle(t)}function ut(t){return x(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function f(t){if(m(t)==="html")return t;const e=t.assignedSlot||t.parentNode||h(t)&&t.host||_(t);return h(e)?e.host:e}function T(t){const e=f(t);return N(e)?t.ownerDocument?t.ownerDocument.body:t.body:A(e)&&E(e)?e:T(e)}function w(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=T(t),s=r===((o=t.ownerDocument)==null?void 0:o.body),i=c(r);if(s){const p=U(i);return e.concat(i,i.visualViewport||[],E(r)?r:[],p&&n?w(p):[])}return e.concat(r,w(r,[],n))}function U(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}export{J as A,lt as B,v as C,L as D,m as E,E as F,ut as G,U as H,I,K as J,R as a,u as b,rt as c,st as d,nt as e,ot as f,b as g,et as h,it as i,y as j,O as k,V as l,M as m,x as n,_ as o,w as p,P as q,ct as r,A as s,tt as t,Z as u,c as v,$ as w,f as x,N as y,at as z};
