🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@floating-ui/core

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@floating-ui/core - npm Package Compare versions

Comparing version
1.7.5
to
1.8.0
+1
-1
dist/floating-ui.core.browser.min.mjs

@@ -1,1 +0,1 @@

const t=["top","right","bottom","left"],e=["start","end"],n=t.reduce(((t,n)=>t.concat(n,n+"-"+e[0],n+"-"+e[1])),[]),r=Math.min,i=Math.max,o={left:"right",right:"left",bottom:"top",top:"bottom"};function a(t,e,n){return i(t,r(e,n))}function l(t,e){return"function"==typeof t?t(e):t}function s(t){return t.split("-")[0]}function c(t){return t.split("-")[1]}function f(t){return"x"===t?"y":"x"}function m(t){return"y"===t?"height":"width"}function u(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function d(t){return f(u(t))}function g(t,e,n){void 0===n&&(n=!1);const r=c(t),i=d(t),o=m(i);let a="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return e.reference[o]>e.floating[o]&&(a=b(a)),[a,b(a)]}function p(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const h=["left","right"],y=["right","left"],w=["top","bottom"],x=["bottom","top"];function v(t,e,n,r){const i=c(t);let o=function(t,e,n){switch(t){case"top":case"bottom":return n?e?y:h:e?h:y;case"left":case"right":return e?w:x;default:return[]}}(s(t),"start"===n,r);return i&&(o=o.map((t=>t+"-"+i)),e&&(o=o.concat(o.map(p)))),o}function b(t){const e=s(t);return o[e]+t.slice(e.length)}function A(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function R(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function O(t,e,n){let{reference:r,floating:i}=t;const o=u(e),a=d(e),l=m(a),f=s(e),g="y"===o,p=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,y=r[l]/2-i[l]/2;let w;switch(f){case"top":w={x:p,y:r.y-i.height};break;case"bottom":w={x:p,y:r.y+r.height};break;case"right":w={x:r.x+r.width,y:h};break;case"left":w={x:r.x-i.width,y:h};break;default:w={x:r.x,y:r.y}}switch(c(e)){case"start":w[a]-=y*(n&&g?-1:1);break;case"end":w[a]+=y*(n&&g?-1:1)}return w}async function D(t,e){var n;void 0===e&&(e={});const{x:r,y:i,platform:o,rects:a,elements:s,strategy:c}=t,{boundary:f="clippingAncestors",rootBoundary:m="viewport",elementContext:u="floating",altBoundary:d=!1,padding:g=0}=l(e,t),p=A(g),h=s[d?"floating"===u?"reference":"floating":u],y=R(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(h)))||n?h:h.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(s.floating)),boundary:f,rootBoundary:m,strategy:c})),w="floating"===u?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(s.floating)),v=await(null==o.isElement?void 0:o.isElement(x))&&await(null==o.getScale?void 0:o.getScale(x))||{x:1,y:1},b=R(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:w,offsetParent:x,strategy:c}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}const P=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:D},s=await(null==a.isRTL?void 0:a.isRTL(e));let c=await a.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:m}=O(c,r,s),u=r,d=0;const g={};for(let n=0;n<o.length;n++){const p=o[n];if(!p)continue;const{name:h,fn:y}=p,{x:w,y:x,data:v,reset:b}=await y({x:f,y:m,initialPlacement:r,placement:u,strategy:i,middlewareData:g,rects:c,platform:l,elements:{reference:t,floating:e}});f=null!=w?w:f,m=null!=x?x:m,g[h]={...g[h],...v},b&&d<50&&(d++,"object"==typeof b&&(b.placement&&(u=b.placement),b.rects&&(c=!0===b.rects?await a.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:m}=O(c,u,s))),n=-1)}return{x:f,y:m,placement:u,strategy:i,middlewareData:g}},E=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:o,rects:s,platform:f,elements:u,middlewareData:g}=e,{element:p,padding:h=0}=l(t,e)||{};if(null==p)return{};const y=A(h),w={x:n,y:i},x=d(o),v=m(x),b=await f.getDimensions(p),R="y"===x,O=R?"top":"left",D=R?"bottom":"right",P=R?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[x]-w[x]-s.floating[v],T=w[x]-s.reference[x],L=await(null==f.getOffsetParent?void 0:f.getOffsetParent(p));let k=L?L[P]:0;k&&await(null==f.isElement?void 0:f.isElement(L))||(k=u.floating[P]||s.floating[v]);const C=E/2-T/2,H=k/2-b[v]/2-1,B=r(y[O],H),S=r(y[D],H),F=B,M=k-b[v]-S,V=k/2-b[v]/2+C,W=a(F,V,M),j=!g.arrow&&null!=c(o)&&V!==W&&s.reference[v]/2-(V<F?B:S)-b[v]/2<0,z=j?V<F?V-F:V-M:0;return{[x]:w[x]+z,data:{[x]:W,centerOffset:V-W-z,...j&&{alignmentOffset:z}},reset:j}}});const T=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var r,i,o;const{rects:a,middlewareData:f,placement:m,platform:u,elements:d}=e,{crossAxis:h=!1,alignment:y,allowedPlacements:w=n,autoAlignment:x=!0,...v}=l(t,e),b=void 0!==y||w===n?function(t,e,n){return(t?[...n.filter((e=>c(e)===t)),...n.filter((e=>c(e)!==t))]:n.filter((t=>s(t)===t))).filter((n=>!t||c(n)===t||!!e&&p(n)!==n))}(y||null,x,w):w,A=await u.detectOverflow(e,v),R=(null==(r=f.autoPlacement)?void 0:r.index)||0,O=b[R];if(null==O)return{};const D=g(O,a,await(null==u.isRTL?void 0:u.isRTL(d.floating)));if(m!==O)return{reset:{placement:b[0]}};const P=[A[s(O)],A[D[0]],A[D[1]]],E=[...(null==(i=f.autoPlacement)?void 0:i.overflows)||[],{placement:O,overflows:P}],T=b[R+1];if(T)return{data:{index:R+1,overflows:E},reset:{placement:T}};const L=E.map((t=>{const e=c(t.placement);return[t.placement,e&&h?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(o=L.filter((t=>t[2].slice(0,c(t[0])?2:3).every((t=>t<=0))))[0])?void 0:o[0])||L[0][0];return k!==m?{data:{index:R+1,overflows:E},reset:{placement:k}}:{}}}},L=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:o,rects:a,initialPlacement:c,platform:f,elements:m}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:y,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:A=!0,...R}=l(t,e);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const O=s(i),D=u(c),P=s(c)===c,E=await(null==f.isRTL?void 0:f.isRTL(m.floating)),T=y||(P||!A?[b(c)]:function(t){const e=b(t);return[p(t),e,p(e)]}(c)),L="none"!==x;!y&&L&&T.push(...v(c,A,x,E));const k=[c,...T],C=await f.detectOverflow(e,R),H=[];let B=(null==(r=o.flip)?void 0:r.overflows)||[];if(d&&H.push(C[O]),h){const t=g(i,a,E);H.push(C[t[0]],C[t[1]])}if(B=[...B,{placement:i,overflows:H}],!H.every((t=>t<=0))){var S,F;const t=((null==(S=o.flip)?void 0:S.index)||0)+1,e=k[t];if(e){if(!("alignment"===h&&D!==u(e))||B.every((t=>u(t.placement)!==D||t.overflows[0]>0)))return{data:{index:t,overflows:B},reset:{placement:e}}}let n=null==(F=B.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(w){case"bestFit":{var M;const t=null==(M=B.filter((t=>{if(L){const e=u(t.placement);return e===D||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:M[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}}}};function k(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function C(e){return t.some((t=>e[t]>=0))}const H=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...o}=l(t,e);switch(i){case"referenceHidden":{const t=k(await r.detectOverflow(e,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:C(t)}}}case"escaped":{const t=k(await r.detectOverflow(e,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:C(t)}}}default:return{}}}}};function B(t){const e=r(...t.map((t=>t.left))),n=r(...t.map((t=>t.top)));return{x:e,y:n,width:i(...t.map((t=>t.right)))-e,height:i(...t.map((t=>t.bottom)))-n}}const S=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:o,rects:a,platform:c,strategy:f}=e,{padding:m=2,x:d,y:g}=l(t,e),p=Array.from(await(null==c.getClientRects?void 0:c.getClientRects(o.reference))||[]),h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let r=null;for(let t=0;t<e.length;t++){const i=e[t];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map((t=>R(B(t))))}(p),y=R(B(p)),w=A(m);const x=await c.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&h[0].left>h[1].right&&null!=d&&null!=g)return h.find((t=>d>t.left-w.left&&d<t.right+w.right&&g>t.top-w.top&&g<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===u(n)){const t=h[0],e=h[h.length-1],r="top"===s(n),i=t.top,o=e.bottom,a=r?t.left:e.left,l=r?t.right:e.right;return{top:i,bottom:o,left:a,right:l,width:l-a,height:o-i,x:a,y:i}}const t="left"===s(n),e=i(...h.map((t=>t.right))),o=r(...h.map((t=>t.left))),a=h.filter((n=>t?n.left===o:n.right===e)),l=a[0].top,c=a[a.length-1].bottom;return{top:l,bottom:c,left:o,right:e,width:e-o,height:c-l,x:o,y:l}}return y}},floating:o.floating,strategy:f});return a.reference.x!==x.reference.x||a.reference.y!==x.reference.y||a.reference.width!==x.reference.width||a.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},F=new Set(["left","top"]);const M=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:o,placement:a,middlewareData:f}=e,m=await async function(t,e){const{placement:n,platform:r,elements:i}=t,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),a=s(n),f=c(n),m="y"===u(n),d=F.has(a)?-1:1,g=o&&m?-1:1,p=l(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return f&&"number"==typeof w&&(y="end"===f?-1*w:w),m?{x:y*g,y:h*d}:{x:h*d,y:y*g}}(e,t);return a===(null==(n=f.offset)?void 0:n.placement)&&null!=(r=f.arrow)&&r.alignmentOffset?{}:{x:i+m.x,y:o+m.y,data:{...m,placement:a}}}}},V=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:o}=e,{mainAxis:c=!0,crossAxis:m=!1,limiter:d={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...g}=l(t,e),p={x:n,y:r},h=await o.detectOverflow(e,g),y=u(s(i)),w=f(y);let x=p[w],v=p[y];if(c){const t="y"===w?"bottom":"right";x=a(x+h["y"===w?"top":"left"],x,x-h[t])}if(m){const t="y"===y?"bottom":"right";v=a(v+h["y"===y?"top":"left"],v,v-h[t])}const b=d.fn({...e,[w]:x,[y]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[w]:c,[y]:m}}}}}},W=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:o,middlewareData:a}=e,{offset:c=0,mainAxis:m=!0,crossAxis:d=!0}=l(t,e),g={x:n,y:r},p=u(i),h=f(p);let y=g[h],w=g[p];const x=l(c,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(m){const t="y"===h?"height":"width",e=o.reference[h]-o.floating[t]+v.mainAxis,n=o.reference[h]+o.reference[t]-v.mainAxis;y<e?y=e:y>n&&(y=n)}if(d){var b,A;const t="y"===h?"width":"height",e=F.has(s(i)),n=o.reference[p]-o.floating[t]+(e&&(null==(b=a.offset)?void 0:b[p])||0)+(e?0:v.crossAxis),r=o.reference[p]+o.reference[t]+(e?0:(null==(A=a.offset)?void 0:A[p])||0)-(e?v.crossAxis:0);w<n?w=n:w>r&&(w=r)}return{[h]:y,[p]:w}}}},j=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var n,o;const{placement:a,rects:f,platform:m,elements:d}=e,{apply:g=()=>{},...p}=l(t,e),h=await m.detectOverflow(e,p),y=s(a),w=c(a),x="y"===u(a),{width:v,height:b}=f.floating;let A,R;"top"===y||"bottom"===y?(A=y,R=w===(await(null==m.isRTL?void 0:m.isRTL(d.floating))?"start":"end")?"left":"right"):(R=y,A="end"===w?"top":"bottom");const O=b-h.top-h.bottom,D=v-h.left-h.right,P=r(b-h[A],O),E=r(v-h[R],D),T=!e.middlewareData.shift;let L=P,k=E;if(null!=(n=e.middlewareData.shift)&&n.enabled.x&&(k=D),null!=(o=e.middlewareData.shift)&&o.enabled.y&&(L=O),T&&!w){const t=i(h.left,0),e=i(h.right,0),n=i(h.top,0),r=i(h.bottom,0);x?k=v-2*(0!==t||0!==e?t+e:i(h.left,h.right)):L=b-2*(0!==n||0!==r?n+r:i(h.top,h.bottom))}await g({...e,availableWidth:k,availableHeight:L});const C=await m.getDimensions(d.floating);return v!==C.width||b!==C.height?{reset:{rects:!0}}:{}}}};export{E as arrow,T as autoPlacement,P as computePosition,D as detectOverflow,L as flip,H as hide,S as inline,W as limitShift,M as offset,R as rectToClientRect,V as shift,j as size};
const t=["top","right","bottom","left"],e=["start","end"],n=t.reduce(((t,n)=>t.concat(n,n+"-"+e[0],n+"-"+e[1])),[]),r=Math.min,i=Math.max,o={left:"right",right:"left",bottom:"top",top:"bottom"};function l(t,e,n){return i(t,r(e,n))}function a(t,e){return"function"==typeof t?t(e):t}function s(t){return t.split("-")[0]}function c(t){return t.split("-")[1]}function f(t){return"x"===t?"y":"x"}function u(t){return"y"===t?"height":"width"}function m(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function d(t){return f(m(t))}function g(t,e,n){void 0===n&&(n=!1);const r=c(t),i=d(t),o=u(i);let l="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return e.reference[o]>e.floating[o]&&(l=b(l)),[l,b(l)]}function p(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const h=["left","right"],y=["right","left"],w=["top","bottom"],x=["bottom","top"];function v(t,e,n,r){const i=c(t);let o=function(t,e,n){switch(t){case"top":case"bottom":return n?e?y:h:e?h:y;case"left":case"right":return e?w:x;default:return[]}}(s(t),"start"===n,r);return i&&(o=o.map((t=>t+"-"+i)),e&&(o=o.concat(o.map(p)))),o}function b(t){const e=s(t);return o[e]+t.slice(e.length)}function A(t){return"number"!=typeof t?function(t){var e,n,r,i;return{top:null!=(e=t.top)?e:0,right:null!=(n=t.right)?n:0,bottom:null!=(r=t.bottom)?r:0,left:null!=(i=t.left)?i:0}}(t):{top:t,right:t,bottom:t,left:t}}function R(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function O(t,e,n){let{reference:r,floating:i}=t;const o=m(e),l=d(e),a=u(l),f=s(e),g="y"===o,p=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,y=r[a]/2-i[a]/2;let w;switch(f){case"top":w={x:p,y:r.y-i.height};break;case"bottom":w={x:p,y:r.y+r.height};break;case"right":w={x:r.x+r.width,y:h};break;case"left":w={x:r.x-i.width,y:h};break;default:w={x:r.x,y:r.y}}const x=c(e);return x&&(w[l]+=y*("end"===x?1:-1)*(n&&g?-1:1)),w}async function P(t,e){var n;void 0===e&&(e={});const{x:r,y:i,platform:o,rects:l,elements:s,strategy:c}=t,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:d=!1,padding:g=0}=a(e,t),p=A(g),h=s[d?"floating"===m?"reference":"floating":m],y=R(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(h)))||n?h:h.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(s.floating)),boundary:f,rootBoundary:u,strategy:c})),w="floating"===m?{x:r,y:i,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(s.floating)),v=await(null==o.isElement?void 0:o.isElement(x))&&await(null==o.getScale?void 0:o.getScale(x))||{x:1,y:1},b=R(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:w,offsetParent:x,strategy:c}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}const D=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:l}=n,a=l.detectOverflow?l:{...l,detectOverflow:P},s=await(null==l.isRTL?void 0:l.isRTL(e));let c=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=O(c,r,s),m=r,d=0;const g={};for(let n=0;n<o.length;n++){const p=o[n];if(!p)continue;const{name:h,fn:y}=p,{x:w,y:x,data:v,reset:b}=await y({x:f,y:u,initialPlacement:r,placement:m,strategy:i,middlewareData:g,rects:c,platform:a,elements:{reference:t,floating:e}});f=null!=w?w:f,u=null!=x?x:u,g[h]={...g[h],...v},b&&d<50&&(d++,"object"==typeof b&&(b.placement&&(m=b.placement),b.rects&&(c=!0===b.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:u}=O(c,m,s))),n=-1)}return{x:f,y:u,placement:m,strategy:i,middlewareData:g}},E=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:o,rects:s,platform:f,elements:m,middlewareData:g}=e,{element:p,padding:h=0}=a(t,e)||{};if(null==p)return{};const y=A(h),w={x:n,y:i},x=d(o),v=u(x),b=await f.getDimensions(p),R="y"===x,O=R?"top":"left",P=R?"bottom":"right",D=R?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[x]-w[x]-s.floating[v],T=w[x]-s.reference[x],L=await(null==f.getOffsetParent?void 0:f.getOffsetParent(p));let k=L?L[D]:0;k&&await(null==f.isElement?void 0:f.isElement(L))||(k=m.floating[D]||s.floating[v]);const C=E/2-T/2,H=k/2-b[v]/2-1,B=r(y[O],H),S=r(y[P],H),F=k-b[v]-S,M=k/2-b[v]/2+C,V=l(B,M,F),W=!g.arrow&&null!=c(o)&&M!==V&&s.reference[v]/2-(M<B?B:S)-b[v]/2<0,j=W?M<B?M-B:M-F:0;return{[x]:w[x]+j,data:{[x]:V,centerOffset:M-V-j,...W&&{alignmentOffset:j}},reset:W}}});const T=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var r,i,o;const{rects:l,middlewareData:f,placement:u,platform:m,elements:d}=e,{crossAxis:h=!1,alignment:y,allowedPlacements:w=n,autoAlignment:x=!0,...v}=a(t,e),b=void 0!==y||w===n?function(t,e,n){return(t?[...n.filter((e=>c(e)===t)),...n.filter((e=>c(e)!==t))]:n.filter((t=>s(t)===t))).filter((n=>!t||c(n)===t||!!e&&p(n)!==n))}(y||null,x,w):w,A=(null==(r=f.autoPlacement)?void 0:r.index)||0,R=b[A];if(null==R)return{};if(u!==R)return{reset:{placement:b[0]}};const O=await m.detectOverflow(e,v),P=g(R,l,await(null==m.isRTL?void 0:m.isRTL(d.floating))),D=[O[s(R)],O[P[0]],O[P[1]]],E=[...(null==(i=f.autoPlacement)?void 0:i.overflows)||[],{placement:R,overflows:D}],T=b[A+1];if(T)return{data:{index:A+1,overflows:E},reset:{placement:T}};const L=E.map((t=>{const e=c(t.placement);return[t.placement,e&&h?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(o=L.filter((t=>t[2].slice(0,c(t[0])?2:3).every((t=>t<=0))))[0])?void 0:o[0])||L[0][0];return k!==u?{data:{index:A+1,overflows:E},reset:{placement:k}}:{}}}},L=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:o,rects:l,initialPlacement:c,platform:f,elements:u}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:y,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:A=!0,...R}=a(t,e);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const O=s(i),P=m(c),D=s(c)===c,E=await(null==f.isRTL?void 0:f.isRTL(u.floating)),T=y||(D||!A?[b(c)]:function(t){const e=b(t);return[p(t),e,p(e)]}(c)),L="none"!==x;!y&&L&&T.push(...v(c,A,x,E));const k=[c,...T],C=await f.detectOverflow(e,R),H=[];let B=(null==(r=o.flip)?void 0:r.overflows)||[];if(d&&H.push(C[O]),h){const t=g(i,l,E);H.push(C[t[0]],C[t[1]])}if(B=[...B,{placement:i,overflows:H}],!H.every((t=>t<=0))){var S,F;const t=((null==(S=o.flip)?void 0:S.index)||0)+1,e=k[t];if(e){if(!("alignment"===h&&P!==m(e))||B.every((t=>m(t.placement)!==P||t.overflows[0]>0)))return{data:{index:t,overflows:B},reset:{placement:e}}}let n=null==(F=B.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(w){case"bestFit":{var M;const t=null==(M=B.filter((t=>{if(L){const e=m(t.placement);return e===P||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:M[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}}}};function k(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function C(e){return t.some((t=>e[t]>=0))}const H=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...o}=a(t,e);switch(i){case"referenceHidden":{const t=k(await r.detectOverflow(e,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:C(t)}}}case"escaped":{const t=k(await r.detectOverflow(e,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:C(t)}}}default:return{}}}}};function B(t){const e=r(...t.map((t=>t.left))),n=r(...t.map((t=>t.top)));return{x:e,y:n,width:i(...t.map((t=>t.right)))-e,height:i(...t.map((t=>t.bottom)))-n}}const S=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:o,rects:l,platform:c,strategy:f}=e,{padding:u=2,x:d,y:g}=a(t,e),p=Array.from(await(null==c.getClientRects?void 0:c.getClientRects(o.reference))||[]);if(!p.length)return{};const h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let r=null;for(let t=0;t<e.length;t++){const i=e[t];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map((t=>R(B(t))))}(p),y=R(B(p)),w=A(u);const x=await c.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&(h[0].left>h[1].right||h[1].left>h[0].right)&&null!=d&&null!=g)return h.find((t=>d>t.left-w.left&&d<t.right+w.right&&g>t.top-w.top&&g<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===m(n)){const t=h[0],e=h[h.length-1],r="top"===s(n),i=t.top,o=e.bottom,l=r?t.left:e.left;return R({x:l,y:i,width:(r?t.right:e.right)-l,height:o-i})}const t="left"===s(n),e=i(...h.map((t=>t.right))),o=r(...h.map((t=>t.left))),l=h.filter((n=>t?n.left===o:n.right===e)),a=l[0].top,c=l[l.length-1].bottom;return R({x:o,y:a,width:e-o,height:c-a})}return y}},floating:o.floating,strategy:f});return l.reference.x!==x.reference.x||l.reference.y!==x.reference.y||l.reference.width!==x.reference.width||l.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},F=new Set(["left","top"]);const M=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:o,placement:l,middlewareData:f}=e,u=await async function(t,e){const{placement:n,platform:r,elements:i}=t,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),l=s(n),f=c(n),u="y"===m(n),d=F.has(l)?-1:1,g=o&&u?-1:1,p=a(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return f&&"number"==typeof w&&(y="end"===f?-1*w:w),u?{x:y*g,y:h*d}:{x:h*d,y:y*g}}(e,t);return l===(null==(n=f.offset)?void 0:n.placement)&&null!=(r=f.arrow)&&r.alignmentOffset?{}:{x:i+u.x,y:o+u.y,data:{...u,placement:l}}}}},V=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:o}=e,{mainAxis:s=!0,crossAxis:c=!1,limiter:u={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...d}=a(t,e),g={x:n,y:r},p=await o.detectOverflow(e,d),h=m(i),y=f(h);let w=g[y],x=g[h];const v=(t,e)=>l(e+p["y"===t?"top":"left"],e,e-p["y"===t?"bottom":"right"]);s&&(w=v(y,w)),c&&(x=v(h,x));const b=u.fn({...e,[y]:w,[h]:x});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[y]:s,[h]:c}}}}}},W=function(t){return void 0===t&&(t={}),{options:t,fn(e){var n,r;const{x:i,y:o,placement:l,rects:c,middlewareData:u}=e,{offset:d=0,mainAxis:g=!0,crossAxis:p=!0}=a(t,e),h={x:i,y:o},y=m(l),w=f(y);let x=h[w],v=h[y];const b=a(d,e),A="number"==typeof b?{mainAxis:b,crossAxis:0}:{mainAxis:null!=(n=b.mainAxis)?n:0,crossAxis:null!=(r=b.crossAxis)?r:0};if(g){const t="y"===w?"height":"width",e=c.reference[w]-c.floating[t]+A.mainAxis,n=c.reference[w]+c.reference[t]-A.mainAxis;x<e?x=e:x>n&&(x=n)}if(p){var R,O;const t="y"===w?"width":"height",e=F.has(s(l)),n=c.reference[y]-c.floating[t]+(e&&(null==(R=u.offset)?void 0:R[y])||0)+(e?0:A.crossAxis),r=c.reference[y]+c.reference[t]+(e?0:(null==(O=u.offset)?void 0:O[y])||0)-(e?A.crossAxis:0);v<n?v=n:v>r&&(v=r)}return{[w]:x,[y]:v}}}},j=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:o,platform:l,elements:f}=e,{apply:u=()=>{},...d}=a(t,e),g=await l.detectOverflow(e,d),p=s(n),h=c(n),y="y"===m(n),{width:w,height:x}=o.floating;let v,b;"top"===p||"bottom"===p?(v=p,b=h===(await(null==l.isRTL?void 0:l.isRTL(f.floating))?"start":"end")?"left":"right"):(b=p,v="end"===h?"top":"bottom");const A=x-g.top-g.bottom,R=w-g.left-g.right,O=r(x-g[v],A),P=r(w-g[b],R),D=e.middlewareData.shift,E=!D;let T=O,L=P;null!=D&&D.enabled.x&&(L=R),null!=D&&D.enabled.y&&(T=A),E&&!h&&(y?L=w-2*i(g.left,g.right):T=x-2*i(g.top,g.bottom)),await u({...e,availableWidth:L,availableHeight:T});const k=await l.getDimensions(f.floating);return w!==k.width||x!==k.height?{reset:{rects:!0}}:{}}}};export{E as arrow,T as autoPlacement,D as computePosition,P as detectOverflow,L as flip,H as hide,S as inline,W as limitShift,M as offset,R as rectToClientRect,V as shift,j as size};

@@ -95,8 +95,8 @@ /**

function expandPaddingObject(padding) {
var _padding$top, _padding$right, _padding$bottom, _padding$left;
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...padding
top: (_padding$top = padding.top) != null ? _padding$top : 0,
right: (_padding$right = padding.right) != null ? _padding$right : 0,
bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
left: (_padding$left = padding.left) != null ? _padding$left : 0
};

@@ -176,9 +176,5 @@ }

}
switch (getAlignment(placement)) {
case 'start':
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
break;
case 'end':
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
break;
const alignment = getAlignment(placement);
if (alignment) {
coords[alignmentAxis] += commonAlign * (alignment === 'end' ? 1 : -1) * (rtl && isVertical ? -1 : 1);
}

@@ -232,8 +228,5 @@ return coords;

const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) && (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
};

@@ -409,6 +402,5 @@ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({

// point is outside the floating element's bounds.
const min$1 = minPadding;
const max = clientSize - arrowDimensions[length] - maxPadding;
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset = clamp(min$1, center, max);
const offset = clamp(minPadding, center, max);

@@ -419,4 +411,4 @@ // If the reference is small enough that the arrow's padding causes it to

// a single reset is performed when this is true.
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
return {

@@ -475,3 +467,2 @@ [axis]: coords[axis] + alignmentOffset,

const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;

@@ -482,3 +473,2 @@ const currentPlacement = placements$1[currentIndex];

}
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));

@@ -493,2 +483,4 @@ // Make `computeCoords` start from the right place.

}
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];

@@ -800,2 +792,9 @@ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {

const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
// No rects (e.g. a hidden or detached reference, or a collapsed range) —
// keep the existing reference rect rather than resetting to an invalid
// one with non-finite values.
if (!nativeClientRects.length) {
return {};
}
const clientRects = getRectsByLine(nativeClientRects);

@@ -806,3 +805,3 @@ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));

// There are two rects and they are disjoined.
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
if (clientRects.length === 2 && (clientRects[0].left > clientRects[1].right || clientRects[1].left > clientRects[0].right) && x != null && y != null) {
// Find the first rect in which the point is fully inside.

@@ -822,14 +821,8 @@ return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;

const right = isTop ? firstRect.right : lastRect.right;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
return rectToClientRect({
x: left,
y: top
};
y: top,
width: right - left,
height: bottom - top
});
}

@@ -842,16 +835,8 @@ const isLeftSide = getSide(placement) === 'left';

const bottom = measureRects[measureRects.length - 1].bottom;
const left = minLeft;
const right = maxRight;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
x: left,
y: top
};
return rectToClientRect({
x: minLeft,
y: top,
width: maxRight - minLeft,
height: bottom - top
});
}

@@ -1006,19 +991,12 @@ return fallback;

const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const crossAxis = getSideAxis(getSide(placement));
const crossAxis = getSideAxis(placement);
const mainAxis = getOppositeAxis(crossAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === 'y' ? 'top' : 'left'], coord, coord - overflow[axis === 'y' ? 'bottom' : 'right']);
if (checkMainAxis) {
const minSide = mainAxis === 'y' ? 'top' : 'left';
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
const min = mainAxisCoord + overflow[minSide];
const max = mainAxisCoord - overflow[maxSide];
mainAxisCoord = clamp(min, mainAxisCoord, max);
mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
}
if (checkCrossAxis) {
const minSide = crossAxis === 'y' ? 'top' : 'left';
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
const min = crossAxisCoord + overflow[minSide];
const max = crossAxisCoord - overflow[maxSide];
crossAxisCoord = clamp(min, crossAxisCoord, max);
crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
}

@@ -1054,2 +1032,3 @@ const limitedCoords = limiter.fn({

fn(state) {
var _rawOffset$mainAxis, _rawOffset$crossAxis;
const {

@@ -1080,5 +1059,4 @@ x,

} : {
mainAxis: 0,
crossAxis: 0,
...rawOffset
mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
};

@@ -1115,2 +1093,8 @@ if (checkMainAxis) {

// Method syntax keeps callback parameters bivariant, but expressing the
// explicit `| undefined` required by `exactOptionalPropertyTypes` needs
// property syntax, which is contravariant under `strictFunctionTypes`.
// Extracting the function from a method position restores that bivariance so
// consumers can still assign callbacks with narrower parameter types.
/**

@@ -1130,3 +1114,2 @@ * Provides data that allows you to change the size of the floating element —

async fn(state) {
var _state$middlewareData, _state$middlewareData2;
const {

@@ -1163,20 +1146,17 @@ placement,

const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
const noShift = !state.middlewareData.shift;
const shiftData = state.middlewareData.shift;
const noShift = !shiftData;
let availableHeight = overflowAvailableHeight;
let availableWidth = overflowAvailableWidth;
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
if (shiftData != null && shiftData.enabled.x) {
availableWidth = maximumClippingWidth;
}
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
if (shiftData != null && shiftData.enabled.y) {
availableHeight = maximumClippingHeight;
}
if (noShift && !alignment) {
const xMin = max(overflow.left, 0);
const xMax = max(overflow.right, 0);
const yMin = max(overflow.top, 0);
const yMax = max(overflow.bottom, 0);
if (isYAxis) {
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
availableWidth = width - 2 * max(overflow.left, overflow.right);
} else {
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
availableHeight = height - 2 * max(overflow.top, overflow.bottom);
}

@@ -1183,0 +1163,0 @@ }

@@ -40,3 +40,3 @@ import { AlignedPlacement } from '@floating-ui/utils';

*/
padding?: Padding;
padding?: Padding | undefined;
}

@@ -58,3 +58,3 @@

*/
crossAxis?: boolean;
crossAxis?: boolean | undefined;
/**

@@ -64,3 +64,3 @@ * Choose placements with a particular alignment.

*/
alignment?: Alignment | null;
alignment?: Alignment | null | undefined;
/**

@@ -71,3 +71,3 @@ * Whether to choose placements with the opposite alignment if the preferred

*/
autoAlignment?: boolean;
autoAlignment?: boolean | undefined;
/**

@@ -78,3 +78,3 @@ * Which placements are allowed to be chosen. Placements must be within the

*/
allowedPlacements?: Array<Placement>;
allowedPlacements?: Array<Placement> | undefined;
}

@@ -84,2 +84,6 @@

declare type BivariantCallback<T extends (...args: any[]) => any> = {
bivariance(...args: Parameters<T>): ReturnType<T>;
}['bivariance'];
export declare type Boundary = any;

@@ -108,7 +112,7 @@

*/
placement?: Placement;
placement?: Placement | undefined;
/**
* The strategy to use when positioning the floating element.
*/
strategy?: Strategy;
strategy?: Strategy | undefined;
/**

@@ -118,3 +122,3 @@ * Array of middleware objects to modify the positioning or provide data for

*/
middleware?: Array<Middleware | null | undefined | false>;
middleware?: Array<Middleware | null | undefined | false> | undefined;
}

@@ -159,3 +163,3 @@

*/
boundary?: Boundary;
boundary?: Boundary | undefined;
/**

@@ -165,3 +169,3 @@ * The root clipping area in which overflow will be checked.

*/
rootBoundary?: RootBoundary;
rootBoundary?: RootBoundary | undefined;
/**

@@ -171,3 +175,3 @@ * The element in which overflow is being checked relative to a boundary.

*/
elementContext?: ElementContext;
elementContext?: ElementContext | undefined;
/**

@@ -178,3 +182,3 @@ * Whether to check for overflow using the alternate element's boundary

*/
altBoundary?: boolean;
altBoundary?: boolean | undefined;
/**

@@ -184,3 +188,3 @@ * Virtual padding for the resolved overflow detection offsets.

*/
padding?: Padding;
padding?: Padding | undefined;
}

@@ -213,3 +217,3 @@

*/
mainAxis?: boolean;
mainAxis?: boolean | undefined;
/**

@@ -223,3 +227,3 @@ * The axis that runs along the alignment of the floating element. Determines

*/
crossAxis?: boolean | 'alignment';
crossAxis?: boolean | 'alignment' | undefined;
/**

@@ -229,3 +233,3 @@ * Placements to try sequentially if the preferred `placement` does not fit.

*/
fallbackPlacements?: Array<Placement>;
fallbackPlacements?: Array<Placement> | undefined;
/**

@@ -235,3 +239,3 @@ * What strategy to use when no placements fit.

*/
fallbackStrategy?: 'bestFit' | 'initialPlacement';
fallbackStrategy?: 'bestFit' | 'initialPlacement' | undefined;
/**

@@ -242,3 +246,3 @@ * Whether to allow fallback to the perpendicular axis of the preferred

*/
fallbackAxisSideDirection?: 'none' | 'start' | 'end';
fallbackAxisSideDirection?: 'none' | 'start' | 'end' | undefined;
/**

@@ -249,3 +253,3 @@ * Whether to flip to placements with the opposite alignment if they fit

*/
flipAlignment?: boolean;
flipAlignment?: boolean | undefined;
}

@@ -266,3 +270,3 @@

