"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=t=>t.parentElement||t.getRootNode().host||null,y=t=>{const o=t.getBoundingClientRect(),n="offsetWidth"in t&&Math.abs(o.width)/t.offsetWidth||1,e="offsetHeight"in t&&Math.abs(o.height)/t.offsetHeight||1;return{top:o.top,right:o.left+t.clientWidth*n,bottom:o.top+t.clientHeight*e,left:o.left}},d=t=>{const o=parseInt(t,10);return Number.isNaN(o)?0:o},m=(t,o,n,e,i,s)=>t<n&&o>e?0:t<n?-(n-t+i):o>e?o-t>e-n?t+i-n:o-e+s:0,D=(t,o)=>{var s,h,p;const n=t.ownerDocument;let e=o,i=t;for(;i;){const r=i===n.body,c=r?{top:0,right:((s=window.visualViewport)==null?void 0:s.width)??n.documentElement.clientWidth,bottom:((h=window.visualViewport)==null?void 0:h.height)??n.documentElement.clientHeight,left:0}:y(i),l=getComputedStyle(i),f=m(e.left,e.right,c.left,c.right,d(l.scrollPaddingLeft),d(l.scrollPaddingRight)),u=m(e.top,e.bottom,c.top,c.bottom,d(l.scrollPaddingTop),d(l.scrollPaddingBottom));if(f||u)if(r)(p=n.defaultView)==null||p.scrollBy(f,u);else{const{scrollLeft:w,scrollTop:a}=i;u&&(i.scrollTop+=u),f&&(i.scrollLeft+=f);const g=i.scrollLeft-w,b=i.scrollTop-a;e={left:e.left-g,top:e.top-b,right:e.right-g,bottom:e.bottom-b}}i=r||l.position==="fixed"?null:T(i)}};exports.default=D;
