go-dy/html/assets/@floating-ui-c5dc13b6.js
2025-10-28 16:50:24 +08:00

2 lines
10 KiB
JavaScript

var t=Object.defineProperty,e=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,l=(e,n,o)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,c=(t,e)=>{for(var n in e||(e={}))i.call(e,n)&&l(t,n,e[n]);if(o)for(var n of o(e))r.call(e,n)&&l(t,n,e[n]);return t},s=(t,o)=>e(t,n(o)),f=(t,e,n)=>new Promise(((o,i)=>{var r=t=>{try{c(n.next(t))}catch(e){i(e)}},l=t=>{try{c(n.throw(t))}catch(e){i(e)}},c=t=>t.done?o(t.value):Promise.resolve(t.value).then(r,l);c((n=n.apply(t,e)).next())}));function a(t){return t.split("-")[1]}function u(t){return"y"===t?"height":"width"}function d(t){return t.split("-")[0]}function h(t){return["top","bottom"].includes(d(t))?"x":"y"}function y(t,e,n){let{reference:o,floating:i}=t;const r=o.x+o.width/2-i.width/2,l=o.y+o.height/2-i.height/2,c=h(e),s=u(c),f=o[s]/2-i[s]/2,y="x"===c;let p;switch(d(e)){case"top":p={x:r,y:o.y-i.height};break;case"bottom":p={x:r,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:l};break;case"left":p={x:o.x-i.width,y:l};break;default:p={x:o.x,y:o.y}}switch(a(e)){case"start":p[c]-=f*(n&&y?-1:1);break;case"end":p[c]+=f*(n&&y?-1:1)}return p}const p=Math.min,g=Math.max;const m=t=>({name:"arrow",options:t,fn(e){return f(this,null,(function*(){const{element:n,padding:o=0}=t||{},{x:i,y:r,placement:l,rects:s,platform:f}=e;if(null==n)return{};const d="number"!=typeof(O=o)?c({top:0,right:0,bottom:0,left:0},O):{top:O,right:O,bottom:O,left:O},y={x:i,y:r},m=h(l),x=u(m),w=yield f.getDimensions(n),b="y"===m?"top":"left",v="y"===m?"bottom":"right",L=s.reference[x]+s.reference[m]-y[m]-s.floating[x],T=y[m]-s.reference[m],R=yield null==f.getOffsetParent?void 0:f.getOffsetParent(n);var O;let A=R?"y"===m?R.clientHeight||0:R.clientWidth||0:0;0===A&&(A=s.floating[x]);const P=L/2-T/2,D=d[b],C=A-w[x]-d[v],E=A/2-w[x]/2+P,W=function(t,e,n){return g(t,p(e,n))}(D,E,C),k=null!=a(l)&&E!=W&&s.reference[x]/2-(E<D?d[b]:d[v])-w[x]/2<0;return{[m]:y[m]-(k?E<D?D-E:C-E:0),data:{[m]:W,centerOffset:E-W}}}))}});["top","right","bottom","left"].reduce(((t,e)=>t.concat(e,e+"-start",e+"-end")),[]);const x=function(t){return void 0===t&&(t=0),{name:"offset",options:t,fn(e){return f(this,null,(function*(){const{x:n,y:o}=e,i=yield function(t,e){return f(this,null,(function*(){const{placement:n,platform:o,elements:i}=t,r=yield null==o.isRTL?void 0:o.isRTL(i.floating),l=d(n),s=a(n),f="x"===h(n),u=["left","top"].includes(l)?-1:1,y=r&&f?-1:1,p="function"==typeof e?e(t):e;let{mainAxis:g,crossAxis:m,alignmentAxis:x}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:c({mainAxis:0,crossAxis:0,alignmentAxis:null},p);return s&&"number"==typeof x&&(m="end"===s?-1*x:x),f?{x:m*y,y:g*u}:{x:g*u,y:m*y}}))}(e,t);return{x:n+i.x,y:o+i.y,data:i}}))}}};function w(t){var e;return(null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function b(t){return w(t).getComputedStyle(t)}const v=Math.min,L=Math.max,T=Math.round;function R(t){const e=b(t);let n=parseFloat(e.width),o=parseFloat(e.height);const i=t.offsetWidth,r=t.offsetHeight,l=T(n)!==i||T(o)!==r;return l&&(n=i,o=r),{width:n,height:o,fallback:l}}function O(t){return E(t)?(t.nodeName||"").toLowerCase():""}let A;function P(){if(A)return A;const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?(A=t.brands.map((t=>t.brand+"/"+t.version)).join(" "),A):navigator.userAgent}function D(t){return t instanceof w(t).HTMLElement}function C(t){return t instanceof w(t).Element}function E(t){return t instanceof w(t).Node}function W(t){return"undefined"!=typeof ShadowRoot&&(t instanceof w(t).ShadowRoot||t instanceof ShadowRoot)}function k(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=b(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function H(t){return["table","td","th"].includes(O(t))}function j(t){const e=/firefox/i.test(P()),n=b(t),o=n.backdropFilter||n.WebkitBackdropFilter;return"none"!==n.transform||"none"!==n.perspective||!!o&&"none"!==o||e&&"filter"===n.willChange||e&&!!n.filter&&"none"!==n.filter||["transform","perspective"].some((t=>n.willChange.includes(t)))||["paint","layout","strict","content"].some((t=>{const e=n.contain;return null!=e&&e.includes(t)}))}function F(){return/^((?!chrome|android).)*safari/i.test(P())}function S(t){return["html","body","#document"].includes(O(t))}function V(t){return C(t)?t:t.contextElement}const B={x:1,y:1};function M(t){const e=V(t);if(!D(e))return B;const n=e.getBoundingClientRect(),{width:o,height:i,fallback:r}=R(e);let l=(r?T(n.width):n.width)/o,c=(r?T(n.height):n.height)/i;return l&&Number.isFinite(l)||(l=1),c&&Number.isFinite(c)||(c=1),{x:l,y:c}}function N(t,e,n,o){var i,r;void 0===e&&(e=!1),void 0===n&&(n=!1);const l=t.getBoundingClientRect(),c=V(t);let s=B;e&&(o?C(o)&&(s=M(o)):s=M(t));const f=c?w(c):window,a=F()&&n;let u=(l.left+(a&&(null==(i=f.visualViewport)?void 0:i.offsetLeft)||0))/s.x,d=(l.top+(a&&(null==(r=f.visualViewport)?void 0:r.offsetTop)||0))/s.y,h=l.width/s.x,y=l.height/s.y;if(c){const t=w(c),e=o&&C(o)?w(o):o;let n=t.frameElement;for(;n&&o&&e!==t;){const t=M(n),e=n.getBoundingClientRect(),o=getComputedStyle(n);e.x+=(n.clientLeft+parseFloat(o.paddingLeft))*t.x,e.y+=(n.clientTop+parseFloat(o.paddingTop))*t.y,u*=t.x,d*=t.y,h*=t.x,y*=t.y,u+=e.x,d+=e.y,n=w(n).frameElement}}return{width:h,height:y,top:d,right:u+h,bottom:d+y,left:u,x:u,y:d}}function X(t){return((E(t)?t.ownerDocument:t.document)||window.document).documentElement}function Y(t){return C(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function _(t){return N(X(t)).left+Y(t).scrollLeft}function I(t){if("html"===O(t))return t;const e=t.assignedSlot||t.parentNode||W(t)&&t.host||X(t);return W(e)?e.host:e}function q(t){const e=I(t);return S(e)?e.ownerDocument.body:D(e)&&k(e)?e:q(e)}function z(t,e){var n;void 0===e&&(e=[]);const o=q(t),i=o===(null==(n=t.ownerDocument)?void 0:n.body),r=w(o);return i?e.concat(r,r.visualViewport||[],k(o)?o:[]):e.concat(o,z(o))}function G(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=w(t),o=X(t),i=n.visualViewport;let r=o.clientWidth,l=o.clientHeight,c=0,s=0;if(i){r=i.width,l=i.height;const t=F();(!t||t&&"fixed"===e)&&(c=i.offsetLeft,s=i.offsetTop)}return{width:r,height:l,x:c,y:s}}(t,n);else if("document"===e)o=function(t){const e=X(t),n=Y(t),o=t.ownerDocument.body,i=L(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=L(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let l=-n.scrollLeft+_(t);const c=-n.scrollTop;return"rtl"===b(o).direction&&(l+=L(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:l,y:c}}(X(t));else if(C(e))o=function(t,e){const n=N(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=D(t)?M(t):{x:1,y:1};return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(e,n);else{const n=c({},e);if(F()){var i,r;const e=w(t);n.x-=(null==(i=e.visualViewport)?void 0:i.offsetLeft)||0,n.y-=(null==(r=e.visualViewport)?void 0:r.offsetTop)||0}o=n}return s(c({},l=o),{top:l.y,left:l.x,right:l.x+l.width,bottom:l.y+l.height});var l}function J(t,e){return D(t)&&"fixed"!==b(t).position?e?e(t):t.offsetParent:null}function K(t,e){const n=w(t);let o=J(t,e);for(;o&&H(o)&&"static"===b(o).position;)o=J(o,e);return o&&("html"===O(o)||"body"===O(o)&&"static"===b(o).position&&!j(o))?n:o||function(t){let e=I(t);for(;D(e)&&!S(e);){if(j(e))return e;e=I(e)}return null}(t)||n}function Q(t,e,n){const o=D(e),i=X(e),r=N(t,!0,"fixed"===n,e);let l={scrollLeft:0,scrollTop:0};const c={x:0,y:0};if(o||!o&&"fixed"!==n)if(("body"!==O(e)||k(i))&&(l=Y(e)),D(e)){const t=N(e,!0);c.x=t.x+e.clientLeft,c.y=t.y+e.clientTop}else i&&(c.x=_(i));return{x:r.left+l.scrollLeft-c.x,y:r.top+l.scrollTop-c.y,width:r.width,height:r.height}}const U={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[..."clippingAncestors"===n?function(t,e){const n=e.get(t);if(n)return n;let o=z(t).filter((t=>C(t)&&"body"!==O(t))),i=null;const r="fixed"===b(t).position;let l=r?I(t):t;for(;C(l)&&!S(l);){const t=b(l),e=j(l);"fixed"===t.position?i=null:(r?e||i:e||"static"!==t.position||!i||!["absolute","fixed"].includes(i.position))?i=t:o=o.filter((t=>t!==l)),l=I(l)}return e.set(t,o),o}(e,this._c):[].concat(n),o],l=r[0],c=r.reduce(((t,n)=>{const o=G(e,n,i);return t.top=L(o.top,t.top),t.right=v(o.right,t.right),t.bottom=v(o.bottom,t.bottom),t.left=L(o.left,t.left),t}),G(e,l,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=D(n),r=X(n);if(n===r)return e;let l={scrollLeft:0,scrollTop:0},c={x:1,y:1};const s={x:0,y:0};if((i||!i&&"fixed"!==o)&&(("body"!==O(n)||k(r))&&(l=Y(n)),D(n))){const t=N(n);c=M(n),s.x=t.x+n.clientLeft,s.y=t.y+n.clientTop}return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+s.x,y:e.y*c.y-l.scrollTop*c.y+s.y}},isElement:C,getDimensions:function(t){return D(t)?R(t):t.getBoundingClientRect()},getOffsetParent:K,getDocumentElement:X,getScale:M,getElementRects(t){return f(this,null,(function*(){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||K,r=this.getDimensions;return{reference:Q(e,yield i(n),o),floating:c({x:0,y:0},yield r(n))}}))},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>"rtl"===b(t).direction},Z=(t,e,n)=>{const o=new Map,i=c({platform:U},n),r=s(c({},i.platform),{_c:o});return((t,e,n)=>f(void 0,null,(function*(){const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:l}=n,f=r.filter(Boolean),a=yield null==l.isRTL?void 0:l.isRTL(e);let u=yield l.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:h}=y(u,o,a),p=o,g={},m=0;for(let n=0;n<f.length;n++){const{name:r,fn:x}=f[n],{x:w,y:b,data:v,reset:L}=yield x({x:d,y:h,initialPlacement:o,placement:p,strategy:i,middlewareData:g,rects:u,platform:l,elements:{reference:t,floating:e}});d=null!=w?w:d,h=null!=b?b:h,g=s(c({},g),{[r]:c(c({},g[r]),v)}),L&&m<=50&&(m++,"object"==typeof L&&(L.placement&&(p=L.placement),L.rects&&(u=!0===L.rects?yield l.getElementRects({reference:t,floating:e,strategy:i}):L.rects),({x:d,y:h}=y(u,p,a))),n=-1)}return{x:d,y:h,placement:p,strategy:i,middlewareData:g}})))(t,e,s(c({},i),{platform:r}))};export{x as O,m,Z as z};