Files

2 lines
5.1 KiB
JavaScript
Raw Permalink Normal View History

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;v<a.length;v++){const{name:p,fn:y}=a[v],{x:g,y:A,data:b,reset:w}=await y({x:m,y:n,initialPlacement:e,placement:r,strategy:l,middlewareData:i,rects:u,platform:c,elements:{reference:o,floating:s}});m=g??m,n=A??n,i={...i,[p]:{...i[p],...b}},w&&d<=50&&(d++,typeof w=="object"&&(w.placement&&(r=w.placement),w.rects&&(u=w.rects===!0?await c.getElementRects({reference:o,floating:s,strategy:l}):w.rects),{x:m,y:n}=Y(u,r,x)),v=-1)}return{x:m,y:n,placement:r,strategy:l,middlewareData:i}};async function I(o,s){var f;s===void 0&&(s={});const{x:e,y:l,platform:t,rects:c,elements:a,strategy:x}=o,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:n="floating",altBoundary:r=!1,padding:i=0}=D(s,o),d=N(i),p=a[r?n==="floating"?"reference":"floating":n],y=X(await t.getClippingRect({element:(f=await(t.isElement==null?void 0:t.isElement(p)))==null||f?p:p.contextElement||await(t.getDocumentElement==null?void 0:t.getDocumentElement(a.floating)),boundary:u,rootBoundary:m,strategy:x})),g=n==="floating"?{x:e,y:l,width:c.floating.width,height:c.floating.height}:c.reference,A=await(t.getOffsetParent==null?void 0:t.getOffsetParent(a.floating)),b=await(t.isElement==null?void 0:t.isElement(A))?await(t.getScale==null?void 0:t.getScale(A))||{x:1,y:1}:{x:1,y:1},w=X(t.convertOffsetParentRelativeRectToViewportRelativeRect?await t.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:g,offsetParent:A,strategy:x}):g);return{top:(y.top-w.top+d.top)/b.y,bottom:(w.bottom-y.bottom+d.bottom)/b.y,left:(y.left-w.left+d.left)/b.x,right:(w.right-y.right+d.right)/b.x}}const ie=function(o){return o===void 0&&(o={}),{name:"flip",options:o,async fn(s){var f,e;const{placement:l,middlewareData:t,rects:c,initialPlacement:a,platform:x,elements:u}=s,{mainAxis:m=!0,crossAxis:n=!0,fallbackPlacements:r,fallbackStrategy:i="bestFit",fallbackAxisSideDirection:d="none",flipAlignment:v=!0,...p}=D(o,s);if((f=t.arrow)!=null&&f.alignmentOffset)return{};const y=E(l),g=C(a),A=E(a)===a,b=await(x.isRTL==null?void 0:x.isRTL(u.floating)),w=r||(A||!v?[G(a)]:H(a)),F=d!=="none";!r&&F&&w.push(...J(a,v,d,b));const q=[a,...w],L=await I(s,p),T=[];let O=((e=t.flip)==null?void 0:e.overflows)||[];if(m&&T.push(L[y]),n){const R=K(l,c,b);T.push(L[R[0]],L[R[1]])}if(O=[...O,{placement:l,overflows:T}],!T.every(R=>R<=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: