2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
|
|
"use strict";var Ht=Object.defineProperty,Vt=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var nt=Object.getOwnPropertySymbols;var xt=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable;var wt=(t,e,n)=>e in t?Ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,A=(t,e)=>{for(var n in e||(e={}))xt.call(e,n)&&wt(t,n,e[n]);if(nt)for(var n of nt(e))yt.call(e,n)&&wt(t,n,e[n]);return t},R=(t,e)=>Vt(t,zt(e));var G=(t,e)=>{var n={};for(var o in t)xt.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&nt)for(var o of nt(t))e.indexOf(o)<0&&yt.call(t,o)&&(n[o]=t[o]);return n};var T=(t,e,n)=>new Promise((o,i)=>{var r=l=>{try{f(n.next(l))}catch(c){i(c)}},s=l=>{try{f(n.throw(l))}catch(c){i(c)}},f=l=>l.done?o(l.value):Promise.resolve(l.value).then(r,s);f((n=n.apply(t,e)).next())});const $t=["top","right","bottom","left"],I=Math.min,C=Math.max,it=Math.round,ot=Math.floor,P=t=>({x:t,y:t}),_t={left:"right",right:"left",bottom:"top",top:"bottom"},It={start:"end",end:"start"};function vt(t,e,n){return C(t,I(e,n))}function Y(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function Z(t){return t.split("-")[1]}function Lt(t){return t==="x"?"y":"x"}function Tt(t){return t==="y"?"height":"width"}function tt(t){return["top","bottom"].includes(W(t))?"y":"x"}function St(t){return Lt(tt(t))}function Xt(t,e,n){n===void 0&&(n=!1);const o=Z(t),i=St(t),r=Tt(i);let s=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=st(s)),[s,st(s)]}function Yt(t){const e=st(t);return[ft(t),e,ft(e)]}function ft(t){return t.replace(/start|end/g,e=>It[e])}function jt(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:s;default:return[]}}function Ut(t,e,n,o){const i=Z(t);let r=jt(W(t),n==="start",o);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(ft)))),r}function st(t){return t.replace(/left|right|bottom|top/g,e=>_t[e])}function qt(t){return A({top:0,right:0,bottom:0,left:0},t)}function Kt(t){return typeof t!="number"?qt(t):{top:t,right:t,bottom:t,left:t}}function rt(t){return R(A({},t),{top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height})}function bt(t,e,n){let{reference:o,floating:i}=t;const r=tt(e),s=St(e),f=Tt(s),l=W(e),c=r==="y",d=o.x+o.width/2-i.width/2,a=o.y+o.height/2-i.height/2,h=o[f]/2-i[f]/2;let u;switch(l){case"top":u={x:d,y:o.y-i.height};break;case"bottom":u={x:d,y:o.y+o.height};break;case"right":u={x:o.x+o.width,y:a};break;case"left":u={x:o.x-i.width,y:a};break;default:u={x:o.x,y:o.y}}switch(Z(e)){case"start":u[s]-=h*(n&&c?-1:1);break;case"end":u[s]+=h*(n&&c?-1:1);break}return u}const Gt=(t,e,n)=>T(exports,null,function*(){const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:s}=n,f=r.filter(Boolean),l=yield s.isRTL==null?void 0:s.isRTL(e);let c=yield s.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:a}=bt(c,o,l),h=o,u={},g=0;for(let m=0;m<f.length;m++){const{name:w,fn:p}=f[m],{x,y,data:b,reset:v}=yield p({x:d,y:a,initialPlacement:o,placement:h,strategy:i,middlewareData:u,rects:c,platform:s,elements:{reference:t,floating:e}});d=x!=null?x:d,a=y!=null?y:a,u=R(A({},u),{[w]:A(A({},u[w]),b)}),v&&g<=50&&(g++,typeof v=="object"&&(v.placement&&(h=v.placement),v.rects&&(c=v.rects===!0?yield s.getElementRects({reference:t,floating:e,strategy:i}):v.rects),{x:d,y:a}=bt(c,h,l)),m=-1)}return{x:d,y:a,placement:h,strategy:i,middlewareData:u}});function J(t,e){return T(this,null,function*(){var n;e===void 0&&(e={});const{x:o,y:i,platform:r,rects:s,elements:f,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:a="floating",altBoundary:h=!1,padding:u=0}=Y(e,t),g=Kt(u),w=f[h?a==="floating"?"reference":"floating":a],p=rt(yield r.getClippingRect({element:(n=yield r.isElement==null?void 0:r.isElement(w))==null||n?w:w.contextElement||(yield r.getDocumentElement==null?void 0:r.getDocumentElement(f.floating)),boundary:c,rootBoundary:d,strategy:l}
|