*/
strategy?: 'referenceHidden' | 'escaped';
strategy?: 'referenceHidden' | 'escaped' | undefined;
}

@@ -282,3 +286,3 @@

*/
x?: number;
x?: number | undefined;
/**

@@ -288,3 +292,3 @@ * Viewport-relative `y` coordinate to choose a `ClientRect`.

*/
y?: number;
y?: number | undefined;
/**

@@ -294,3 +298,3 @@ * Represents the padding around a disjoined rect when choosing it.

*/
padding?: Padding;
padding?: Padding | undefined;
}

@@ -313,3 +317,3 @@

*/
mainAxis?: number;
mainAxis?: number | undefined;
/**

@@ -319,3 +323,3 @@ * Offset the limiting of the axis that runs along the side of the

*/
crossAxis?: number;
crossAxis?: number | undefined;
};

@@ -330,3 +334,3 @@

*/
offset?: LimitShiftOffset | Derivable<LimitShiftOffset>;
offset?: LimitShiftOffset | Derivable<LimitShiftOffset> | undefined;
/**

@@ -336,7 +340,7 @@ * Whether to limit the axis that runs along the alignment of the floating

*/
mainAxis?: boolean;
mainAxis?: boolean | undefined;
/**
* Whether to limit the axis that runs along the side of the floating element.
*/
crossAxis?: boolean;
crossAxis?: boolean | undefined;
}

