site/node_modules/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs

2 lines
8.9 KiB
JavaScript
Raw Normal View History

2024-10-14 06:09:33 +00:00
import{rectToClientRect as t,detectOverflow as e,offset as n,autoPlacement as o,shift as i,flip as r,size as c,hide as l,arrow as s,inline as f,limitShift as u,computePosition as a}from"@floating-ui/core";const d=Math.min,h=Math.max,p=Math.round,m=Math.floor,g=t=>({x:t,y:t});function y(t){return x(t)?(t.nodeName||"").toLowerCase():"#document"}function w(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function v(t){var e;return null==(e=(x(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function x(t){return t instanceof Node||t instanceof w(t).Node}function b(t){return t instanceof Element||t instanceof w(t).Element}function L(t){return t instanceof HTMLElement||t instanceof w(t).HTMLElement}function T(t){return"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof w(t).ShadowRoot)}function R(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=O(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function E(t){return["table","td","th"].includes(y(t))}function S(t){const e=C(),n=O(t);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function C(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function F(t){return["html","body","#document"].includes(y(t))}function O(t){return w(t).getComputedStyle(t)}function D(t){return b(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function H(t){if("html"===y(t))return t;const e=t.assignedSlot||t.parentNode||T(t)&&t.host||v(t);return T(e)?e.host:e}function W(t){const e=H(t);return F(e)?t.ownerDocument?t.ownerDocument.body:t.body:L(e)&&R(e)?e:W(e)}function M(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=W(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=w(i);return r?e.concat(c,c.visualViewport||[],R(i)?i:[],c.frameElement&&n?M(c.frameElement):[]):e.concat(i,M(i,[],n))}function z(t){const e=O(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=L(t),r=i?t.offsetWidth:n,c=i?t.offsetHeight:o,l=p(n)!==r||p(o)!==c;return l&&(n=r,o=c),{width:n,height:o,$:l}}function P(t){return b(t)?t:t.contextElement}function V(t){const e=P(t);if(!L(e))return g(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=z(e);let c=(r?p(n.width):n.width)/o,l=(r?p(n.height):n.height)/i;return c&&Number.isFinite(c)||(c=1),l&&Number.isFinite(l)||(l=1),{x:c,y:l}}const A=g(0);function N(t){const e=w(t);return C()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:A}function B(e,n,o,i){void 0===n&&(n=!1),void 0===o&&(o=!1);const r=e.getBoundingClientRect(),c=P(e);let l=g(1);n&&(i?b(i)&&(l=V(i)):l=V(e));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==w(t))&&e}(c,o,i)?N(c):g(0);let f=(r.left+s.x)/l.x,u=(r.top+s.y)/l.y,a=r.width/l.x,d=r.height/l.y;if(c){const t=w(c),e=i&&b(i)?w(i):i;let n=t,o=n.frameElement;for(;o&&i&&e!==n;){const t=V(o),e=o.getBoundingClientRect(),i=O(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;f*=t.x,u*=t.y,a*=t.x,d*=t.y,f+=r,u+=c,n=w(o),o=n.frameElement}}return t({width:a,height:d,x:f,y:u})}const k=[":popover-open",":modal"];function I(t){return k.some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function q(t){return B(v(t)).left+D(t).scrollLeft}function X(e,n,o){let i;if("viewport"===n)i=function(t,e){const n=w(t),o=v(t),i=n.visualViewport;let r=o.clientWidth,c=o.clientHeight,l=0,s=0;if(i){r=i.width,c=i.height;const t=C();(!t||t&&"fixed"===e)&&(l=i.offsetLeft,s=i.offsetTop)}return{width:r,height:c,x:l,y:s}}(e,o);else if("document"===n)i=function(t){const e=v(t),n=D(t),o=t.ownerDocument.body,i=h(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=