import{e as D,g as E,a as C,b as G,c as H,d as J,f as K,h as $,i as N,r as X,j as _,k as Q,l as U,m as W}from"./vendor-floating-ui-utils-CALKnY__.js";function Y(o,s,f){let{reference:e,floating:l}=o;const t=C(s),c=U(s),a=W(c),x=E(s),u=t==="y",m=e.x+e.width/2-l.width/2,n=e.y+e.height/2-l.height/2,r=e[a]/2-l[a]/2;let i;switch(x){case"top":i={x:m,y:e.y-l.height};break;case"bottom":i={x:m,y:e.y+e.height};break;case"right":i={x:e.x+e.width,y:n};break;case"left":i={x:e.x-l.width,y:n};break;default:i={x:e.x,y:e.y}}switch(_(s)){case"start":i[c]-=r*(f&&u?-1:1);break;case"end":i[c]+=r*(f&&u?-1:1);break}return i}const ne=async(o,s,f)=>{const{placement:e="bottom",strategy:l="absolute",middleware:t=[],platform:c}=f,a=t.filter(Boolean),x=await(c.isRTL==null?void 0:c.isRTL(s));let u=await c.getElementRects({reference:o,floating:s,strategy:l}),{x:m,y:n}=Y(u,e,x),r=e,i={},d=0;for(let v=0;vR<=0)){var M,j;const R=(((M=t.flip)==null?void 0:M.index)||0)+1,V=q[R];if(V&&(!(n==="alignment"?g!==C(V):!1)||O.every(h=>C(h.placement)===g?h.overflows[0]>0:!0)))return{data:{index:R,overflows:O},reset:{placement:V}};let S=(j=O.filter(k=>k.overflows[0]<=0).sort((k,h)=>k.overflows[1]-h.overflows[1])[0])==null?void 0:j.placement;if(!S)switch(i){case"bestFit":{var B;const k=(B=O.filter(h=>{if(F){const P=C(h.placement);return P===g||P==="y"}return!0}).map(h=>[h.placement,h.overflows.filter(P=>P>0).reduce((P,z)=>P+z,0)]).sort((h,P)=>h[1]-P[1])[0])==null?void 0:B[0];k&&(S=k);break}case"initialPlacement":S=a;break}if(l!==S)return{reset:{placement:S}}}return{}}}},Z=new Set(["left","top"]);async function ee(o,s){const{placement:f,platform:e,elements:l}=o,t=await(e.isRTL==null?void 0:e.isRTL(l.floating)),c=E(f),a=_(f),x=C(f)==="y",u=Z.has(c)?-1:1,m=t&&x?-1:1,n=D(s,o);let{mainAxis:r,crossAxis:i,alignmentAxis:d}=typeof n=="number"?{mainAxis:n,crossAxis:0,alignmentAxis:null}:{mainAxis:n.mainAxis||0,crossAxis:n.crossAxis||0,alignmentAxis:n.alignmentAxis};return a&&typeof d=="number"&&(i=a==="end"?d*-1:d),x?{x:i*m,y:r*u}:{x:r*u,y:i*m}}const se=function(o){return o===void 0&&(o=0),{name:"offset",options:o,async fn(s){var f,e;const{x:l,y:t,placement:c,middlewareData:a}=s,x=await ee(s,o);return c===((f=a.offset)==null?void 0:f.placement)&&(e=a.arrow)!=null&&e.alignmentOffset?{}:{x:l+x.x,y:t+x.y,data:{...x,placement:c}}}}},ae=function(o){return o===void 0&&(o={}),{name:"shift",options:o,async fn(s){const{x:f,y:e,placement:l}=s,{mainAxis:t=!0,crossAxis:c=!1,limiter:a={fn:p=>{let{x:y,y:g}=p;return{x:y,y:g}}},...x}=D(o,s),u={x:f,y:e},m=await I(s,x),n=C(E(l)),r=Q(n);let i=u[r],d=u[n];if(t){const p=r==="y"?"top":"left",y=r==="y"?"bottom":"right",g=i+m[p],A=i-m[y];i=$(g,i,A)}if(c){const p=n==="y"?"top":"left",y=n==="y"?"bottom":"right",g=d+m[p],A=d-m[y];d=$(g,d,A)}const v=a.fn({...s,[r]:i,[n]:d});return{...v,data:{x:v.x-f,y:v.y-e,enabled:{[r]:t,[n]:c}}}}}};export{ne as c,ie as f,se as o,ae as s};