@@ -357,8 +361,8 @@

[key: string]: any;
arrow?: Partial<Coords> & {
arrow?: (Partial<Coords> & {
centerOffset: number;
alignmentOffset?: number;
};
alignmentOffset?: number | undefined;
}) | undefined;
autoPlacement?: {
index?: number;
index?: number | undefined;
overflows: Array<{

@@ -368,5 +372,5 @@ placement: Placement;

}>;
};
} | undefined;
flip?: {
index?: number;
index?: number | undefined;
overflows: Array<{

@@ -376,17 +380,17 @@ placement: Placement;

}>;
};
} | undefined;
hide?: {
referenceHidden?: boolean;
escaped?: boolean;
referenceHiddenOffsets?: SideObject;
escapedOffsets?: SideObject;
};
offset?: Coords & {
referenceHidden?: boolean | undefined;
escaped?: boolean | undefined;
referenceHiddenOffsets?: SideObject | undefined;
escapedOffsets?: SideObject | undefined;
} | undefined;
offset?: (Coords & {
placement: Placement;
};
shift?: Coords & {
}) | undefined;
shift?: (Coords & {
enabled: {
[key in Axis]: boolean;
};
};
}) | undefined;
}

@@ -397,7 +401,7 @@

[key: string]: any;
};
} | undefined;
reset?: boolean | {
placement?: Placement;
rects?: boolean | ElementRects;
};
placement?: Placement | undefined;
rects?: boolean | ElementRects | undefined;
} | undefined;
}

@@ -435,3 +439,3 @@

*/
mainAxis?: number;
mainAxis?: number | undefined;
/**

@@ -442,3 +446,3 @@ * The axis that runs along the alignment of the floating element.

*/
crossAxis?: number;
crossAxis?: number | undefined;
/**

@@ -454,3 +458,3 @@ * The same axis as `crossAxis` but applies only to aligned placements

*/
alignmentAxis?: number | null;
alignmentAxis?: number | null | undefined;
};

@@ -479,18 +483,18 @@

getDimensions: (element: any) => Promisable<Dimensions>;
convertOffsetParentRelativeRectToViewportRelativeRect?: (args: {
elements?: Elements;
convertOffsetParentRelativeRectToViewportRelativeRect?: ((args: {
elements?: Elements | undefined;
rect: Rect;
offsetParent: any;
strategy: Strategy;
}) => Promisable<Rect>;
getOffsetParent?: (element: any) => Promisable<any>;
isElement?: (value: any) => Promisable<boolean>;
getDocumentElement?: (element: any) => Promisable<any>;
getClientRects?: (element: any) => Promisable<Array<ClientRectObject>>;
isRTL?: (element: any) => Promisable<boolean>;
getScale?: (element: any) => Promisable<{
}) => Promisable<Rect>) | undefined;
getOffsetParent?: ((element: any) => Promisable<any>) | undefined;
isElement?: ((value: any) => Promisable<boolean>) | undefined;
getDocumentElement?: ((element: any) => Promisable<any>) | undefined;
getClientRects?: ((element: any) => Promisable<Array<ClientRectObject>>) | undefined;
isRTL?: ((element: any) => Promisable<boolean>) | undefined;
getScale?: ((element: any) => Promisable<{
x: number;
y: number;
}>;
detectOverflow?: typeof detectOverflow;
}>) | undefined;
detectOverflow?: typeof detectOverflow | undefined;
}

@@ -506,3 +510,3 @@

export declare type RootBoundary = 'viewport' | 'document' | Rect;
export declare type RootBoundary = 'viewport' | 'layoutViewport' | 'document' | Rect;

@@ -522,3 +526,3 @@ /**

*/
mainAxis?: boolean;
mainAxis?: boolean | undefined;
/**

@@ -529,3 +533,3 @@ * The axis that runs along the side of the floating element. Determines

*/
crossAxis?: boolean;
crossAxis?: boolean | undefined;
/**

@@ -538,3 +542,3 @@ * Accepts a function that limits the shifting done in order to prevent

options?: any;
};
} | undefined;
}

@@ -560,6 +564,6 @@

*/
apply?(args: MiddlewareState & {
apply?: BivariantCallback<(args: MiddlewareState & {
availableWidth: number;
availableHeight: number;
}): void | Promise<void>;
}) => void | Promise<void>> | undefined;
}

@@ -566,0 +570,0 @@

@@ -40,3 +40,3 @@ import { AlignedPlacement } from '@floating-ui/utils';

*/
padding?: Padding;
padding?: Padding | undefined;
}

@@ -58,3 +58,3 @@

*/
crossAxis?: boolean;
crossAxis?: boolean | undefined;
/**

@@ -64,3 +64,3 @@ * Choose placements with a particular alignment.

*/
alignment?: Alignment | null;
alignment?: Alignment | null | undefined;
/**

@@ -71,3 +71,3 @@ * Whether to choose placements with the opposite alignment if the preferred

*/
autoAlignment?: boolean;
autoAlignment?: boolean | undefined;
/**

@@ -78,3 +78,3 @@ * Which placements are allowed to be chosen. Placements must be within the

*/
allowedPlacements?: Array<Placement>;
allowedPlacements?: Array<Placement> | undefined;
}

@@ -84,2 +84,6 @@

declare type BivariantCallback<T extends (...args: any[]) => any> = {
bivariance(...args: Parameters<T>): ReturnType<T>;
}['bivariance'];
export declare type Boundary = any;

@@ -108,7 +112,7 @@

*/
placement?: Placement;
placement?: Placement | undefined;
/**
* The strategy to use when positioning the floating element.
*/
strategy?: Strategy;
strategy?: Strategy | undefined;
/**

@@ -118,3 +122,3 @@ * Array of middleware objects to modify the positioning or provide data for

*/
middleware?: Array<Middleware | null | undefined | false>;
middleware?: Array<Middleware | null | undefined | false> | undefined;
}

@@ -159,3 +163,3 @@

*/
boundary?: Boundary;
boundary?: Boundary | undefined;
/**

@@ -165,3 +169,3 @@ * The root clipping area in which overflow will be checked.

*/
rootBoundary?: RootBoundary;
rootBoundary?: RootBoundary | undefined;
/**

@@ -171,3 +175,3 @@ * The element in which overflow is being checked relative to a boundary.

*/
elementContext?: ElementContext;
elementContext?: ElementContext | undefined;
/**

@@ -178,3 +182,3 @@ * Whether to check for overflow using the alternate element's boundary

*/
altBoundary?: boolean;
altBoundary?: boolean | undefined;
/**

@@ -184,3 +188,3 @@ * Virtual padding for the resolved overflow detection offsets.

*/
padding?: Padding;
padding?: Padding | undefined;
}

@@ -213,3 +217,3 @@

*/
mainAxis?: boolean;
mainAxis?: boolean | undefined;
/**

@@ -223,3 +227,3 @@ * The axis that runs along the alignment of the floating element. Determines

*/
crossAxis?: boolean | 'alignment';
crossAxis?: boolean | 'alignment' | undefined;
/**

@@ -229,3 +233,3 @@ * Placements to try sequentially if the preferred `placement` does not fit.

*/
fallbackPlacements?: Array<Placement>;
fallbackPlacements?: Array<Placement> | undefined;
/**

@@ -235,3 +239,3 @@ * What strategy to use when no placements fit.

*/
fallbackStrategy?: 'bestFit' | 'initialPlacement';
fallbackStrategy?: 'bestFit' | 'initialPlacement' | undefined;
/**

@@ -242,3 +246,3 @@ * Whether to allow fallback to the perpendicular axis of the preferred

*/
fallbackAxisSideDirection?: 'none' | 'start' | 'end';
fallbackAxisSideDirection?: 'none' | 'start' | 'end' | undefined;
/**

@@ -249,3 +253,3 @@ * Whether to flip to placements with the opposite alignment if they fit

*/
flipAlignment?: boolean;
flipAlignment?: boolean | undefined;
}

@@ -266,3 +270,3 @@

*/
strategy?: 'referenceHidden' | 'escaped';
strategy?: 'referenceHidden' | 'escaped' | undefined;
}

@@ -282,3 +286,3 @@

*/
x?: number;
x?: number | undefined;
/**

@@ -288,3 +292,3 @@ * Viewport-relative `y` coordinate to choose a `ClientRect`.

*/
y?: number;
y?: number | undefined;
/**

@@ -294,3 +298,3 @@ * Represents the padding around a disjoined rect when choosing it.

*/
padding?: Padding;
padding?: Padding | undefined;
}

@@ -313,3 +317,3 @@

*/
mainAxis?: number;
mainAxis?: number | undefined;
/**

@@ -319,3 +323,3 @@ * Offset the limiting of the axis that runs along the side of the

*/
crossAxis?: number;
crossAxis?: number | undefined;
};

@@ -330,3 +334,3 @@

*/
offset?: LimitShiftOffset | Derivable<LimitShiftOffset>;
offset?: LimitShiftOffset | Derivable<LimitShiftOffset> | undefined;
/**

@@ -336,7 +340,7 @@ * Whether to limit the axis that runs along the alignment of the floating

*/
mainAxis?: boolean;
mainAxis?: boolean | undefined;
/**
* Whether to limit the axis that runs along the side of the floating element.
*/
crossAxis?: boolean;
crossAxis?: boolean | undefined;
}

@@ -357,8 +361,8 @@

[key: string]: any;
arrow?: Partial<Coords> & {
arrow?: (Partial<Coords> & {
centerOffset: number;
alignmentOffset?: number;
};
alignmentOffset?: number | undefined;
}) | undefined;
autoPlacement?: {
index?: number;
index?: number | undefined;
overflows: Array<{

@@ -368,5 +372,5 @@ placement: Placement;

}>;
};
} | undefined;
flip?: {
index?: number;
index?: number | undefined;
overflows: Array<{

@@ -376,17 +380,17 @@ placement: Placement;

}>;
};
} | undefined;
hide?: {
referenceHidden?: boolean;
escaped?: boolean;
referenceHiddenOffsets?: SideObject;
escapedOffsets?: SideObject;
};
offset?: Coords & {
referenceHidden?: boolean | undefined;
escaped?: boolean | undefined;
referenceHiddenOffsets?: SideObject | undefined;
escapedOffsets?: SideObject | undefined;
} | undefined;
offset?: (Coords & {
placement: Placement;
};
shift?: Coords & {
}) | undefined;
shift?: (Coords & {
enabled: {
[key in Axis]: boolean;
};
};
}) | undefined;
}

@@ -397,7 +401,7 @@

[key: string]: any;
};
} | undefined;
reset?: boolean | {
placement?: Placement;
rects?: boolean | ElementRects;
};
placement?: Placement | undefined;
rects?: boolean | ElementRects | undefined;
} | undefined;
}

@@ -435,3 +439,3 @@

*/
mainAxis?: number;
mainAxis?: number | undefined;
/**

@@ -442,3 +446,3 @@ * The axis that runs along the alignment of the floating element.

*/
crossAxis?: number;
crossAxis?: number | undefined;
/**

@@ -454,3 +458,3 @@ * The same axis as `crossAxis` but applies only to aligned placements

*/
alignmentAxis?: number | null;
alignmentAxis?: number | null | undefined;
};

@@ -479,18 +483,18 @@

getDimensions: (element: any) => Promisable<Dimensions>;
convertOffsetParentRelativeRectToViewportRelativeRect?: (args: {
elements?: Elements;
convertOffsetParentRelativeRectToViewportRelativeRect?: ((args: {
elements?: Elements | undefined;
rect: Rect;
offsetParent: any;
strategy: Strategy;
}) => Promisable<Rect>;
getOffsetParent?: (element: any) => Promisable<any>;
isElement?: (value: any) => Promisable<boolean>;
getDocumentElement?: (element: any) => Promisable<any>;
getClientRects?: (element: any) => Promisable<Array<ClientRectObject>>;
isRTL?: (element: any) => Promisable<boolean>;
getScale?: (element: any) => Promisable<{
}) => Promisable<Rect>) | undefined;
getOffsetParent?: ((element: any) => Promisable<any>) | undefined;
isElement?: ((value: any) => Promisable<boolean>) | undefined;
getDocumentElement?: ((element: any) => Promisable<any>) | undefined;
getClientRects?: ((element: any) => Promisable<Array<ClientRectObject>>) | undefined;
isRTL?: ((element: any) => Promisable<boolean>) | undefined;
getScale?: ((element: any) => Promisable<{
x: number;
y: number;
}>;
detectOverflow?: typeof detectOverflow;
}>) | undefined;
detectOverflow?: typeof detectOverflow | undefined;
}

@@ -506,3 +510,3 @@

export declare type RootBoundary = 'viewport' | 'document' | Rect;
export declare type RootBoundary = 'viewport' | 'layoutViewport' | 'document' | Rect;

@@ -522,3 +526,3 @@ /**

*/
mainAxis?: boolean;
mainAxis?: boolean | undefined;
/**

@@ -529,3 +533,3 @@ * The axis that runs along the side of the floating element. Determines

*/
crossAxis?: boolean;
crossAxis?: boolean | undefined;
/**

@@ -538,3 +542,3 @@ * Accepts a function that limits the shifting done in order to prevent

options?: any;
};
} | undefined;
}

@@ -560,6 +564,6 @@

*/
apply?(args: MiddlewareState & {
apply?: BivariantCallback<(args: MiddlewareState & {
availableWidth: number;
availableHeight: number;
}): void | Promise<void>;
}) => void | Promise<void>> | undefined;
}

@@ -566,0 +570,0 @@

@@ -49,9 +49,5 @@ import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils';

}
switch (getAlignment(placement)) {
case 'start':
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
break;
case 'end':
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
break;
const alignment = getAlignment(placement);
if (alignment) {
coords[alignmentAxis] += commonAlign * (alignment === 'end' ? 1 : -1) * (rtl && isVertical ? -1 : 1);
}

@@ -105,8 +101,5 @@ return coords;

const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) && (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
};

@@ -282,6 +275,5 @@ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({

// point is outside the floating element's bounds.
const min$1 = minPadding;
const max = clientSize - arrowDimensions[length] - maxPadding;
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset = clamp(min$1, center, max);
const offset = clamp(minPadding, center, max);

@@ -292,4 +284,4 @@ // If the reference is small enough that the arrow's padding causes it to

// a single reset is performed when this is true.
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
return {

@@ -348,3 +340,2 @@ [axis]: coords[axis] + alignmentOffset,

const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;

@@ -355,3 +346,2 @@ const currentPlacement = placements$1[currentIndex];

}
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));

@@ -366,2 +356,4 @@ // Make `computeCoords` start from the right place.

}
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];

@@ -673,2 +665,9 @@ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {

const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
// No rects (e.g. a hidden or detached reference, or a collapsed range) —
// keep the existing reference rect rather than resetting to an invalid
// one with non-finite values.
if (!nativeClientRects.length) {
return {};
}
const clientRects = getRectsByLine(nativeClientRects);

@@ -679,3 +678,3 @@ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));

// There are two rects and they are disjoined.
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
if (clientRects.length === 2 && (clientRects[0].left > clientRects[1].right || clientRects[1].left > clientRects[0].right) && x != null && y != null) {
// Find the first rect in which the point is fully inside.

@@ -695,14 +694,8 @@ return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;

const right = isTop ? firstRect.right : lastRect.right;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
return rectToClientRect({
x: left,
y: top
};
y: top,
width: right - left,
height: bottom - top
});
}

@@ -715,16 +708,8 @@ const isLeftSide = getSide(placement) === 'left';

const bottom = measureRects[measureRects.length - 1].bottom;
const left = minLeft;
const right = maxRight;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
x: left,
y: top
};
return rectToClientRect({
x: minLeft,
y: top,
width: maxRight - minLeft,
height: bottom - top
});
}

@@ -879,19 +864,12 @@ return fallback;

const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const crossAxis = getSideAxis(getSide(placement));
const crossAxis = getSideAxis(placement);
const mainAxis = getOppositeAxis(crossAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === 'y' ? 'top' : 'left'], coord, coord - overflow[axis === 'y' ? 'bottom' : 'right']);
if (checkMainAxis) {
const minSide = mainAxis === 'y' ? 'top' : 'left';
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
const min = mainAxisCoord + overflow[minSide];
const max = mainAxisCoord - overflow[maxSide];
mainAxisCoord = clamp(min, mainAxisCoord, max);
mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
}
if (checkCrossAxis) {
const minSide = crossAxis === 'y' ? 'top' : 'left';
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
const min = crossAxisCoord + overflow[minSide];
const max = crossAxisCoord - overflow[maxSide];
crossAxisCoord = clamp(min, crossAxisCoord, max);
crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
}

@@ -927,2 +905,3 @@ const limitedCoords = limiter.fn({

fn(state) {
var _rawOffset$mainAxis, _rawOffset$crossAxis;
const {

@@ -953,5 +932,4 @@ x,

} : {
mainAxis: 0,
crossAxis: 0,
...rawOffset
mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
};

@@ -988,2 +966,8 @@ if (checkMainAxis) {

// Method syntax keeps callback parameters bivariant, but expressing the
// explicit `| undefined` required by `exactOptionalPropertyTypes` needs
// property syntax, which is contravariant under `strictFunctionTypes`.
// Extracting the function from a method position restores that bivariance so
// consumers can still assign callbacks with narrower parameter types.
/**

@@ -1003,3 +987,2 @@ * Provides data that allows you to change the size of the floating element —

async fn(state) {
var _state$middlewareData, _state$middlewareData2;
const {

@@ -1036,20 +1019,17 @@ placement,

const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
const noShift = !state.middlewareData.shift;
const shiftData = state.middlewareData.shift;
const noShift = !shiftData;
let availableHeight = overflowAvailableHeight;
let availableWidth = overflowAvailableWidth;
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
if (shiftData != null && shiftData.enabled.x) {
availableWidth = maximumClippingWidth;
}
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
if (shiftData != null && shiftData.enabled.y) {
availableHeight = maximumClippingHeight;
}
if (noShift && !alignment) {
const xMin = max(overflow.left, 0);
const xMax = max(overflow.right, 0);
const yMin = max(overflow.top, 0);
const yMax = max(overflow.bottom, 0);
if (isYAxis) {
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
availableWidth = width - 2 * max(overflow.left, overflow.right);
} else {
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
availableHeight = height - 2 * max(overflow.top, overflow.bottom);
}

@@ -1056,0 +1036,0 @@ }

@@ -49,9 +49,5 @@ import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils';

}
switch (getAlignment(placement)) {
case 'start':
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
break;
case 'end':
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
break;
const alignment = getAlignment(placement);
if (alignment) {
coords[alignmentAxis] += commonAlign * (alignment === 'end' ? 1 : -1) * (rtl && isVertical ? -1 : 1);
}

@@ -105,8 +101,5 @@ return coords;

const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) && (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
};

@@ -282,6 +275,5 @@ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({

// point is outside the floating element's bounds.
const min$1 = minPadding;
const max = clientSize - arrowDimensions[length] - maxPadding;
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset = clamp(min$1, center, max);
const offset = clamp(minPadding, center, max);

@@ -292,4 +284,4 @@ // If the reference is small enough that the arrow's padding causes it to

// a single reset is performed when this is true.
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
return {

@@ -348,3 +340,2 @@ [axis]: coords[axis] + alignmentOffset,

const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;

@@ -355,3 +346,2 @@ const currentPlacement = placements$1[currentIndex];

}
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));

@@ -366,2 +356,4 @@ // Make `computeCoords` start from the right place.

}
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];

@@ -673,2 +665,9 @@ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {

const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
// No rects (e.g. a hidden or detached reference, or a collapsed range) —
// keep the existing reference rect rather than resetting to an invalid
// one with non-finite values.
if (!nativeClientRects.length) {
return {};
}
const clientRects = getRectsByLine(nativeClientRects);

@@ -679,3 +678,3 @@ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));

// There are two rects and they are disjoined.
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
if (clientRects.length === 2 && (clientRects[0].left > clientRects[1].right || clientRects[1].left > clientRects[0].right) && x != null && y != null) {
// Find the first rect in which the point is fully inside.

@@ -695,14 +694,8 @@ return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;

const right = isTop ? firstRect.right : lastRect.right;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
return rectToClientRect({
x: left,
y: top
};
y: top,
width: right - left,
height: bottom - top
});
}

@@ -715,16 +708,8 @@ const isLeftSide = getSide(placement) === 'left';

const bottom = measureRects[measureRects.length - 1].bottom;
const left = minLeft;
const right = maxRight;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
x: left,
y: top
};
return rectToClientRect({
x: minLeft,
y: top,
width: maxRight - minLeft,
height: bottom - top
});
}

@@ -879,19 +864,12 @@ return fallback;

const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const crossAxis = getSideAxis(getSide(placement));
const crossAxis = getSideAxis(placement);
const mainAxis = getOppositeAxis(crossAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === 'y' ? 'top' : 'left'], coord, coord - overflow[axis === 'y' ? 'bottom' : 'right']);
if (checkMainAxis) {
const minSide = mainAxis === 'y' ? 'top' : 'left';
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
const min = mainAxisCoord + overflow[minSide];
const max = mainAxisCoord - overflow[maxSide];
mainAxisCoord = clamp(min, mainAxisCoord, max);
mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
}
if (checkCrossAxis) {
const minSide = crossAxis === 'y' ? 'top' : 'left';
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
const min = crossAxisCoord + overflow[minSide];
const max = crossAxisCoord - overflow[maxSide];
crossAxisCoord = clamp(min, crossAxisCoord, max);
crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
}

@@ -927,2 +905,3 @@ const limitedCoords = limiter.fn({

fn(state) {
var _rawOffset$mainAxis, _rawOffset$crossAxis;
const {

@@ -953,5 +932,4 @@ x,

} : {
mainAxis: 0,
crossAxis: 0,
...rawOffset
mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
};

@@ -988,2 +966,8 @@ if (checkMainAxis) {

// Method syntax keeps callback parameters bivariant, but expressing the
// explicit `| undefined` required by `exactOptionalPropertyTypes` needs
// property syntax, which is contravariant under `strictFunctionTypes`.
// Extracting the function from a method position restores that bivariance so
// consumers can still assign callbacks with narrower parameter types.
/**

@@ -1003,3 +987,2 @@ * Provides data that allows you to change the size of the floating element —

async fn(state) {
var _state$middlewareData, _state$middlewareData2;
const {

@@ -1036,20 +1019,17 @@ placement,

const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
const noShift = !state.middlewareData.shift;
const shiftData = state.middlewareData.shift;
const noShift = !shiftData;
let availableHeight = overflowAvailableHeight;
let availableWidth = overflowAvailableWidth;
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
if (shiftData != null && shiftData.enabled.x) {
availableWidth = maximumClippingWidth;
}
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
if (shiftData != null && shiftData.enabled.y) {
availableHeight = maximumClippingHeight;
}
if (noShift && !alignment) {
const xMin = max(overflow.left, 0);
const xMax = max(overflow.right, 0);
const yMin = max(overflow.top, 0);
const yMax = max(overflow.bottom, 0);
if (isYAxis) {
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
availableWidth = width - 2 * max(overflow.left, overflow.right);
} else {
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
availableHeight = height - 2 * max(overflow.top, overflow.bottom);
}

@@ -1056,0 +1036,0 @@ }

@@ -101,8 +101,8 @@ (function (global, factory) {

function expandPaddingObject(padding) {
var _padding$top, _padding$right, _padding$bottom, _padding$left;
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...padding
top: (_padding$top = padding.top) != null ? _padding$top : 0,
right: (_padding$right = padding.right) != null ? _padding$right : 0,
bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
left: (_padding$left = padding.left) != null ? _padding$left : 0
};

@@ -182,9 +182,5 @@ }

}
switch (getAlignment(placement)) {
case 'start':
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
break;
case 'end':
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
break;
const alignment = getAlignment(placement);
if (alignment) {
coords[alignmentAxis] += commonAlign * (alignment === 'end' ? 1 : -1) * (rtl && isVertical ? -1 : 1);
}

@@ -238,8 +234,5 @@ return coords;

const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) && (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
};

@@ -415,6 +408,5 @@ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({

// point is outside the floating element's bounds.
const min$1 = minPadding;
const max = clientSize - arrowDimensions[length] - maxPadding;
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset = clamp(min$1, center, max);
const offset = clamp(minPadding, center, max);

@@ -425,4 +417,4 @@ // If the reference is small enough that the arrow's padding causes it to

// a single reset is performed when this is true.
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
return {

@@ -481,3 +473,2 @@ [axis]: coords[axis] + alignmentOffset,

const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;

@@ -488,3 +479,2 @@ const currentPlacement = placements$1[currentIndex];

}
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));

@@ -499,2 +489,4 @@ // Make `computeCoords` start from the right place.

}
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];

@@ -806,2 +798,9 @@ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {

const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
// No rects (e.g. a hidden or detached reference, or a collapsed range) —
// keep the existing reference rect rather than resetting to an invalid
// one with non-finite values.
if (!nativeClientRects.length) {
return {};
}
const clientRects = getRectsByLine(nativeClientRects);

@@ -812,3 +811,3 @@ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));

// There are two rects and they are disjoined.
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
if (clientRects.length === 2 && (clientRects[0].left > clientRects[1].right || clientRects[1].left > clientRects[0].right) && x != null && y != null) {
// Find the first rect in which the point is fully inside.

@@ -828,14 +827,8 @@ return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;

const right = isTop ? firstRect.right : lastRect.right;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
return rectToClientRect({
x: left,
y: top
};
y: top,
width: right - left,
height: bottom - top
});
}

@@ -848,16 +841,8 @@ const isLeftSide = getSide(placement) === 'left';

const bottom = measureRects[measureRects.length - 1].bottom;
const left = minLeft;
const right = maxRight;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
x: left,
y: top
};
return rectToClientRect({
x: minLeft,
y: top,
width: maxRight - minLeft,
height: bottom - top
});
}

@@ -1012,19 +997,12 @@ return fallback;

const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const crossAxis = getSideAxis(getSide(placement));
const crossAxis = getSideAxis(placement);
const mainAxis = getOppositeAxis(crossAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === 'y' ? 'top' : 'left'], coord, coord - overflow[axis === 'y' ? 'bottom' : 'right']);
if (checkMainAxis) {
const minSide = mainAxis === 'y' ? 'top' : 'left';
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
const min = mainAxisCoord + overflow[minSide];
const max = mainAxisCoord - overflow[maxSide];
mainAxisCoord = clamp(min, mainAxisCoord, max);
mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
}
if (checkCrossAxis) {
const minSide = crossAxis === 'y' ? 'top' : 'left';
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
const min = crossAxisCoord + overflow[minSide];
const max = crossAxisCoord - overflow[maxSide];
crossAxisCoord = clamp(min, crossAxisCoord, max);
crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
}

@@ -1060,2 +1038,3 @@ const limitedCoords = limiter.fn({

fn(state) {
var _rawOffset$mainAxis, _rawOffset$crossAxis;
const {

@@ -1086,5 +1065,4 @@ x,

} : {
mainAxis: 0,
crossAxis: 0,
...rawOffset
mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
};

@@ -1121,2 +1099,8 @@ if (checkMainAxis) {

// Method syntax keeps callback parameters bivariant, but expressing the
// explicit `| undefined` required by `exactOptionalPropertyTypes` needs
// property syntax, which is contravariant under `strictFunctionTypes`.
// Extracting the function from a method position restores that bivariance so
// consumers can still assign callbacks with narrower parameter types.
/**

@@ -1136,3 +1120,2 @@ * Provides data that allows you to change the size of the floating element —

async fn(state) {
var _state$middlewareData, _state$middlewareData2;
const {

@@ -1169,20 +1152,17 @@ placement,

const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
const noShift = !state.middlewareData.shift;
const shiftData = state.middlewareData.shift;
const noShift = !shiftData;
let availableHeight = overflowAvailableHeight;
let availableWidth = overflowAvailableWidth;
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
if (shiftData != null && shiftData.enabled.x) {
availableWidth = maximumClippingWidth;
}
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
if (shiftData != null && shiftData.enabled.y) {
availableHeight = maximumClippingHeight;
}
if (noShift && !alignment) {
const xMin = max(overflow.left, 0);
const xMax = max(overflow.right, 0);
const yMin = max(overflow.top, 0);
const yMax = max(overflow.bottom, 0);
if (isYAxis) {
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
availableWidth = width - 2 * max(overflow.left, overflow.right);
} else {
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
availableHeight = height - 2 * max(overflow.top, overflow.bottom);
}

@@ -1189,0 +1169,0 @@ }

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUICore={})}(this,(function(t){"use strict";const e=["top","right","bottom","left"],n=["start","end"],i=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),o=Math.min,r=Math.max,a={left:"right",right:"left",bottom:"top",top:"bottom"};function l(t,e,n){return r(t,o(e,n))}function s(t,e){return"function"==typeof t?t(e):t}function f(t){return t.split("-")[0]}function c(t){return t.split("-")[1]}function m(t){return"x"===t?"y":"x"}function u(t){return"y"===t?"height":"width"}function d(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function g(t){return m(d(t))}function p(t,e,n){void 0===n&&(n=!1);const i=c(t),o=g(t),r=u(o);let a="x"===o?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=A(a)),[a,A(a)]}function h(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const y=["left","right"],w=["right","left"],x=["top","bottom"],v=["bottom","top"];function b(t,e,n,i){const o=c(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?w:y:e?y:w;case"left":case"right":return e?x:v;default:return[]}}(f(t),"start"===n,i);return o&&(r=r.map((t=>t+"-"+o)),e&&(r=r.concat(r.map(h)))),r}function A(t){const e=f(t);return a[e]+t.slice(e.length)}function R(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function O(t){const{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function P(t,e,n){let{reference:i,floating:o}=t;const r=d(e),a=g(e),l=u(a),s=f(e),m="y"===r,p=i.x+i.width/2-o.width/2,h=i.y+i.height/2-o.height/2,y=i[l]/2-o[l]/2;let w;switch(s){case"top":w={x:p,y:i.y-o.height};break;case"bottom":w={x:p,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y:h};break;case"left":w={x:i.x-o.width,y:h};break;default:w={x:i.x,y:i.y}}switch(c(e)){case"start":w[a]-=y*(n&&m?-1:1);break;case"end":w[a]+=y*(n&&m?-1:1)}return w}async function D(t,e){var n;void 0===e&&(e={});const{x:i,y:o,platform:r,rects:a,elements:l,strategy:f}=t,{boundary:c="clippingAncestors",rootBoundary:m="viewport",elementContext:u="floating",altBoundary:d=!1,padding:g=0}=s(e,t),p=R(g),h=l[d?"floating"===u?"reference":"floating":u],y=O(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(h)))||n?h:h.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(l.floating)),boundary:c,rootBoundary:m,strategy:f})),w="floating"===u?{x:i,y:o,width:a.floating.width,height:a.floating.height}:a.reference,x=await(null==r.getOffsetParent?void 0:r.getOffsetParent(l.floating)),v=await(null==r.isElement?void 0:r.isElement(x))&&await(null==r.getScale?void 0:r.getScale(x))||{x:1,y:1},b=O(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:x,strategy:f}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}function T(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function E(t){return e.some((e=>t[e]>=0))}function L(t){const e=o(...t.map((t=>t.left))),n=o(...t.map((t=>t.top)));return{x:e,y:n,width:r(...t.map((t=>t.right)))-e,height:r(...t.map((t=>t.bottom)))-n}}const k=new Set(["left","top"]);t.arrow=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:a,platform:f,elements:m,middlewareData:d}=e,{element:p,padding:h=0}=s(t,e)||{};if(null==p)return{};const y=R(h),w={x:n,y:i},x=g(r),v=u(x),b=await f.getDimensions(p),A="y"===x,O=A?"top":"left",P=A?"bottom":"right",D=A?"clientHeight":"clientWidth",T=a.reference[v]+a.reference[x]-w[x]-a.floating[v],E=w[x]-a.reference[x],L=await(null==f.getOffsetParent?void 0:f.getOffsetParent(p));let k=L?L[D]:0;k&&await(null==f.isElement?void 0:f.isElement(L))||(k=m.floating[D]||a.floating[v]);const C=T/2-E/2,H=k/2-b[v]/2-1,S=o(y[O],H),B=o(y[P],H),F=S,j=k-b[v]-B,z=k/2-b[v]/2+C,M=l(F,z,j),V=!d.arrow&&null!=c(r)&&z!==M&&a.reference[v]/2-(z<F?S:B)-b[v]/2<0,W=V?z<F?z-F:z-j:0;return{[x]:w[x]+W,data:{[x]:M,centerOffset:z-M-W,...V&&{alignmentOffset:W}},reset:V}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,o,r;const{rects:a,middlewareData:l,placement:m,platform:u,elements:d}=e,{crossAxis:g=!1,alignment:y,allowedPlacements:w=i,autoAlignment:x=!0,...v}=s(t,e),b=void 0!==y||w===i?function(t,e,n){return(t?[...n.filter((e=>c(e)===t)),...n.filter((e=>c(e)!==t))]:n.filter((t=>f(t)===t))).filter((n=>!t||c(n)===t||!!e&&h(n)!==n))}(y||null,x,w):w,A=await u.detectOverflow(e,v),R=(null==(n=l.autoPlacement)?void 0:n.index)||0,O=b[R];if(null==O)return{};const P=p(O,a,await(null==u.isRTL?void 0:u.isRTL(d.floating)));if(m!==O)return{reset:{placement:b[0]}};const D=[A[f(O)],A[P[0]],A[P[1]]],T=[...(null==(o=l.autoPlacement)?void 0:o.overflows)||[],{placement:O,overflows:D}],E=b[R+1];if(E)return{data:{index:R+1,overflows:T},reset:{placement:E}};const L=T.map((t=>{const e=c(t.placement);return[t.placement,e&&g?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(r=L.filter((t=>t[2].slice(0,c(t[0])?2:3).every((t=>t<=0))))[0])?void 0:r[0])||L[0][0];return k!==m?{data:{index:R+1,overflows:T},reset:{placement:k}}:{}}}},t.computePosition=async(t,e,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:D},s=await(null==a.isRTL?void 0:a.isRTL(e));let f=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:c,y:m}=P(f,i,s),u=i,d=0;const g={};for(let n=0;n<r.length;n++){const p=r[n];if(!p)continue;const{name:h,fn:y}=p,{x:w,y:x,data:v,reset:b}=await y({x:c,y:m,initialPlacement:i,placement:u,strategy:o,middlewareData:g,rects:f,platform:l,elements:{reference:t,floating:e}});c=null!=w?w:c,m=null!=x?x:m,g[h]={...g[h],...v},b&&d<50&&(d++,"object"==typeof b&&(b.placement&&(u=b.placement),b.rects&&(f=!0===b.rects?await a.getElementRects({reference:t,floating:e,strategy:o}):b.rects),({x:c,y:m}=P(f,u,s))),n=-1)}return{x:c,y:m,placement:u,strategy:o,middlewareData:g}},t.detectOverflow=D,t.flip=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,i;const{placement:o,middlewareData:r,rects:a,initialPlacement:l,platform:c,elements:m}=e,{mainAxis:u=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0,...R}=s(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const O=f(o),P=d(l),D=f(l)===l,T=await(null==c.isRTL?void 0:c.isRTL(m.floating)),E=y||(D||!v?[A(l)]:function(t){const e=A(t);return[h(t),e,h(e)]}(l)),L="none"!==x;!y&&L&&E.push(...b(l,v,x,T));const k=[l,...E],C=await c.detectOverflow(e,R),H=[];let S=(null==(i=r.flip)?void 0:i.overflows)||[];if(u&&H.push(C[O]),g){const t=p(o,a,T);H.push(C[t[0]],C[t[1]])}if(S=[...S,{placement:o,overflows:H}],!H.every((t=>t<=0))){var B,F;const t=((null==(B=r.flip)?void 0:B.index)||0)+1,e=k[t];if(e){if(!("alignment"===g&&P!==d(e))||S.every((t=>d(t.placement)!==P||t.overflows[0]>0)))return{data:{index:t,overflows:S},reset:{placement:e}}}let n=null==(F=S.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(w){case"bestFit":{var j;const t=null==(j=S.filter((t=>{if(L){const e=d(t.placement);return e===P||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:j[0];t&&(n=t);break}case"initialPlacement":n=l}if(o!==n)return{reset:{placement:n}}}return{}}}},t.hide=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:i}=e,{strategy:o="referenceHidden",...r}=s(t,e);switch(o){case"referenceHidden":{const t=T(await i.detectOverflow(e,{...r,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:E(t)}}}case"escaped":{const t=T(await i.detectOverflow(e,{...r,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:E(t)}}}default:return{}}}}},t.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:i,rects:a,platform:l,strategy:c}=e,{padding:m=2,x:u,y:g}=s(t,e),p=Array.from(await(null==l.getClientRects?void 0:l.getClientRects(i.reference))||[]),h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let i=null;for(let t=0;t<e.length;t++){const o=e[t];!i||o.y-i.y>i.height/2?n.push([o]):n[n.length-1].push(o),i=o}return n.map((t=>O(L(t))))}(p),y=O(L(p)),w=R(m);const x=await l.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&h[0].left>h[1].right&&null!=u&&null!=g)return h.find((t=>u>t.left-w.left&&u<t.right+w.right&&g>t.top-w.top&&g<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===d(n)){const t=h[0],e=h[h.length-1],i="top"===f(n),o=t.top,r=e.bottom,a=i?t.left:e.left,l=i?t.right:e.right;return{top:o,bottom:r,left:a,right:l,width:l-a,height:r-o,x:a,y:o}}const t="left"===f(n),e=r(...h.map((t=>t.right))),i=o(...h.map((t=>t.left))),a=h.filter((n=>t?n.left===i:n.right===e)),l=a[0].top,s=a[a.length-1].bottom;return{top:l,bottom:s,left:i,right:e,width:e-i,height:s-l,x:i,y:l}}return y}},floating:i.floating,strategy:c});return a.reference.x!==x.reference.x||a.reference.y!==x.reference.y||a.reference.width!==x.reference.width||a.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:i,placement:o,rects:r,middlewareData:a}=e,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=s(t,e),g={x:n,y:i},p=d(o),h=m(p);let y=g[h],w=g[p];const x=s(l,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const t="y"===h?"height":"width",e=r.reference[h]-r.floating[t]+v.mainAxis,n=r.reference[h]+r.reference[t]-v.mainAxis;y<e?y=e:y>n&&(y=n)}if(u){var b,A;const t="y"===h?"width":"height",e=k.has(f(o)),n=r.reference[p]-r.floating[t]+(e&&(null==(b=a.offset)?void 0:b[p])||0)+(e?0:v.crossAxis),i=r.reference[p]+r.reference[t]+(e?0:(null==(A=a.offset)?void 0:A[p])||0)-(e?v.crossAxis:0);w<n?w=n:w>i&&(w=i)}return{[h]:y,[p]:w}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:o,y:r,placement:a,middlewareData:l}=e,m=await async function(t,e){const{placement:n,platform:i,elements:o}=t,r=await(null==i.isRTL?void 0:i.isRTL(o.floating)),a=f(n),l=c(n),m="y"===d(n),u=k.has(a)?-1:1,g=r&&m?-1:1,p=s(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&"number"==typeof w&&(y="end"===l?-1*w:w),m?{x:y*g,y:h*u}:{x:h*u,y:y*g}}(e,t);return a===(null==(n=l.offset)?void 0:n.placement)&&null!=(i=l.arrow)&&i.alignmentOffset?{}:{x:o+m.x,y:r+m.y,data:{...m,placement:a}}}}},t.rectToClientRect=O,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:o,platform:r}=e,{mainAxis:a=!0,crossAxis:c=!1,limiter:u={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...g}=s(t,e),p={x:n,y:i},h=await r.detectOverflow(e,g),y=d(f(o)),w=m(y);let x=p[w],v=p[y];if(a){const t="y"===w?"bottom":"right";x=l(x+h["y"===w?"top":"left"],x,x-h[t])}if(c){const t="y"===y?"bottom":"right";v=l(v+h["y"===y?"top":"left"],v,v-h[t])}const b=u.fn({...e,[w]:x,[y]:v});return{...b,data:{x:b.x-n,y:b.y-i,enabled:{[w]:a,[y]:c}}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var n,i;const{placement:a,rects:l,platform:m,elements:u}=e,{apply:g=()=>{},...p}=s(t,e),h=await m.detectOverflow(e,p),y=f(a),w=c(a),x="y"===d(a),{width:v,height:b}=l.floating;let A,R;"top"===y||"bottom"===y?(A=y,R=w===(await(null==m.isRTL?void 0:m.isRTL(u.floating))?"start":"end")?"left":"right"):(R=y,A="end"===w?"top":"bottom");const O=b-h.top-h.bottom,P=v-h.left-h.right,D=o(b-h[A],O),T=o(v-h[R],P),E=!e.middlewareData.shift;let L=D,k=T;if(null!=(n=e.middlewareData.shift)&&n.enabled.x&&(k=P),null!=(i=e.middlewareData.shift)&&i.enabled.y&&(L=O),E&&!w){const t=r(h.left,0),e=r(h.right,0),n=r(h.top,0),i=r(h.bottom,0);x?k=v-2*(0!==t||0!==e?t+e:r(h.left,h.right)):L=b-2*(0!==n||0!==i?n+i:r(h.top,h.bottom))}await g({...e,availableWidth:k,availableHeight:L});const C=await m.getDimensions(u.floating);return v!==C.width||b!==C.height?{reset:{rects:!0}}:{}}}}}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUICore={})}(this,(function(t){"use strict";const e=["top","right","bottom","left"],n=["start","end"],i=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),r=Math.min,o=Math.max,l={left:"right",right:"left",bottom:"top",top:"bottom"};function a(t,e,n){return o(t,r(e,n))}function s(t,e){return"function"==typeof t?t(e):t}function f(t){return t.split("-")[0]}function c(t){return t.split("-")[1]}function u(t){return"x"===t?"y":"x"}function m(t){return"y"===t?"height":"width"}function d(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function g(t){return u(d(t))}function p(t,e,n){void 0===n&&(n=!1);const i=c(t),r=g(t),o=m(r);let l="x"===r?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[o]>e.floating[o]&&(l=A(l)),[l,A(l)]}function h(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const y=["left","right"],w=["right","left"],x=["top","bottom"],v=["bottom","top"];function b(t,e,n,i){const r=c(t);let o=function(t,e,n){switch(t){case"top":case"bottom":return n?e?w:y:e?y:w;case"left":case"right":return e?x:v;default:return[]}}(f(t),"start"===n,i);return r&&(o=o.map((t=>t+"-"+r)),e&&(o=o.concat(o.map(h)))),o}function A(t){const e=f(t);return l[e]+t.slice(e.length)}function R(t){return"number"!=typeof t?function(t){var e,n,i,r;return{top:null!=(e=t.top)?e:0,right:null!=(n=t.right)?n:0,bottom:null!=(i=t.bottom)?i:0,left:null!=(r=t.left)?r:0}}(t):{top:t,right:t,bottom:t,left:t}}function O(t){const{x:e,y:n,width:i,height:r}=t;return{width:i,height:r,top:n,left:e,right:e+i,bottom:n+r,x:e,y:n}}function P(t,e,n){let{reference:i,floating:r}=t;const o=d(e),l=g(e),a=m(l),s=f(e),u="y"===o,p=i.x+i.width/2-r.width/2,h=i.y+i.height/2-r.height/2,y=i[a]/2-r[a]/2;let w;switch(s){case"top":w={x:p,y:i.y-r.height};break;case"bottom":w={x:p,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y:h};break;case"left":w={x:i.x-r.width,y:h};break;default:w={x:i.x,y:i.y}}const x=c(e);return x&&(w[l]+=y*("end"===x?1:-1)*(n&&u?-1:1)),w}async function T(t,e){var n;void 0===e&&(e={});const{x:i,y:r,platform:o,rects:l,elements:a,strategy:f}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:d=!1,padding:g=0}=s(e,t),p=R(g),h=a[d?"floating"===m?"reference":"floating":m],y=O(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(h)))||n?h:h.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:f})),w="floating"===m?{x:i,y:r,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),v=await(null==o.isElement?void 0:o.isElement(x))&&await(null==o.getScale?void 0:o.getScale(x))||{x:1,y:1},b=O(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:x,strategy:f}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}function D(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function E(t){return e.some((e=>t[e]>=0))}function L(t){const e=r(...t.map((t=>t.left))),n=r(...t.map((t=>t.top)));return{x:e,y:n,width:o(...t.map((t=>t.right)))-e,height:o(...t.map((t=>t.bottom)))-n}}const k=new Set(["left","top"]);t.arrow=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:o,rects:l,platform:f,elements:u,middlewareData:d}=e,{element:p,padding:h=0}=s(t,e)||{};if(null==p)return{};const y=R(h),w={x:n,y:i},x=g(o),v=m(x),b=await f.getDimensions(p),A="y"===x,O=A?"top":"left",P=A?"bottom":"right",T=A?"clientHeight":"clientWidth",D=l.reference[v]+l.reference[x]-w[x]-l.floating[v],E=w[x]-l.reference[x],L=await(null==f.getOffsetParent?void 0:f.getOffsetParent(p));let k=L?L[T]:0;k&&await(null==f.isElement?void 0:f.isElement(L))||(k=u.floating[T]||l.floating[v]);const C=D/2-E/2,H=k/2-b[v]/2-1,S=r(y[O],H),B=r(y[P],H),F=k-b[v]-B,j=k/2-b[v]/2+C,z=a(S,j,F),M=!d.arrow&&null!=c(o)&&j!==z&&l.reference[v]/2-(j<S?S:B)-b[v]/2<0,V=M?j<S?j-S:j-F:0;return{[x]:w[x]+V,data:{[x]:z,centerOffset:j-z-V,...M&&{alignmentOffset:V}},reset:M}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,o;const{rects:l,middlewareData:a,placement:u,platform:m,elements:d}=e,{crossAxis:g=!1,alignment:y,allowedPlacements:w=i,autoAlignment:x=!0,...v}=s(t,e),b=void 0!==y||w===i?function(t,e,n){return(t?[...n.filter((e=>c(e)===t)),...n.filter((e=>c(e)!==t))]:n.filter((t=>f(t)===t))).filter((n=>!t||c(n)===t||!!e&&h(n)!==n))}(y||null,x,w):w,A=(null==(n=a.autoPlacement)?void 0:n.index)||0,R=b[A];if(null==R)return{};if(u!==R)return{reset:{placement:b[0]}};const O=await m.detectOverflow(e,v),P=p(R,l,await(null==m.isRTL?void 0:m.isRTL(d.floating))),T=[O[f(R)],O[P[0]],O[P[1]]],D=[...(null==(r=a.autoPlacement)?void 0:r.overflows)||[],{placement:R,overflows:T}],E=b[A+1];if(E)return{data:{index:A+1,overflows:D},reset:{placement:E}};const L=D.map((t=>{const e=c(t.placement);return[t.placement,e&&g?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(o=L.filter((t=>t[2].slice(0,c(t[0])?2:3).every((t=>t<=0))))[0])?void 0:o[0])||L[0][0];return k!==u?{data:{index:A+1,overflows:D},reset:{placement:k}}:{}}}},t.computePosition=async(t,e,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:l}=n,a=l.detectOverflow?l:{...l,detectOverflow:T},s=await(null==l.isRTL?void 0:l.isRTL(e));let f=await l.getElementRects({reference:t,floating:e,strategy:r}),{x:c,y:u}=P(f,i,s),m=i,d=0;const g={};for(let n=0;n<o.length;n++){const p=o[n];if(!p)continue;const{name:h,fn:y}=p,{x:w,y:x,data:v,reset:b}=await y({x:c,y:u,initialPlacement:i,placement:m,strategy:r,middlewareData:g,rects:f,platform:a,elements:{reference:t,floating:e}});c=null!=w?w:c,u=null!=x?x:u,g[h]={...g[h],...v},b&&d<50&&(d++,"object"==typeof b&&(b.placement&&(m=b.placement),b.rects&&(f=!0===b.rects?await l.getElementRects({reference:t,floating:e,strategy:r}):b.rects),({x:c,y:u}=P(f,m,s))),n=-1)}return{x:c,y:u,placement:m,strategy:r,middlewareData:g}},t.detectOverflow=T,t.flip=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,i;const{placement:r,middlewareData:o,rects:l,initialPlacement:a,platform:c,elements:u}=e,{mainAxis:m=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0,...R}=s(t,e);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const O=f(r),P=d(a),T=f(a)===a,D=await(null==c.isRTL?void 0:c.isRTL(u.floating)),E=y||(T||!v?[A(a)]:function(t){const e=A(t);return[h(t),e,h(e)]}(a)),L="none"!==x;!y&&L&&E.push(...b(a,v,x,D));const k=[a,...E],C=await c.detectOverflow(e,R),H=[];let S=(null==(i=o.flip)?void 0:i.overflows)||[];if(m&&H.push(C[O]),g){const t=p(r,l,D);H.push(C[t[0]],C[t[1]])}if(S=[...S,{placement:r,overflows:H}],!H.every((t=>t<=0))){var B,F;const t=((null==(B=o.flip)?void 0:B.index)||0)+1,e=k[t];if(e){if(!("alignment"===g&&P!==d(e))||S.every((t=>d(t.placement)!==P||t.overflows[0]>0)))return{data:{index:t,overflows:S},reset:{placement:e}}}let n=null==(F=S.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(w){case"bestFit":{var j;const t=null==(j=S.filter((t=>{if(L){const e=d(t.placement);return e===P||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:j[0];t&&(n=t);break}case"initialPlacement":n=a}if(r!==n)return{reset:{placement:n}}}return{}}}},t.hide=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:i}=e,{strategy:r="referenceHidden",...o}=s(t,e);switch(r){case"referenceHidden":{const t=D(await i.detectOverflow(e,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:E(t)}}}case"escaped":{const t=D(await i.detectOverflow(e,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:E(t)}}}default:return{}}}}},t.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:i,rects:l,platform:a,strategy:c}=e,{padding:u=2,x:m,y:g}=s(t,e),p=Array.from(await(null==a.getClientRects?void 0:a.getClientRects(i.reference))||[]);if(!p.length)return{};const h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let i=null;for(let t=0;t<e.length;t++){const r=e[t];!i||r.y-i.y>i.height/2?n.push([r]):n[n.length-1].push(r),i=r}return n.map((t=>O(L(t))))}(p),y=O(L(p)),w=R(u);const x=await a.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&(h[0].left>h[1].right||h[1].left>h[0].right)&&null!=m&&null!=g)return h.find((t=>m>t.left-w.left&&m<t.right+w.right&&g>t.top-w.top&&g<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===d(n)){const t=h[0],e=h[h.length-1],i="top"===f(n),r=t.top,o=e.bottom,l=i?t.left:e.left;return O({x:l,y:r,width:(i?t.right:e.right)-l,height:o-r})}const t="left"===f(n),e=o(...h.map((t=>t.right))),i=r(...h.map((t=>t.left))),l=h.filter((n=>t?n.left===i:n.right===e)),a=l[0].top,s=l[l.length-1].bottom;return O({x:i,y:a,width:e-i,height:s-a})}return y}},floating:i.floating,strategy:c});return l.reference.x!==x.reference.x||l.reference.y!==x.reference.y||l.reference.width!==x.reference.width||l.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(e){var n,i;const{x:r,y:o,placement:l,rects:a,middlewareData:c}=e,{offset:m=0,mainAxis:g=!0,crossAxis:p=!0}=s(t,e),h={x:r,y:o},y=d(l),w=u(y);let x=h[w],v=h[y];const b=s(m,e),A="number"==typeof b?{mainAxis:b,crossAxis:0}:{mainAxis:null!=(n=b.mainAxis)?n:0,crossAxis:null!=(i=b.crossAxis)?i:0};if(g){const t="y"===w?"height":"width",e=a.reference[w]-a.floating[t]+A.mainAxis,n=a.reference[w]+a.reference[t]-A.mainAxis;x<e?x=e:x>n&&(x=n)}if(p){var R,O;const t="y"===w?"width":"height",e=k.has(f(l)),n=a.reference[y]-a.floating[t]+(e&&(null==(R=c.offset)?void 0:R[y])||0)+(e?0:A.crossAxis),i=a.reference[y]+a.reference[t]+(e?0:(null==(O=c.offset)?void 0:O[y])||0)-(e?A.crossAxis:0);v<n?v=n:v>i&&(v=i)}return{[w]:x,[y]:v}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:r,y:o,placement:l,middlewareData:a}=e,u=await async function(t,e){const{placement:n,platform:i,elements:r}=t,o=await(null==i.isRTL?void 0:i.isRTL(r.floating)),l=f(n),a=c(n),u="y"===d(n),m=k.has(l)?-1:1,g=o&&u?-1:1,p=s(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&"number"==typeof w&&(y="end"===a?-1*w:w),u?{x:y*g,y:h*m}:{x:h*m,y:y*g}}(e,t);return l===(null==(n=a.offset)?void 0:n.placement)&&null!=(i=a.arrow)&&i.alignmentOffset?{}:{x:r+u.x,y:o+u.y,data:{...u,placement:l}}}}},t.rectToClientRect=O,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:r,platform:o}=e,{mainAxis:l=!0,crossAxis:f=!1,limiter:c={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...m}=s(t,e),g={x:n,y:i},p=await o.detectOverflow(e,m),h=d(r),y=u(h);let w=g[y],x=g[h];const v=(t,e)=>a(e+p["y"===t?"top":"left"],e,e-p["y"===t?"bottom":"right"]);l&&(w=v(y,w)),f&&(x=v(h,x));const b=c.fn({...e,[y]:w,[h]:x});return{...b,data:{x:b.x-n,y:b.y-i,enabled:{[y]:l,[h]:f}}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:i,platform:l,elements:a}=e,{apply:u=()=>{},...m}=s(t,e),g=await l.detectOverflow(e,m),p=f(n),h=c(n),y="y"===d(n),{width:w,height:x}=i.floating;let v,b;"top"===p||"bottom"===p?(v=p,b=h===(await(null==l.isRTL?void 0:l.isRTL(a.floating))?"start":"end")?"left":"right"):(b=p,v="end"===h?"top":"bottom");const A=x-g.top-g.bottom,R=w-g.left-g.right,O=r(x-g[v],A),P=r(w-g[b],R),T=e.middlewareData.shift,D=!T;let E=O,L=P;null!=T&&T.enabled.x&&(L=R),null!=T&&T.enabled.y&&(E=A),D&&!h&&(y?L=w-2*o(g.left,g.right):E=x-2*o(g.top,g.bottom)),await u({...e,availableWidth:L,availableHeight:E});const k=await l.getDimensions(a.floating);return w!==k.width||x!==k.height?{reset:{rects:!0}}:{}}}}}));
{
"name": "@floating-ui/core",
"version": "1.7.5",
"version": "1.8.0",
"description": "Positioning library for floating elements: tooltips, popovers, dropdowns, and more",

@@ -46,3 +46,3 @@ "publishConfig": {

"dependencies": {
"@floating-ui/utils": "^0.2.11"
"@floating-ui/utils": "^0.2.12"
},

@@ -56,3 +56,3 @@ "devDependencies": {

"lint": "eslint .",
"format": "prettier --write .",
"format": "prettier --ignore-path ../../.gitignore --write .",
"clean": "rimraf dist out-tsc",

@@ -59,0 +59,0 @@ "dev": "rollup -c -w",